| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- /*
- * 描 述:修改密码页面前端脚本
- */
- (function ($) {
- "use strict";
- var wmsPage = {
- init: function () {
- $('#psw_change_op').css({
- 'background': 'url(' + $.rootUrl + '/Content/images/Login/psw0.png) no-repeat center center'
- });
- $('#psw_change_np').css({
- 'background': 'url(' + $.rootUrl + '/Content/images/Login/psw0.png) no-repeat center center'
- });
- $("#wms_username").val(request('username'));
- if (window.location.href != top.window.location.href) {
- top.window.location.href = window.location.href;
- }
- var isIE = !!window.ActiveXObject;
- var isIE6 = isIE && !window.XMLHttpRequest;
- if (isIE6) {
- window.location.href = $.rootUrl + "/Error/ErrorBrowser";
- }
- wmsPage.bind();
- },
- bind: function () {
- // 回车键
- document.onkeydown = function (e) {
- e = e || window.event;
- if ((e.keyCode || e.which) == 13) {
- $('#wms_login_edit').trigger('click');
- }
- }
- //输入框获取焦点
- $('.wms-login-input input').on('focus', function () {
- var src = $(this).prev().attr('src');
- $(this).prev().attr('src', src.replace(/0.png$/, '1.png'));
- }).on('blur', function () {
- var src = $(this).prev().attr('src');
- $(this).prev().attr('src', src.replace(/1.png$/, '0.png'));
- });
- //点击密码icon 显示/隐藏
- $('#psw_change_op').click(function (event) {
- var event = event || window.event;
- event.stopPropagation();
- var $this = $(this);
- $this.toggleClass('psw_show');
- //如果当前隐藏 变显示
- if ($this.hasClass('psw_show')) {
- $this.css({
- 'background': 'url(' + $.rootUrl +'/Content/images/Login/psw1.png) no-repeat center center'
- });
- $this.prev().attr('type', 'text');
- } else {
- $this.css(
- 'background', 'url(/Content/images/Login/psw0.png) no-repeat center center'
- );
- $this.prev().attr('type', 'password');
- }
- });
- //点击密码icon 显示/隐藏
- $('#psw_change_np').click(function (event) {
- var event = event || window.event;
- event.stopPropagation();
- var $this = $(this);
- $this.toggleClass('psw_show');
- //如果当前隐藏 变显示
- if ($this.hasClass('psw_show')) {
- $this.css({
- 'background': 'url(' + $.rootUrl + '/Content/images/Login/psw1.png) no-repeat center center'
- });
- $this.prev().attr('type', 'text');
- } else {
- $this.css(
- 'background', 'url(/Content/images/Login/psw0.png) no-repeat center center'
- );
- $this.prev().attr('type', 'password');
- }
- });
- // 登录按钮事件
- $("#wms_login_edit").on('click', function () {
- wmsPage.login();
- });
- },
- login: function () {
- wmsPage.tip();
- var $textu = $("#wms_username"), $textop = $("#wms_op"), $textnp = $("#wms_np");
- var textu = $.trim($textu.val()), textop = $.trim($textop.val()), textnp = $.trim($textnp.val());
- if (textu == "") {
- wmsPage.tip('请输入账户');
- $textu.focus();
- return false;
- }
- if (textop == "") {
- wmsPage.tip('请输入旧密码');
- $textp.focus();
- return false;
- }
- if (textnp == "") {
- wmsPage.tip('请输入新密码');
- $textv.focus();
- return false;
- }
- if (textnp == textop) {
- wmsPage.tip('新密码与旧密码相同');
- $textnp.focus();
- return false;
- }
- wmsPage.logining(true);
- $.ajax({
- url: $.rootUrl + "/Login/LoginUserEditPwd",
- headers: { __RequestVerificationToken: $.wmsToken },
- data: { JsonData: JSON.stringify({ TextU: textu, TextOP: textop, TextNP: textnp }) },
- type: "post",
- dataType: "json",
- success: function (res) {
- if (res.IsSucc) {
- window.location.href = $.rootUrl + '/Login/Index';
- }
- else if (res.code == -1) {
- console.error(res.info);
- wmsPage.logining(false);
- wmsPage.tip('服务端异常,请联系管理员', true);
- }
- else {
- wmsPage.logining(false);
- wmsPage.tip(res.info, true);
- }
- }
- });
- $.ajax({
- url: $.rootUrl + "/Login/LoginUserEditPwd",
- headers: { __RequestVerificationToken: $.wmsToken },
- data: { JsonData: JSON.stringify({ TextU: textu, TextOP: textop, TextNP: textnp }) },
- type: "post",
- dataType: "json",
- success: function (res) {
- if (res.IsSucc) {
- window.location.href = $.rootUrl + '/Login/Index';
- }
- else if (res.code == -1) {
- console.error(res.info);
- wmsPage.logining(false);
- wmsPage.tip('服务端异常,请联系管理员', true);
- }
- else {
- wmsPage.logining(false);
- wmsPage.tip(res.info, true);
- }
- }
- });
- },
- logining: function (isShow) {
- if (isShow) {
- $('input').attr('disabled', 'disabled');
- $("#wms_login_edit").addClass('active').attr('disabled', 'disabled').find('span').hide();
- $("#wms_login_edit").css('background', '#eeecec url(/Content/images/Login/loading.gif) no-repeat center 10px');
- }
- else {
- $('input').removeAttr('disabled');
- $("#wms_login_edit").removeClass('active').removeAttr('disabled').find('span').show();
- $("#wms_login_edit").css('background', '#268fe2');
- }
- },
- tip: function (msg) {
- var $tip = $('.error_info');
- $tip.hide();
- if (!!msg) {
- $tip.find('span').html(msg);
- $tip.show();
- }
- }
- };
- $(function () {
- wmsPage.init();
- });
- })(window.jQuery)
|