You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
229 lines
7.8 KiB
229 lines
7.8 KiB
|
|
define(function (require, exports, module) {
|
|
var Window = require('system/views/pages/window');
|
|
var tpl = require('text!./change.tpl');
|
|
var md5 = CryptoJS.MD5;
|
|
var isShowkeyBoard = null;
|
|
|
|
function PwdWindow(options) {
|
|
var self = this;
|
|
isShowkeyBoard = Store.Cache.get('showkeyboard');
|
|
self.options = {
|
|
title:'',
|
|
content: '',
|
|
width: 1024,
|
|
height: 700,
|
|
modal: false,
|
|
closed: false,
|
|
maximizable: false,
|
|
closable: false,
|
|
draggable: false,
|
|
collapsible:false,
|
|
data: null,
|
|
shadow:false
|
|
};
|
|
|
|
_.extend(self.options, options);
|
|
|
|
getOpValue(self);
|
|
|
|
_init(self);
|
|
|
|
Window.call(self, self.options);
|
|
|
|
}
|
|
|
|
inherits(PwdWindow, Window);
|
|
|
|
function _init(obj) {
|
|
var self = obj;
|
|
if (!self.options.initMsg) {
|
|
self.options.content = Store.compile(tpl, Store.MSG);
|
|
return;
|
|
}
|
|
|
|
var lang = Store.logOn.langId;
|
|
var _frs = 'locale/'+ lang +'/frs';
|
|
var _msg = 'locale/'+ lang +'/common';
|
|
var _msgproject = 'locale/'+ lang +'/' + Store.project;
|
|
|
|
require([_frs, _msg, _msgproject], function(msg1, msg2, msg3) {
|
|
Store.MSG = _.extend(Store.MSG, msg1, msg2, msg3);
|
|
self.options.content = Store.compile(tpl, Store.MSG);
|
|
Window.call(self, self.options);
|
|
if (self.options.initCb && typeof self.options.initCb === 'function') {
|
|
self.options.initCb(self.enablePwdAndCycle);
|
|
}
|
|
});
|
|
};
|
|
|
|
function getOpValue(obj) {
|
|
obj.enablePwdAndCycle = Store.bizDao.getOptionValueSync('FRS_IsEnablePwdAndCycle', Store.logOn.orgCode, '1');
|
|
if ('1' === obj.enablePwdAndCycle) {
|
|
obj.pwdComplex = Store.bizDao.getOptionValueSync('FRS_SetPasswordComplex', Store.logOn.orgCode, '3');
|
|
obj.pwdCycle = Store.bizDao.getOptionValueSync('FRS_SetPasswordCycle', Store.logOn.orgCode, '30');
|
|
}
|
|
}
|
|
|
|
PwdWindow.prototype.open = function () {
|
|
Window.prototype.open.call(this);
|
|
};
|
|
|
|
PwdWindow.prototype.init = function () {
|
|
|
|
};
|
|
|
|
function checkPwdComplex(pwd, pwdComplex) {
|
|
var data = {
|
|
success: true,
|
|
msg: ''
|
|
};
|
|
var reglevel1 = /^[0-9]{6,12}$/;
|
|
var reglevel2 = /^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,12}$/;
|
|
var reglevel3 = /^(?![a-zA-z]+$)(?!\d+$)(?![_\W]+$)(?![a-zA-Z\d]+$)(?![a-zA-Z_\W]+$)(?![\d_\W]+$)[a-zA-Z\d_\W]{6,12}$/;
|
|
switch (pwdComplex.toString()) {
|
|
case '1': // 6-12位数字
|
|
data.success = reglevel1.test(pwd) || reglevel2.test(pwd) || reglevel3.test(pwd);
|
|
data.msg = data.success ? '' : Store.MSG.NUM_PASSWORD_CHECK;
|
|
break;
|
|
case '2': //6-12位数字字母组合
|
|
data.success = reglevel2.test(pwd) || reglevel3.test(pwd);
|
|
data.msg = data.success ? '' : Store.MSG.NUM_ALPHABET_PASSWORD_CHECK;
|
|
break;
|
|
case '3': //6-12位数字-字母-特殊符号组合
|
|
data.success = reglevel3.test(pwd);
|
|
data.msg = data.success ? '' : Store.MSG.NUM_ALPHA_OTHER_PASSWORD_CHECK;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return data;
|
|
}
|
|
|
|
PwdWindow.prototype.checkPwdComplex = function(pwd) {
|
|
var result = {
|
|
success: true,
|
|
msg: ''
|
|
};
|
|
if (this.enablePwdAndCycle === '1') {
|
|
result = checkPwdComplex(pwd, this.pwdComplex);
|
|
}
|
|
return result;
|
|
}
|
|
|
|
PwdWindow.prototype.checkPwdCycle = function () {
|
|
var data = {success: true, msg: ''};
|
|
// if (this.pwdCycle !== '0' || !this.pwdCycle) return data;
|
|
// 从服务器获取剩余时间数目
|
|
var params = {
|
|
sync: true
|
|
};
|
|
var result = Store.services.checkPwdRecyle(params);
|
|
if (!result) return data;
|
|
var leftDay = result.leftDay;
|
|
return {
|
|
success: (leftDay > 0) ? true : false,
|
|
msg: (leftDay > 5) ? '' : (leftDay > 0 ? Store.MSG['PASSWORD_LEFT'] + leftDay + Store.MSG['PASSWORD_LEFT_SUFFIX'] : Store.MSG['PASSWORD_OUT_OF_DATE'])
|
|
}
|
|
}
|
|
|
|
var clickx=0;
|
|
PwdWindow.prototype.customerize = function ($container) {
|
|
var self = this;
|
|
//重新计算窗体大小
|
|
$container.window('resize',{width:$(window).width(),height:$(window).height(),top:0,left:0});
|
|
$container.parent().addClass('edp-pwd-change-bg').css('z-index',6666).addClass('edp-pwd-change-border').end().addClass('edp-pwd-change-border');
|
|
|
|
this.$changeBtn = this.getElement('button.edp-pwd-change-confirm');
|
|
this.$oldPwd = this.getElement('.edp-pwd-change-oldpwd');
|
|
this.$newPwd = this.getElement('.edp-pwd-change-newpwd');
|
|
this.$cfmPwd = this.getElement('.edp-pwd-change-cfmpwd');
|
|
this.$tip = this.getElement('.edp-pwd-change-tip');
|
|
this.$changeSuccess = this.getElement('.edp-pwd-change-success');
|
|
this.$input= this.getElement('.edp-pwd-change-input');
|
|
|
|
this.$close = $container.find('.edp-pwd-change-close');
|
|
this.$close.click(function (e) {
|
|
self.close();
|
|
});
|
|
if(clickx==0){
|
|
this.$input.on('focus',function (e) {
|
|
if(isShowkeyBoard == 1) {
|
|
Store.VK.openVK(e.target,1);
|
|
}
|
|
});
|
|
this.$input.on('blur',function (e) {
|
|
if(isShowkeyBoard == 1) {
|
|
Store.VK.closeVK(e.target);
|
|
}
|
|
});
|
|
clickx=1;
|
|
}
|
|
|
|
function showInfo(result) {
|
|
if (!result.success) {
|
|
self.$tip.text(result.msg);
|
|
} else {
|
|
self.$tip.text('');
|
|
}
|
|
}
|
|
|
|
this.$newPwd.on('blur', function(e) {
|
|
var result = self.checkPwdComplex($(this).val());
|
|
showInfo(result);
|
|
});
|
|
this.$cfmPwd.on('blur', function(e) {
|
|
var result = self.checkPwdComplex($(this).val());
|
|
showInfo(result);
|
|
});
|
|
|
|
this.$changeBtn.off('click').on('click', function (e) {
|
|
var oldPwd = $.trim(self.$oldPwd.val());
|
|
var newPwd = $.trim(self.$newPwd.val());
|
|
var cfmPwd = $.trim(self.$cfmPwd.val());
|
|
var userId = Store.logOn.userId;
|
|
var userCode = Store.logOn.userCode;
|
|
|
|
if(oldPwd === '' ||newPwd === '' || cfmPwd === '') {
|
|
self.$tip.text(Store.MSG.FRS007_12);
|
|
return;
|
|
}
|
|
|
|
if(newPwd.length <6 ||newPwd.length>12|| cfmPwd.length < 6||cfmPwd.length > 12) {
|
|
self.$tip.text(Store.MSG.FRS007_07);
|
|
return;
|
|
}
|
|
|
|
if (newPwd !== cfmPwd) {
|
|
self.$tip.text(Store.MSG.FRS007_02); //两次输入的新密码不一致,请重新输入。
|
|
return;
|
|
}
|
|
|
|
var result = self.checkPwdComplex(cfmPwd);
|
|
if (!result.success) {
|
|
self.$tip.text(result.msg);
|
|
return;
|
|
}
|
|
|
|
Store.bizDao.executeplugin('userCommPlugin', {
|
|
isClear: '0',
|
|
userId: userId,
|
|
userCode: userCode,
|
|
oldPassword: md5(userCode.toLowerCase() +oldPwd).toString(),
|
|
newPassword: md5(userCode.toLowerCase() +newPwd).toString()
|
|
}, function (isOk, ret) {
|
|
if (!isOk) throw '访问服务器失败';
|
|
if (self.options.doneCb && typeof self.options.doneCb === 'function') {
|
|
self.options.doneCb({
|
|
success: true,
|
|
msg: '修改成功!'
|
|
})
|
|
}
|
|
self.close();
|
|
})
|
|
|
|
});
|
|
};
|
|
|
|
return PwdWindow;
|
|
}); |