纸通宝SAAS仓库
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.
 

99 lines
2.9 KiB

// pages/home/password/index.js
// 页面已经废弃,因为UEC的修改,暂时不会提供修改密码的功能
import { postCaptcha } from "../../../api/user"
import { getCustomerInfo, bindCustomer } from "../../../api/saas"
const util = require('../../../utils/util')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
second: '获取验证码',
codeEnable: false,
pwdType: 'password',
pwd_icon: 'attention',
form: {
mobile: null,
captcha: null
},
loging: false,
customerInfo: null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(options.id){
wx.showLoading({ title: '正在获取', mask: true })
getCustomerInfo(options.id).then(result => {
wx.hideLoading()
this.setData({ customerInfo: result.data })
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
},
bindForm: function (e) {
this.data.form[e.target.id] = e.detail.value
},
changePwd: function (e) {
if (this.data.pwdType === 'password') {
this.setData({ pwdType: 'text', pwd_icon: 'attentionforbid' })
} else {
this.setData({ pwdType: 'password', pwd_icon: 'attention' })
}
},
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 })
postCaptcha({ verifiableAccount: this.data.form.mobile, verifiableAccountType: 1, purpose: 1 }).then(result => {
wx.hideLoading()
this.setData({ codeEnable: true })
util.showToast('验证码已经发送')
this.countDown = this.countDown || this.selectComponent('.count-down')
this.countDown.reset()
this.countDown.start()
}).catch(error => {
wx.hideLoading()
util.showToast(error)
})
},
onChange: function(e) {
this.setData({ second: e.detail.seconds + ' 秒 ' })
},
onFinished: function(){
this.setData({ second: '重新获取验证码', codeEnable: false })
},
submitForm: function () {
if (this.data.loging || !this.data.customerInfo) {
return
}
if (util.isEmpty(this.data.form.mobile)) {
util.showToast('请输入客户手机号码')
return
}
if (util.isEmpty(this.data.form.captcha)) {
util.showToast('请输入验证码')
return
}
wx.showLoading({ title: '处理中', mask: true })
this.setData({ loging: true })
this.data.form.factorycustomerId = this.customerInfo.id
this.data.form.factoryId = app.userInfo.factoryId
bindCustomer(this.data.form).then(result => {
util.showBackToast('客户注册成功')
}).catch(error => {
wx.hideLoading()
util.showToast(error)
this.setData({ loging: false })
})
}
})