195 lines
3.2 KiB
JavaScript
195 lines
3.2 KiB
JavaScript
// pages/password/password.js
|
|
const app = getApp();
|
|
import { getCode, resetPassword } from "../../utils/withdraw"
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
show: false,
|
|
show1: false,
|
|
disabled: true,
|
|
codeName: '获取验证码',
|
|
codeDisabled: false, //获取验证码按钮禁用
|
|
code: '',
|
|
password: '',
|
|
confirmPassword: '',
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad(options) {
|
|
|
|
},
|
|
|
|
|
|
// 密码显示隐藏
|
|
changeType() {
|
|
this.setData({
|
|
show: !(this.data.show)
|
|
})
|
|
},
|
|
// 确认密码显示隐藏
|
|
changeType1() {
|
|
this.setData({
|
|
show1: !(this.data.show1)
|
|
})
|
|
},
|
|
|
|
|
|
// 提交修改密码
|
|
bindConfirm() {
|
|
let { code, password, confirmPassword } = this.data
|
|
if (!code) {
|
|
wx.showToast({
|
|
title: '请输入验证码',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
if (password !== confirmPassword) {
|
|
wx.showToast({
|
|
title: '两次密码输入不一致',
|
|
icon: 'none'
|
|
})
|
|
} else {
|
|
let phone = wx.getStorageSync("cooperation").phone
|
|
let id = wx.getStorageSync("cooperation").id
|
|
let data = {
|
|
phone, id, code, password, confirmPassword
|
|
}
|
|
wx.showLoading()
|
|
resetPassword(data).then(res => {
|
|
wx.hideLoading()
|
|
let cooperation = wx.getStorageSync('cooperation')
|
|
cooperation.password = '****'
|
|
wx.setStorageSync('cooperation', cooperation)
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon: 'none',
|
|
success: () => {
|
|
setTimeout(() => {
|
|
wx.navigateBack()
|
|
}, 1000)
|
|
}
|
|
})
|
|
}).catch(err => {
|
|
wx.showModal({
|
|
title: "提示",
|
|
content: err.msg,
|
|
showCancel:false
|
|
});
|
|
wx.hideLoading()
|
|
})
|
|
}
|
|
}
|
|
},
|
|
|
|
|
|
changeInput(e) {
|
|
const keys = e.target.id;
|
|
this.setData({
|
|
[keys]: e.detail.value
|
|
})
|
|
let { code, password, confirmPassword } = this.data
|
|
if (code && password && confirmPassword) {
|
|
this.setData({
|
|
disabled: false
|
|
})
|
|
} else {
|
|
this.setData({
|
|
disabled: true
|
|
})
|
|
}
|
|
},
|
|
|
|
getPhoneCode() {
|
|
if(!this.data.codeDisabled){
|
|
getCode().then(res => {
|
|
if (res.code == 0) {
|
|
wx.showToast({
|
|
title: '发送成功',
|
|
})
|
|
this.setData({
|
|
codeDisabled: true
|
|
})
|
|
let num = 60;
|
|
let timer = setInterval(() => {
|
|
num--;
|
|
if (num <= 0) {
|
|
clearInterval(timer);
|
|
this.setData({
|
|
codeName: '获取验证码',
|
|
codeDisabled: false
|
|
})
|
|
} else {
|
|
this.setData({
|
|
codeName: num
|
|
})
|
|
}
|
|
}, 1000)
|
|
} else {
|
|
wx.showToast({
|
|
title: '发送失败',
|
|
})
|
|
this.setData({
|
|
codeDisabled: false
|
|
})
|
|
}
|
|
})
|
|
}
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage() {
|
|
|
|
}
|
|
}) |