You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
2.8 KiB
113 lines
2.8 KiB
// pages/bank/password/index.js
|
|
const request = require('../../../utils/request') //导入模块
|
|
const util = require('../../../utils/util')
|
|
const md5 = require('../../../utils/md5')
|
|
import { $wuxCountDown } from '../../../components/index'
|
|
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
second: null,
|
|
codeEnable: true,
|
|
form: {
|
|
mobile: null,
|
|
captcha: null,
|
|
payPassword: null
|
|
},
|
|
requesting: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
|
|
},
|
|
|
|
bindForm: function (e) {
|
|
this.data.form[e.target.id] = e.detail.value
|
|
},
|
|
fetchCode: function () {
|
|
if (util.isEmpty(this.data.form.mobile)) {
|
|
util.showToast('请输入手机号码')
|
|
return
|
|
}
|
|
if (this.second && this.second.interval) return !1
|
|
wx.showLoading({
|
|
title: '正在获取',
|
|
mask: true
|
|
})
|
|
// /login/h5/mobile/send_sms_code 发送验证码
|
|
request.post('/recycle-service/send/captcha', {
|
|
account: this.data.form.mobile,
|
|
accountType: 'MOBILE',
|
|
purpose: 'RECYCLE_CLIENT_UPDATE_PAY_PASSWORD'
|
|
}).then(result => {
|
|
wx.hideLoading()
|
|
this.setData({
|
|
codeEnable: false
|
|
})
|
|
util.showToast('验证码已经发送')
|
|
this.wuxCountDown = new $wuxCountDown({
|
|
date: +(new Date) + 60000,
|
|
onEnd() {
|
|
this.setData({
|
|
second: '重新获取验证码',
|
|
codeEnable: true
|
|
})
|
|
},
|
|
render(date) {
|
|
const sec = this.leadingZeros(date.sec, 2) + ' 秒 '
|
|
date.sec !== 0 && this.setData({
|
|
second: sec,
|
|
})
|
|
},
|
|
})
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
util.showToast(error)
|
|
})
|
|
},
|
|
submitForm: function () {
|
|
if (this.data.requesting) {
|
|
return
|
|
}
|
|
if (util.isEmpty(this.data.form.mobile)) {
|
|
util.showToast('请输入手机号码')
|
|
return
|
|
}
|
|
if (util.isEmpty(this.data.form.payPassword)) {
|
|
util.showToast('请输入密码')
|
|
return
|
|
}
|
|
// this.data.form.payPassword = md5.hexMD5(this.data.form.payPassword).toUpperCase()
|
|
if (util.isEmpty(this.data.form.captcha)) {
|
|
util.showToast('请输入验证码')
|
|
return
|
|
}
|
|
this.data.form.verifyCode = this.data.form.captcha
|
|
wx.showLoading({
|
|
title: '处理中',
|
|
mask: true
|
|
})
|
|
this.data.requesting = true
|
|
request.post('/saas-user/user/udpatePayPassword', this.data.form).then(res => {
|
|
wx.hideLoading()
|
|
util.showBackToast('设置成功')
|
|
}).catch(error => {
|
|
wx.hideLoading()
|
|
this.data.requesting = false
|
|
util.showToast(error)
|
|
})
|
|
},
|
|
onUnload: function(){
|
|
if(this.wuxCountDown){
|
|
this.wuxCountDown.stop()
|
|
this.wuxCountDown = null
|
|
}
|
|
}
|
|
|
|
})
|