debug
This commit is contained in:
@@ -0,0 +1,147 @@
|
||||
import { layerPopup } from '../public/commonFun.js';
|
||||
import { resetPasswordByKey, setPasswd } from '../public/api/index.js';
|
||||
import { fetchApi,onError} from '../public/api/fetch.js';
|
||||
import { getLoginStatus }from '../public/localstorage.js';
|
||||
// 登录状态
|
||||
if (getLoginStatus()) {
|
||||
//getUserInfo()
|
||||
}else{
|
||||
location.href="/login.html"
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示和隐藏密码
|
||||
*/
|
||||
export const showHidePwd = function () {
|
||||
const inputElements = ['user_old_password', 'user_password', 'user_password2'];
|
||||
const visibleElements = ['user_old_password_visible_img', 'user_password_visible_img', 'user_password2_visible_img'];
|
||||
const isVisibleData = [false, false, false];
|
||||
$('.j-closeEye').on('click', function () {
|
||||
let index = $(this).data('index')
|
||||
isVisibleData[index] = !isVisibleData[index];
|
||||
if (isVisibleData[index]) {
|
||||
$(`#${inputElements[index]}`).attr('type', 'text');
|
||||
$(`#${visibleElements[index]}`).removeClass('icon-closeEye');
|
||||
$(`#${visibleElements[index]}`).addClass('icon-eye1');
|
||||
|
||||
} else {
|
||||
$(`#${inputElements[index]}`).attr('type', 'password');
|
||||
$(`#${visibleElements[index]}`).addClass('icon-closeEye');
|
||||
$(`#${visibleElements[index]}`).removeClass('icon-eye1');
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证密码格式
|
||||
* @returns obj
|
||||
*/
|
||||
export const verifyPwd = function () {
|
||||
|
||||
var strOldPassword = $("#user_old_password").val().replace(/\s*/g, "");
|
||||
var strNewsPassword = $("#user_password").val().replace(/\s*/g, "");
|
||||
var strConfirmPassword = $("#user_password2").val().replace(/\s*/g, "");
|
||||
|
||||
if (strOldPassword.length < 6) {
|
||||
layerPopup('当前密码必须由6-20位的数字或者字母组成', 3)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strNewsPassword.length < 6) {
|
||||
layerPopup('新密码必须由6-20位的数字或者字母组成', 3)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strConfirmPassword.length < 6) {
|
||||
layerPopup('确认密码必须由6-20位的数字或者字母组成', 3)
|
||||
return false;
|
||||
} else {
|
||||
if (strConfirmPassword !== strNewsPassword) {
|
||||
layerPopup('两次密码不匹配,请确认后重新输入', 3)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return { 'strOldPassword': strOldPassword, 'strNewsPassword': strNewsPassword }
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码-登录
|
||||
*/
|
||||
export const SetPasswdFun = function (strOldPassword, strEwsPassword, strSetPwdKey,Callback) {
|
||||
let postData = {
|
||||
'mu_old_password':strOldPassword,
|
||||
'mu_new_password':strEwsPassword,
|
||||
'key':strSetPwdKey,
|
||||
}
|
||||
fetchApi(resetPasswordByKey, postData,successFun, onError)
|
||||
function successFun(res){
|
||||
CallbackFun(res,Callback)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码-个人中心3
|
||||
*/
|
||||
export const setPasswdFun2 = function (strOldPassword, strEwsPassword,Callback=null) {
|
||||
let postData = {
|
||||
'oldpassword':strOldPassword,
|
||||
'password':strEwsPassword,
|
||||
}
|
||||
fetchApi(setPasswd, postData,successFun, onError)
|
||||
function successFun(res){
|
||||
CallbackFun(res,Callback)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理回调
|
||||
* @param {*} res
|
||||
* @param {*} Callback
|
||||
*/
|
||||
const CallbackFun = function(res,Callback) {
|
||||
|
||||
if(Callback) Callback(res)
|
||||
|
||||
if (res.code == '000') {
|
||||
$("#user_old_password").val('')
|
||||
$("#user_password").val('')
|
||||
$("#user_password2").val('');
|
||||
$('.msg-dialog2').show();
|
||||
$('.tip-hy').text('修改成功')
|
||||
} else if (res.code == '2001') {
|
||||
$('.msg-dialog').show();
|
||||
$('.tip-hy').text(res.msg)
|
||||
} else {
|
||||
$('.msg-dialog').show();
|
||||
$('.tip-hy').text(res.msg)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 邮箱找回密码-登录页入口
|
||||
*/
|
||||
export const resetPwdByEmail = function () {
|
||||
|
||||
$('.j-reset-pwd-btn').on('click', function () {
|
||||
layerPopup('重置密码已经发送到你的邮箱,请按邮件里的密码重新登录!',5)
|
||||
setTimeout(()=>{
|
||||
location.href="/member/login.html"
|
||||
},5000)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 验证邮箱-个人中心页入口
|
||||
*/
|
||||
export const verifyEmail = function () {
|
||||
|
||||
$('.j-verify-email-btn').on('click', function () {
|
||||
layerPopup('重置密码已经发送到你的邮箱,请按邮件里的密码重新登录!',5)
|
||||
setTimeout(()=>{
|
||||
location.href="/member/login.html"
|
||||
},5000)
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user