| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- @using WeApp
- @using WeApp.Configuration
- @using WeApp.Views.Shared.Modals
- @model WeApp.Models.Account.LoginFormViewModel
- @{
- ViewBag.Title = L("LogIn");
- }
- @section styles
- {
- }
- @section scripts
- {
- <script>
- (function () {
- $(function () {
- var $loginForm = $('#LoginForm');
- $loginForm.submit(function (e) {
- e.preventDefault();
- if (!$loginForm.valid()) {
- return;
- }
- abp.ui.setBusy(
- $('#LoginArea'),
- $.iwbAjax4({
- url: '/Account/Login',
- form: $loginForm,
- success: function () {
- abp.ui.setBusy();
- abp.message.success("登陆成功", "登陆");
- },
- error: function (error) {
- if (error.details) {
- return abp.message.error(error.details, error.message);
- } else {
- return abp.message.error(error.message || abp.ajax.defaultError.message);
- }
- }
- })
- );
- });
- $('a.social-login-link').click(function () {
- var $a = $(this);
- var $form = $a.closest('form');
- $form.find('input[name=provider]').val($a.attr('data-provider'));
- $form.submit();
- });
- $('input[name=returnUrlHash]').val(location.hash);
- $('#LoginForm input:first-child').focus();
- });
-
- })();
- function RememberChange(that) {
- var $that = $(that);
- $that.val($that.is(':checked'));
- }
- </script>
- @if (ViewBag.IsMultiTenancyEnabled)
- {
- <script>
- function changeTenant() {
- $('#TenantChangeModal').iwbModal();
- }
- (function () {
-
- $(function() {
- var $tenantChangeForm = $('#TenantChangeForm');
- $tenantChangeForm.find('select').select2();
- function switchToSelectedTenant() {
- var tenancyName = $tenantChangeForm.find('#TenancyName').val();
- if (!tenancyName) {
- abp.multiTenancy.setTenantIdCookie(null);
- location.reload();
- return;
- }
- $.iwbAjax4({
- url: '@Path.Combine(ApplicationPath, IwbConsts.ApiAppUrl)account/isTenantAvailable',
- form:$tenantChangeForm,
- success: function (result) {
- switch (result.state) {
- case 1: //Available
- abp.multiTenancy.setTenantIdCookie(result.tenantId);
- //_modalManager.close();
- location.reload();
- return;
- case 2: //InActive
- abp.message.warn(abp.utils.formatString(abp.localization
- .localize("TenantIsNotActive", "WeApp"),
- tenancyName));
- break;
- case 3: //NotFound
- abp.message.warn(abp.utils.formatString(abp.localization
- .localize("ThereIsNoTenantDefinedWithName{0}", "WeApp"),
- tenancyName));
- break;
- }
- }
- });
- }
- //Handle save button click
- $tenantChangeForm.closest('div.modal-content').find(".save-btn").click(function (e) {
- e.preventDefault();
- switchToSelectedTenant();
- });
- //Handle enter key
- $tenantChangeForm.find('input').on('keypress', function (e) {
- if (e.which === 13) {
- e.preventDefault();
- switchToSelectedTenant();
- }
- });
- //$.AdminBSB.input.activate($tenantChangeForm);
- //$('#TenantChangeModal').on('shown.bs.modal', function () {
- // $tenantChangeForm.find('input[type=text]:first').focus();
- //});
- });
- })();
- </script>
- }
- }
- <div class="card">
- <div class="body">
- @if (ViewBag.IsMultiTenancyEnabled)
- {
- <div class="text-center" style="margin-bottom: 3px;">
- <span>
- @L("CurrentTenant"):
- @if (Model.Tenant != null)
- {
- <span title="@Model.Tenant.Name"><strong>@Model.Tenant.TenancyName</strong></span>
- }
- else
- {
- <span>@L("NotSelected")</span>
- }
- (<a href="javascript:void(0)" data-toggle="modal" onclick="changeTenant()">@L("Change")</a>)
- </span>
- </div>
- List<SelectListItem> tenantList = ViewBag.TenantList;
- var tenantModal = new ModalViewModel(L("ChangeTenant"), "", new ModalBodyViewModel(new List<Input>()
- {
- new Input("TenancyName", L("TenancyName")).SetSelectOptions(tenantList,isAddBlank:false)
- //.SetHelp(L("LeaveEmptyToSwitchToHost"))
- }, "TenantChangeForm"), "TenantChangeModal");
- @section modal{
- @Html.Partial("Modals/_Modal", tenantModal)
- }
- }
- <form id="LoginForm" method="POST">
- <input type="hidden" name="returnUrl" value="@Model.ReturnUrl" />
- <input type="hidden" name="returnUrlHash" />
- <h4 class="text-center login-title">@L("LogIn")</h4>
- <div class="input-group">
- <span class="input-group-prepend">
- <span class="input-group-text"><i class="fa fa-user"></i></span>
- </span>
- <input type="text" class="form-control" name="UsernameOrEmailAddress" required autofocus maxlength="100">
- </div>
- <div class="input-group">
- <span class="input-group-prepend">
- <span class="input-group-text"><i class="fa fa-lock"></i></span>
- </span>
- <input type="password" class="form-control" name="Password" required maxlength="100">
- </div>
- <div class="row">
- <div class="col-9">
- @*<input type="checkbox" name="RememberMe" id="rememberme" class="filled-in chk-col-pink" value="true">
- <label for="rememberme">@L("RememberMe")</label>*@
- <label class="iwb-checkbox">
- <input data-index="0" name="rememberMe" id="rememberme" type="checkbox" value="false" onchange="RememberChange(this)">
- <span></span>
- @L("RememberMe")
- </label>
- </div>
- <div class="col-3">
- <button id="LoginButton" class="btn btn-sm btn-block btn-iwb waves-effect" type="submit">@L("LogIn")</button>
- </div>
- </div>
- @if (Model.IsSelfRegistrationAllowed)
- {
- <div class="row">
- <div class="col-12">
- <a href="@Url.Action("Register", "Account")">@L("Register")</a>
- </div>
- </div>
- }
- </form>
- </div>
- </div>
|