| | |
| | | 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 (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( |
| | | '/sib/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( |
| | | '/sib/xcx/login/logout', |
| | | 'POST', |
| | | res => { |
| | | my.removeStorageSync({ |
| | | key: 'sessionId', |
| | | }); |
| | | my.navigateTo({ |
| | | url: '/pages/index/index' |
| | | }); |
| | | }, |
| | | err => { |
| | | |
| | | }, |
| | | true |
| | | ) |
| | | }) |
| | | |
| | | } |
| | | }); |