124 lines
2.3 KiB
JavaScript
124 lines
2.3 KiB
JavaScript
![]() |
// subpackage/user/change-password/change-password.js
|
|||
|
import '../../../utils/serve/user'
|
|||
|
import { changePassword } from '../../../utils/serve/user'
|
|||
|
Page({
|
|||
|
|
|||
|
/**
|
|||
|
* 页面的初始数据
|
|||
|
*/
|
|||
|
data: {
|
|||
|
canSeeF:false,
|
|||
|
canSeeS:false,
|
|||
|
canSeeT:false,
|
|||
|
oldPwd:'',
|
|||
|
newPwd:'',
|
|||
|
confirmPwd:'',
|
|||
|
},
|
|||
|
|
|||
|
setCanSee(e){
|
|||
|
console.log(e)
|
|||
|
this.setData({
|
|||
|
[e.currentTarget.id]: !this.data[e.currentTarget.id]
|
|||
|
})
|
|||
|
},
|
|||
|
|
|||
|
inputChange(e){
|
|||
|
this.setData({
|
|||
|
[e.currentTarget.id]:e.detail.value
|
|||
|
})
|
|||
|
console.log(this.data.oldPwd)
|
|||
|
console.log(this.data.newPwd)
|
|||
|
console.log(this.data.confirmPwd)
|
|||
|
},
|
|||
|
|
|||
|
sure (){
|
|||
|
const regex = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,12}$/
|
|||
|
if(!regex.test(this.data.newPwd)||!regex.test(this.data.confirmPwd)) return wx.showToast({
|
|||
|
title: '密码长度为6-12字符,需包含字母和数字!',
|
|||
|
icon:'none'
|
|||
|
})
|
|||
|
|
|||
|
if(this.data.newPwd != this.data.confirmPwd)return wx.showToast({
|
|||
|
title: '输入的两次新密码不一致!',
|
|||
|
icon:'none'
|
|||
|
})
|
|||
|
|
|||
|
changePassword({
|
|||
|
oldPwd:this.data.oldPwd,
|
|||
|
newPwd:this.data.newPwd,
|
|||
|
confirmPwd:this.data.confirmPwd
|
|||
|
}).then(res =>{
|
|||
|
if(!res.success){
|
|||
|
wx.showToast({
|
|||
|
title: res.errorMsg,
|
|||
|
icon:'none'
|
|||
|
})
|
|||
|
}else{
|
|||
|
wx.showToast({
|
|||
|
title: '修改密码成功',
|
|||
|
icon:'none'
|
|||
|
})
|
|||
|
setTimeout(() => {
|
|||
|
wx.navigateBack()
|
|||
|
}, 500);
|
|||
|
}
|
|||
|
})
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面加载
|
|||
|
*/
|
|||
|
onLoad(options) {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面初次渲染完成
|
|||
|
*/
|
|||
|
onReady() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面显示
|
|||
|
*/
|
|||
|
onShow() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面隐藏
|
|||
|
*/
|
|||
|
onHide() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 生命周期函数--监听页面卸载
|
|||
|
*/
|
|||
|
onUnload() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面相关事件处理函数--监听用户下拉动作
|
|||
|
*/
|
|||
|
onPullDownRefresh() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 页面上拉触底事件的处理函数
|
|||
|
*/
|
|||
|
onReachBottom() {
|
|||
|
|
|||
|
},
|
|||
|
|
|||
|
/**
|
|||
|
* 用户点击右上角分享
|
|||
|
*/
|
|||
|
onShareAppMessage() {
|
|||
|
|
|||
|
}
|
|||
|
})
|