EditPIndex.js 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * 描 述:修改密码页面前端脚本
  3. */
  4. (function ($) {
  5. "use strict";
  6. var wmsPage = {
  7. init: function () {
  8. $('#psw_change_op').css({
  9. 'background': 'url(' + $.rootUrl + '/Content/images/Login/psw0.png) no-repeat center center'
  10. });
  11. $('#psw_change_np').css({
  12. 'background': 'url(' + $.rootUrl + '/Content/images/Login/psw0.png) no-repeat center center'
  13. });
  14. $("#wms_username").val(request('username'));
  15. if (window.location.href != top.window.location.href) {
  16. top.window.location.href = window.location.href;
  17. }
  18. var isIE = !!window.ActiveXObject;
  19. var isIE6 = isIE && !window.XMLHttpRequest;
  20. if (isIE6) {
  21. window.location.href = $.rootUrl + "/Error/ErrorBrowser";
  22. }
  23. wmsPage.bind();
  24. },
  25. bind: function () {
  26. // 回车键
  27. document.onkeydown = function (e) {
  28. e = e || window.event;
  29. if ((e.keyCode || e.which) == 13) {
  30. $('#wms_login_edit').trigger('click');
  31. }
  32. }
  33. //输入框获取焦点
  34. $('.wms-login-input input').on('focus', function () {
  35. var src = $(this).prev().attr('src');
  36. $(this).prev().attr('src', src.replace(/0.png$/, '1.png'));
  37. }).on('blur', function () {
  38. var src = $(this).prev().attr('src');
  39. $(this).prev().attr('src', src.replace(/1.png$/, '0.png'));
  40. });
  41. //点击密码icon 显示/隐藏
  42. $('#psw_change_op').click(function (event) {
  43. var event = event || window.event;
  44. event.stopPropagation();
  45. var $this = $(this);
  46. $this.toggleClass('psw_show');
  47. //如果当前隐藏 变显示
  48. if ($this.hasClass('psw_show')) {
  49. $this.css({
  50. 'background': 'url(' + $.rootUrl +'/Content/images/Login/psw1.png) no-repeat center center'
  51. });
  52. $this.prev().attr('type', 'text');
  53. } else {
  54. $this.css(
  55. 'background', 'url(/Content/images/Login/psw0.png) no-repeat center center'
  56. );
  57. $this.prev().attr('type', 'password');
  58. }
  59. });
  60. //点击密码icon 显示/隐藏
  61. $('#psw_change_np').click(function (event) {
  62. var event = event || window.event;
  63. event.stopPropagation();
  64. var $this = $(this);
  65. $this.toggleClass('psw_show');
  66. //如果当前隐藏 变显示
  67. if ($this.hasClass('psw_show')) {
  68. $this.css({
  69. 'background': 'url(' + $.rootUrl + '/Content/images/Login/psw1.png) no-repeat center center'
  70. });
  71. $this.prev().attr('type', 'text');
  72. } else {
  73. $this.css(
  74. 'background', 'url(/Content/images/Login/psw0.png) no-repeat center center'
  75. );
  76. $this.prev().attr('type', 'password');
  77. }
  78. });
  79. // 登录按钮事件
  80. $("#wms_login_edit").on('click', function () {
  81. wmsPage.login();
  82. });
  83. },
  84. login: function () {
  85. wmsPage.tip();
  86. var $textu = $("#wms_username"), $textop = $("#wms_op"), $textnp = $("#wms_np");
  87. var textu = $.trim($textu.val()), textop = $.trim($textop.val()), textnp = $.trim($textnp.val());
  88. if (textu == "") {
  89. wmsPage.tip('请输入账户');
  90. $textu.focus();
  91. return false;
  92. }
  93. if (textop == "") {
  94. wmsPage.tip('请输入旧密码');
  95. $textp.focus();
  96. return false;
  97. }
  98. if (textnp == "") {
  99. wmsPage.tip('请输入新密码');
  100. $textv.focus();
  101. return false;
  102. }
  103. if (textnp == textop) {
  104. wmsPage.tip('新密码与旧密码相同');
  105. $textnp.focus();
  106. return false;
  107. }
  108. wmsPage.logining(true);
  109. $.ajax({
  110. url: $.rootUrl + "/Login/LoginUserEditPwd",
  111. headers: { __RequestVerificationToken: $.wmsToken },
  112. data: { JsonData: JSON.stringify({ TextU: textu, TextOP: textop, TextNP: textnp }) },
  113. type: "post",
  114. dataType: "json",
  115. success: function (res) {
  116. if (res.IsSucc) {
  117. window.location.href = $.rootUrl + '/Login/Index';
  118. }
  119. else if (res.code == -1) {
  120. console.error(res.info);
  121. wmsPage.logining(false);
  122. wmsPage.tip('服务端异常,请联系管理员', true);
  123. }
  124. else {
  125. wmsPage.logining(false);
  126. wmsPage.tip(res.info, true);
  127. }
  128. }
  129. });
  130. $.ajax({
  131. url: $.rootUrl + "/Login/LoginUserEditPwd",
  132. headers: { __RequestVerificationToken: $.wmsToken },
  133. data: { JsonData: JSON.stringify({ TextU: textu, TextOP: textop, TextNP: textnp }) },
  134. type: "post",
  135. dataType: "json",
  136. success: function (res) {
  137. if (res.IsSucc) {
  138. window.location.href = $.rootUrl + '/Login/Index';
  139. }
  140. else if (res.code == -1) {
  141. console.error(res.info);
  142. wmsPage.logining(false);
  143. wmsPage.tip('服务端异常,请联系管理员', true);
  144. }
  145. else {
  146. wmsPage.logining(false);
  147. wmsPage.tip(res.info, true);
  148. }
  149. }
  150. });
  151. },
  152. logining: function (isShow) {
  153. if (isShow) {
  154. $('input').attr('disabled', 'disabled');
  155. $("#wms_login_edit").addClass('active').attr('disabled', 'disabled').find('span').hide();
  156. $("#wms_login_edit").css('background', '#eeecec url(/Content/images/Login/loading.gif) no-repeat center 10px');
  157. }
  158. else {
  159. $('input').removeAttr('disabled');
  160. $("#wms_login_edit").removeClass('active').removeAttr('disabled').find('span').show();
  161. $("#wms_login_edit").css('background', '#268fe2');
  162. }
  163. },
  164. tip: function (msg) {
  165. var $tip = $('.error_info');
  166. $tip.hide();
  167. if (!!msg) {
  168. $tip.find('span').html(msg);
  169. $tip.show();
  170. }
  171. }
  172. };
  173. $(function () {
  174. wmsPage.init();
  175. });
  176. })(window.jQuery)