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

106 lines
3.2 KiB

// pages/home/mobile/index.js
const util = require('../../../utils/util')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
mobileEnable: false,
codeEnable: true,
loginEnable: true,
second: '获取验证码',
form: {
accountType: 'MOBILE',
mobile: null,
captcha: null
},
mobile: null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ mobile: app.accountInfo.mobile })
},
bindInput: function (e) {
this.data.form[e.target.id] = e.detail.value
if ('mobile' == e.target.id) {
if ((/^1\d{10}$/.test(e.detail.value)) && e.detail.value.length == 11) {
this.setData({ mobileEnable: true })
}
}
if ((/^1\d{10}$/.test(this.data.form.mobile)) && this.data.form.mobile.length == 11) {
if (!util.isEmpty(this.data.form.captcha)) {
this.setData({ loginEnable: false })
} else {
this.setData({ loginEnable: true })
}
} else {
this.setData({ loginEnable: true })
}
},
fetchCode: function () {
if (!(/^1\d{10}$/.test(this.data.form.mobile)) || this.data.form.mobile.length < 11) {
utill.showToast('请输入11位手机号码')
return
}
if (this.data.form.mobile == this.data.mobile) {
util.showToast('新手机号码不能和当前号码一致!')
return
}
wx.showLoading({ title: '正在获取', mask: true })
var form = {account: this.data.form.mobile, accountType: 'MOBILE', purpose: 'RECYCLE_CLIENT_UPDATE_MOBILE' }
// /send/captcha 发送验证码
// request.post('/cloud-print-user-center/send/captcha', form).then(result => {
// wx.hideLoading()
// this.setData({ codeEnable: false })
// 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: true })
},
submitForm: function () {
if (this.data.requesting) {
return
}
if (!(/^1\d{10}$/.test(this.data.form.mobile)) || this.data.form.mobile.length < 11) {
utill.showToast('请输入11位手机号码')
return
}
if (this.data.form.mobile == this.data.mobile) {
util.showToast('新手机号码不能和当前号码一致!')
return
}
if (util.isEmpty(this.data.form.captcha)) {
util.showToast('请输入验证码')
return
}
wx.showLoading({ title: '处理中', mask: true })
var data = { mobile: this.data.form.mobile, captcha: this.data.form.captcha }
this.data.requesting = true
// /front/customer/mobile修改手机号码
// request.post('/cloud-print-user-center/user/modify/mobile', data).then(res => {
// wx.hideLoading()
// app.accountInfo.mobile = this.data.form.mobile
// util.showBackToast('修改成功')
// }).catch(error => {
// wx.hideLoading()
// this.data.requesting = false
// util.showToast(error)
// })
}
})