Login.cshtml 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. @using WeOnlineApp
  2. @using WeOnlineApp.Configuration
  3. @using WeOnlineApp.Views.Shared.Modals
  4. @model WeOnlineApp.Models.Account.LoginFormViewModel
  5. @{
  6. ViewBag.Title = L("LogIn");
  7. }
  8. @section styles
  9. {
  10. <style>
  11. input::-webkit-input-placeholder,
  12. input:-moz-placeholder,
  13. input::-moz-placeholder,
  14. input:-ms-input-placeholder {
  15. color: #eee;
  16. opacity: 0.9;
  17. }
  18. </style>
  19. }
  20. @section scripts
  21. {
  22. <script>
  23. (function () {
  24. $(function () {
  25. $.iwbAjax5({
  26. url: "/api/services/app/query/LoadPackagePre?type=0",
  27. complete: function () {
  28. }
  29. });
  30. var $loginForm = $('#LoginForm');
  31. $loginForm.submit(function (e) {
  32. e.preventDefault();
  33. if (!$loginForm.valid()) {
  34. return;
  35. }
  36. abp.ui.setBusy(
  37. $('#LoginArea'),
  38. $.iwbAjax4({
  39. url: '/Account/Login',
  40. form: $loginForm,
  41. success: function () {
  42. abp.ui.setBusy();
  43. abp.message.success("登陆成功", "登陆");
  44. },
  45. error: function (error) {
  46. if (error.details) {
  47. return abp.message.error(error.details, error.message);
  48. } else {
  49. return abp.message.error(error.message || abp.ajax.defaultError.message);
  50. }
  51. }
  52. })
  53. );
  54. });
  55. $('a.social-login-link').click(function () {
  56. var $a = $(this);
  57. var $form = $a.closest('form');
  58. $form.find('input[name=provider]').val($a.attr('data-provider'));
  59. $form.submit();
  60. });
  61. $('input[name=returnUrlHash]').val(location.hash);
  62. $('#LoginForm input:first-child').focus();
  63. });
  64. })();
  65. function RememberChange(that) {
  66. var $that = $(that);
  67. $that.val($that.is(':checked'));
  68. }
  69. </script>
  70. @if (ViewBag.IsMultiTenancyEnabled)
  71. {
  72. <script>
  73. function changeTenant() {
  74. $('#TenantChangeModal').iwbModal();
  75. }
  76. (function () {
  77. $(function() {
  78. var $tenantChangeForm = $('#TenantChangeForm');
  79. $tenantChangeForm.find('select').select2();
  80. function switchToSelectedTenant() {
  81. var tenancyName = $tenantChangeForm.find('#TenancyName').val();
  82. if (!tenancyName) {
  83. abp.multiTenancy.setTenantIdCookie(null);
  84. location.reload();
  85. return;
  86. }
  87. $.iwbAjax4({
  88. url: '@Path.Combine(ApplicationPath, IwbConsts.ApiAppUrl)account/isTenantAvailable',
  89. form:$tenantChangeForm,
  90. success: function (result) {
  91. switch (result.state) {
  92. case 1: //Available
  93. abp.multiTenancy.setTenantIdCookie(result.tenantId);
  94. //_modalManager.close();
  95. location.reload();
  96. return;
  97. case 2: //InActive
  98. abp.message.warn(abp.utils.formatString(abp.localization
  99. .localize("TenantIsNotActive", "WeOnlineApp"),
  100. tenancyName));
  101. break;
  102. case 3: //NotFound
  103. abp.message.warn(abp.utils.formatString(abp.localization
  104. .localize("ThereIsNoTenantDefinedWithName{0}", "WeOnlineApp"),
  105. tenancyName));
  106. break;
  107. }
  108. }
  109. });
  110. }
  111. //Handle save button click
  112. $tenantChangeForm.closest('div.modal-content').find(".save-btn").click(function (e) {
  113. e.preventDefault();
  114. switchToSelectedTenant();
  115. });
  116. //Handle enter key
  117. $tenantChangeForm.find('input').on('keypress', function (e) {
  118. if (e.which === 13) {
  119. e.preventDefault();
  120. switchToSelectedTenant();
  121. }
  122. });
  123. //$.AdminBSB.input.activate($tenantChangeForm);
  124. //$('#TenantChangeModal').on('shown.bs.modal', function () {
  125. // $tenantChangeForm.find('input[type=text]:first').focus();
  126. //});
  127. });
  128. })();
  129. </script>
  130. }
  131. }
  132. <div class="card">
  133. <div class="body">
  134. @if (ViewBag.IsMultiTenancyEnabled)
  135. {
  136. <div class="text-center" style="margin-bottom: 3px;">
  137. <span>
  138. @L("CurrentTenant"):
  139. @if (Model.Tenant != null)
  140. {
  141. <span title="@Model.Tenant.Name"><strong>@Model.Tenant.TenancyName</strong></span>
  142. }
  143. else
  144. {
  145. <span>@L("NotSelected")</span>
  146. }
  147. (<a href="javascript:void(0)" data-toggle="modal" onclick="changeTenant()">@L("Change")</a>)
  148. </span>
  149. </div>
  150. List<SelectListItem> tenantList = ViewBag.TenantList;
  151. var tenantModal = new ModalViewModel(L("ChangeTenant"), "", new ModalBodyViewModel(new List<Input>()
  152. {
  153. new Input("TenancyName", L("TenancyName")).SetSelectOptions(tenantList,isAddBlank:false)
  154. //.SetHelp(L("LeaveEmptyToSwitchToHost"))
  155. }, "TenantChangeForm"), "TenantChangeModal");
  156. @section modal{
  157. @Html.Partial("Modals/_Modal", tenantModal)
  158. }
  159. }
  160. <form id="LoginForm" method="POST">
  161. <input type="hidden" name="returnUrl" value="@Model.ReturnUrl" />
  162. <input type="hidden" name="returnUrlHash" />
  163. <h4 class="text-center login-title">@L("LogIn")</h4>
  164. <div class="input-group">
  165. <span class="input-group-prepend">
  166. <span class="input-group-text"><i class="fa fa-user"></i></span>
  167. </span>
  168. @*<input type="text" class="form-control required" name="UsernameOrEmailAddress" placeholder="@L("UserNameOrEmail")" autofocus maxlength="100">*@
  169. <input type="text" class="form-control required" name="UsernameOrEmailAddress" autofocus="" maxlength="100">
  170. </div>
  171. <div class="input-group">
  172. <span class="input-group-prepend">
  173. <span class="input-group-text"><i class="fa fa-lock"></i></span>
  174. </span>
  175. @*<input type="password" class="form-control required" name="Password" placeholder="@L("Password")" maxlength="100">*@
  176. <input type="password" class="form-control required" name="Password" maxlength="100">
  177. </div>
  178. <div class="row">
  179. <div class="col-9">
  180. @*<input type="checkbox" name="RememberMe" id="rememberme" class="filled-in chk-col-pink" value="true">
  181. <label for="rememberme">@L("RememberMe")</label>*@
  182. <label class="iwb-checkbox">
  183. <input data-index="0" name="rememberMe" id="rememberme" type="checkbox" value="false" onchange="RememberChange(this)">
  184. <span></span>
  185. @L("RememberMe")
  186. </label>
  187. </div>
  188. <div class="col-3">
  189. <button id="LoginButton" class="btn btn-sm btn-block btn-iwb waves-effect" type="submit">@L("LogIn")</button>
  190. </div>
  191. </div>
  192. @if (Model.IsSelfRegistrationAllowed)
  193. {
  194. <div class="row">
  195. <div class="col-12">
  196. <a href="@Url.Action("Register", "Account")">@L("Register")</a>
  197. </div>
  198. </div>
  199. }
  200. </form>
  201. </div>
  202. </div>