|
@@ -15,11 +15,19 @@ let passwordComplexity = getCookie('passwordComplexity')
|
|
|
const modalDom = `
|
|
|
<p class="tips"><img src=${WarningIcon} /><span>为确保账号安全,请及时修改初始密码</span></p>
|
|
|
<div class="modalAction">
|
|
|
- <p><span>原密码:</span><input type="text" placeholder="请输入原密码" class="oldword" id="oldWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="oldWaring warning"><img src=${warnIcon} /><b>请及时修改初始密码</b></p></p>
|
|
|
- <p><span>新密码:</span><input type="text" disabled placeholder="请输入新密码" class="newword" id="newWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="newword warning"><img src=${warnIcon} /><b>请及时修改初始密码</b></p></p>
|
|
|
- <p><span>确认新密码:</span><input type="text" disabled placeholder="请输入确认新密码" class="sureword" id="sureWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="sureword warning"><img src=${warnIcon} /><b>请及时修改初始密码</b></p></p>
|
|
|
+ <p><span>原密码:</span><input type="password" placeholder="请输入原密码" class="oldword" id="oldWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="oldWaring warning"><img src=${warnIcon} /><b>原密码错误</b></p></p>
|
|
|
+ <p><span>新密码:</span><input type="password" disabled placeholder="请输入新密码" class="newword" id="newWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="newword warning"><img src=${warnIcon} /><b>密码最多12位</b></p></p>
|
|
|
+ <p><span>确认新密码:</span><input type="password" disabled placeholder="请输入确认新密码" class="sureword" id="sureWord" autocomplete="off"><img class="eye" src=${closeEye} /><p class="sureword warning"><img src=${warnIcon} /><b>两次密码输入不一致</b></p></p>
|
|
|
</div>
|
|
|
`;
|
|
|
+const psdChecker = `<div class="psd-checkbox">
|
|
|
+ <p class="label">密码至少包含:</p>
|
|
|
+ <p class="big-letter"><i></i>1个大写字母</p>
|
|
|
+ <p class="small-letter"><i></i>1个小写字母</p>
|
|
|
+ <p class="special-letter"><i></i>1个特色字符</p>
|
|
|
+ <p class="one-number"><i></i>1个数字</p>
|
|
|
+ <p class="eight-str"><i></i>8位字符</p>
|
|
|
+ </div>`;
|
|
|
$(function () {
|
|
|
getOwnDept();
|
|
|
setInterval(() => {
|
|
@@ -36,27 +44,7 @@ $(function () {
|
|
|
time: '1000',
|
|
|
sureText: '保存',
|
|
|
message: modalDom});
|
|
|
- let oldword = $(".oldword").val().trim()
|
|
|
- let newword = $(".newword").val().trim()
|
|
|
- let sureword = $(".sureword").val().trim()
|
|
|
- if (!oldword && !newword && !sureword) {
|
|
|
- $(".sureChange").css({ "border": "#E4E3E3", "background": "#E4E3E3" })
|
|
|
- }
|
|
|
- $(".oldword").blur(function () {
|
|
|
- if ($(".oldword").val() && $(".newword").val() && $(".sureword").val()) {
|
|
|
- $(".sureChange").css({ "border": "#00A1FF", "background": "#00A1FF" })
|
|
|
- }
|
|
|
- });
|
|
|
- $(".newword").blur(function () {
|
|
|
- if ($(".oldword").val() && $(".newword").val() && $(".sureword").val()) {
|
|
|
- $(".sureChange").css({ "border": "#00A1FF", "background": "#00A1FF" })
|
|
|
- }
|
|
|
- });
|
|
|
- $(".sureword").blur(function () {
|
|
|
- if ($(".oldword").val() && $(".newword").val() && $(".sureword").val()) {
|
|
|
- $(".sureChange").css({ "border": "#00A1FF", "background": "#00A1FF" })
|
|
|
- }
|
|
|
- });
|
|
|
+ bindModalEvent();
|
|
|
}
|
|
|
$(".main").css({
|
|
|
height: $(window).height() - 52 + 'px'
|
|
@@ -66,9 +54,6 @@ $(function () {
|
|
|
height: $(window).height() - 52 + 'px'
|
|
|
})
|
|
|
})
|
|
|
- $("body").on('focus', ".modalAction input", function () {
|
|
|
- $(this).attr("type", "password")
|
|
|
- })
|
|
|
$(window).click(function (e) {
|
|
|
$(".userAction").css("display", "none")
|
|
|
})
|
|
@@ -106,16 +91,111 @@ $(function () {
|
|
|
})
|
|
|
});
|
|
|
//切换密码明文
|
|
|
-function switchPwd(el,flag) {
|
|
|
- if(flag){
|
|
|
- el.parent()
|
|
|
- el.attr("type",'text');
|
|
|
+function switchPwd(el) {
|
|
|
+ if(!el.is(".open")){
|
|
|
+ el.attr("src",openEye).addClass("open");
|
|
|
+ el.prev().attr("type",'text');
|
|
|
}else{
|
|
|
- el.attr("type",'password');
|
|
|
+ el.attr("src",closeEye).removeClass("open");
|
|
|
+ el.prev().attr("type",'password');
|
|
|
}
|
|
|
}
|
|
|
//绑定输入框事件
|
|
|
+function bindModalEvent(){
|
|
|
+ $(".modalAction .eye").off("click").on("click",function(){
|
|
|
+ switchPwd($(this))
|
|
|
+ })
|
|
|
+ $("#oldWord").off("input").on("input",function(){
|
|
|
+ const text = $(this).val();
|
|
|
+ if(text.trim()){
|
|
|
+ $("#newWord").attr("disabled",false);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $("#newWord").off("input").on("input",function(){
|
|
|
+ const text = $(this).val();
|
|
|
+ if(text.trim()){ //显示密码验证标签
|
|
|
+ const checker = $(".alertModal .psd-checkbox");
|
|
|
+ if(checker.length){
|
|
|
+ checker.show()
|
|
|
+ }else{
|
|
|
+ $(psdChecker).appendTo($(".alertModal"));
|
|
|
+ }
|
|
|
+ const psdOk = verifyPsd(text);
|
|
|
+ let psdsOk=false;
|
|
|
+ if(psdOk){
|
|
|
+ $("#sureWord").attr("disabled",false);
|
|
|
+ psdsOk = verifyPsdPart($("#oldWord").val(),$("#newWord").val(),$("#sureWord").val());
|
|
|
+ }
|
|
|
+ if(psdsOk){
|
|
|
+ //保存按钮启用
|
|
|
+ $(".sureChange .sureChange").addClass("active");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ $("#sureWord").off("blur").on("blur",function(){
|
|
|
+ const text = $(this).val();
|
|
|
+ if(text.trim()){ //显示密码验证标签
|
|
|
+ let psdsOk=verifyPsdPart($("#oldWord").val(),$("#newWord").val(),$("#sureWord").val());
|
|
|
+ if(psdsOk){
|
|
|
+ //保存按钮启用
|
|
|
+ $(".alertModal .sureChange").addClass("active");
|
|
|
+ }else{
|
|
|
+ $(".alertModal .sureChange").removeClass("active");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
|
|
|
+//验证新密码规则
|
|
|
+function verifyPsd(text){
|
|
|
+ if(/(?=.*?[A-Z])/.test(text)){ //至少一个大写字母
|
|
|
+ $(".big-letter").addClass("active");
|
|
|
+ }else{
|
|
|
+ $(".big-letter").removeClass("active");
|
|
|
+ }
|
|
|
+ if(/(?=.*?[a-z])/.test(text)){ //至少一个大写字母
|
|
|
+ $(".small-letter").addClass("active");
|
|
|
+ }else{
|
|
|
+ $(".small-letter").removeClass("active");
|
|
|
+ }
|
|
|
+ if(/(?=.*?[0-9])/.test(text)){ //至少一个数字
|
|
|
+ $(".one-number").addClass("active");
|
|
|
+ }else{
|
|
|
+ $(".one-number").removeClass("active");
|
|
|
+ }
|
|
|
+ if(/(?=.*?[#?!@$,,%^&*-])/.test(text)){ //至少一个特殊字符
|
|
|
+ $(".special-letter").addClass("active");
|
|
|
+ }else{
|
|
|
+ $(".special-letter").removeClass("active");
|
|
|
+ }
|
|
|
+ if(text.length>7){ //至少8个字符
|
|
|
+ $(".eight-str").addClass("active");
|
|
|
+ }else{
|
|
|
+ $(".eight-str").removeClass("active");
|
|
|
+ }
|
|
|
+ if(text.length>12){
|
|
|
+ $(".newword.warning").text("密码最多12位").show();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ const regex = new RegExp('^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[$@~·$、,,\.!#%*?&])[A-Za-z\\d$@#$\.~、,,·!%*?&]{8,12}');
|
|
|
+ if(regex.test(text)){
|
|
|
+ return true
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+}
|
|
|
+
|
|
|
+function verifyPsdPart(oldP,newP,confirmP){ //验证各密码关系规则
|
|
|
+ if(oldP.trim()===newP.trim()){
|
|
|
+ $(".newword.warning").text("原密码和新密码不能相同").show();
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ if(confirmP.trim()&&newP.trim()!==confirmP.trim()){
|
|
|
+ $(".sureword.warning").text("两次密码输入不一致").show();
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ $(".warning").hide();
|
|
|
+ return true;
|
|
|
+}
|
|
|
|
|
|
//判断有无某一权限
|
|
|
function hasData(data, list) {
|
|
@@ -287,22 +367,17 @@ function getAllCode(data) {
|
|
|
setCookie("trdObj", JSON.stringify(trdObj))
|
|
|
}
|
|
|
function sureChangeWord() {
|
|
|
- $(document).on('click', '.sureChange', function () {
|
|
|
+ $(document).on('click', '.sureChange.active', function () {
|
|
|
let oldword = $(".oldword").val().trim()
|
|
|
let newword = $(".newword").val().trim()
|
|
|
- let sureword = $(".sureword").val().trim()
|
|
|
- if (newword != sureword) {
|
|
|
- $(".modalAction .waring i").html('两次密码不一致')
|
|
|
- return
|
|
|
- }
|
|
|
$(".modalAction .waring i").html('')
|
|
|
changeWord(oldword, newword)
|
|
|
})
|
|
|
}
|
|
|
function changeWord(oldword, newword) {
|
|
|
post(api.midifyPassword, {
|
|
|
- "modifyPassword": md5(newword),
|
|
|
- "password": md5(oldword)
|
|
|
+ "modifyPassword": newword,
|
|
|
+ "password": oldword
|
|
|
}).then(function (res) {
|
|
|
const data = res.data;
|
|
|
if (data.code === '0') {
|
|
@@ -310,7 +385,7 @@ function changeWord(oldword, newword) {
|
|
|
setCookie('behosDateEnd', '')
|
|
|
window.location.href = './login.html'
|
|
|
} else {
|
|
|
- $(".oldWaring").html(data.msg)
|
|
|
+ $(".oldWaring").html(data.msg).show();
|
|
|
return
|
|
|
}
|
|
|
});
|