From e293974e1be9d2b6894cbf2fa5841a8bd21163de Mon Sep 17 00:00:00 2001
From: liangjin <liangjin@finlean.com>
Date: Tue, 11 May 2021 15:40:40 +0800
Subject: [PATCH] 支付宝重构
---
pages/changePassword/changePassword.js | 111 +++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 82 insertions(+), 29 deletions(-)
diff --git a/pages/changePassword/changePassword.js b/pages/changePassword/changePassword.js
index dfd94ab..ffc5f98 100644
--- a/pages/changePassword/changePassword.js
+++ b/pages/changePassword/changePassword.js
@@ -1,58 +1,111 @@
let $api = require('../../utils/ajaxFn.js')
let md5 = require('../../utils/md5.js')
+let validator = require('../../utils/validator.js')
const app = getApp()
Page({
data: {
- userStyle:{},
- newTwo:"",
- info:{
- newPwd: "",
- oldPwd: ""
- }
+ userStyle: {},
+ newTwo: "",
+ info: {
+ newPwd: "",
+ oldPwd: ""
+ },
+ userInfo: {}
},
onLoad() {
this.setData({
- userStyle:app.userStyle
+ userStyle: app.userStyle,
+ userInfo: app.userInfo
})
},
- getOld(e){
+ getOld(e) {
this.setData({
- 'info.oldPwd':md5.hex_md5(e.detail.value)
+ 'info.oldPwd': e.detail.value
})
},
- getNem(e){
+ getNem(e) {
this.setData({
- 'info.newPwd':md5.hex_md5(e.detail.value)
+ 'info.newPwd': e.detail.value
})
},
- getNemTwo(e){
- console.log(3)
+ getNemTwo(e) {
this.setData({
- newTwo: md5.hex_md5(e.detail.value)
+ newTwo: e.detail.value
})
},
- save(){
- console.log(this.data.newTwo,this.data.info)
- if(this.data.newTwo != this.data.info.newPwd){
+ save() {
+ let self = this
+ console.log(this.data.userInfo.mblNo, this.data.newTwo, this.data.info)
+ if (validator.checkValEmpty(this.data.info.oldPwd)) {
+ my.showToast({
+ content: '请输入原密码',
+ duration: 2000,
+ });
+ return
+ }
+ if (validator.checkValEmpty(this.data.info.newPwd)) {
+ my.showToast({
+ content: '请输入新密码',
+ duration: 2000,
+ });
+ return
+ }
+ if (!validator.checkPassword(this.data.info.newPwd)) {
+ my.showToast({
+ content: '新密码格式有误,应为8-16位字母数字组合',
+ duration: 2000,
+ });
+ return
+ }
+ if (this.data.newTwo != this.data.info.newPwd) {
my.showToast({
content: '两次新密码不一致,请确认',
duration: 2000,
});
return
}
- $api.ajax(
- '/sib/user/updatePwd',
- 'POST',
- (res)=>{
+ let p = new Promise(function (re, rej) {
+ $api.ajax(
+ '/zic/user/updatePwd',
+ 'POST',
+ (res) => {
+ my.showToast({
+ content:'修改成功',
+ duration:3000,
+ success:()=>{
+ re()
+ }
+ })
+ },
+ (err) => {
- },
- (err)=>{
+ },
+ true,
+ {
+ newPwd: md5.hex_md5(self.data.userInfo.mblNo + self.data.info.newPwd),
+ oldPwd: md5.hex_md5(self.data.userInfo.mblNo + self.data.info.oldPwd)
+ }
+ )
- },
- true,
- {
- ...this.data.info
- }
- )
+ })
+ p.then(() => {
+ $api.ajax(
+ '/zic/login/logout',
+ 'POST',
+ res => {
+ my.removeStorageSync({
+ key: 'sessionId',
+ });
+ my.navigateTo({
+ url: '/pages/index/index'
+ });
+ },
+ err => {
+
+ },
+ true
+ )
+ })
+
}
});
--
Gitblit v1.8.0