|
@@ -17,17 +17,18 @@ Page({
|
|
|
phone: '',
|
|
phone: '',
|
|
|
format_phone: '',
|
|
format_phone: '',
|
|
|
code: '',
|
|
code: '',
|
|
|
- cansubmit: false
|
|
|
|
|
|
|
+ cansubmit: false,
|
|
|
|
|
+ captcha
|
|
|
},
|
|
},
|
|
|
show() {
|
|
show() {
|
|
|
- const captchaResult = getApp().captchaResult;
|
|
|
|
|
- getApp().captchaResult = null; // 验证码的票据为一次性票据,取完需要置空
|
|
|
|
|
- if (captchaResult && captchaResult.ret === 0) {
|
|
|
|
|
- // 将验证码的结果返回至服务端校验
|
|
|
|
|
- const ticket = captchaResult.ticket;
|
|
|
|
|
- const randstr = captchaResult.randstr;
|
|
|
|
|
- this.send({ randstr, ticket })
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // const captchaResult = getApp().captchaResult;
|
|
|
|
|
+ // getApp().captchaResult = null; // 验证码的票据为一次性票据,取完需要置空
|
|
|
|
|
+ // if (captchaResult && captchaResult.ret === 0) {
|
|
|
|
|
+ // // 将验证码的结果返回至服务端校验
|
|
|
|
|
+ // const ticket = captchaResult.ticket;
|
|
|
|
|
+ // const randstr = captchaResult.randstr;
|
|
|
|
|
+ // this.send({ randstr, ticket })
|
|
|
|
|
+ // }
|
|
|
},
|
|
},
|
|
|
submit() {
|
|
submit() {
|
|
|
if (this.data.cansubmit) {
|
|
if (this.data.cansubmit) {
|
|
@@ -98,13 +99,14 @@ Page({
|
|
|
new_phone: this.data.phone,
|
|
new_phone: this.data.phone,
|
|
|
type: 'check_phone',
|
|
type: 'check_phone',
|
|
|
}).then(data => {
|
|
}).then(data => {
|
|
|
- wx.navigateToMiniProgram({
|
|
|
|
|
- appId: 'wx5a3a7366fd07e119',
|
|
|
|
|
- path: '/pages/captcha/index',
|
|
|
|
|
- extraData: {
|
|
|
|
|
- appId: captcha//您申请的验证码的 appId
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ // wx.navigateToMiniProgram({
|
|
|
|
|
+ // appId: 'wx5a3a7366fd07e119',
|
|
|
|
|
+ // path: '/pages/captcha/index',
|
|
|
|
|
+ // extraData: {
|
|
|
|
|
+ // appId: captcha//您申请的验证码的 appId
|
|
|
|
|
+ // }
|
|
|
|
|
+ // })
|
|
|
|
|
+ this.selectComponent('#captcha').show()
|
|
|
})
|
|
})
|
|
|
} else {
|
|
} else {
|
|
|
wx.showToast({
|
|
wx.showToast({
|
|
@@ -120,26 +122,18 @@ Page({
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
- send() {
|
|
|
|
|
- const captchaResult = getApp().captchaResult;
|
|
|
|
|
- getApp().captchaResult = null; // 验证码的票据为一次性票据,取完需要置空
|
|
|
|
|
- if (captchaResult && captchaResult.ret === 0) {
|
|
|
|
|
- // 将验证码的结果返回至服务端校验
|
|
|
|
|
- const ticket = captchaResult.ticket;
|
|
|
|
|
- const randstr = captchaResult.randstr;
|
|
|
|
|
- // this.send({ randstr, ticket })
|
|
|
|
|
- sendPhoneCode({
|
|
|
|
|
- phone: this.data.phone,
|
|
|
|
|
- ticket,
|
|
|
|
|
- randstr
|
|
|
|
|
- }).then(data => {
|
|
|
|
|
- wx.showToast({
|
|
|
|
|
- icon: 'none',
|
|
|
|
|
- title: '验证码发送成功',
|
|
|
|
|
- })
|
|
|
|
|
- })
|
|
|
|
|
- this.countdown()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ send({ randstr, ticket }) {
|
|
|
|
|
+ sendPhoneCode({
|
|
|
|
|
+ phone: this.data.phone,
|
|
|
|
|
+ ticket,
|
|
|
|
|
+ randstr
|
|
|
|
|
+ }).then(data => {
|
|
|
|
|
+ wx.showToast({
|
|
|
|
|
+ icon: 'none',
|
|
|
|
|
+ title: '验证码发送成功',
|
|
|
|
|
+ })
|
|
|
|
|
+ })
|
|
|
|
|
+ this.countdown()
|
|
|
},
|
|
},
|
|
|
countdown() {
|
|
countdown() {
|
|
|
time--;
|
|
time--;
|
|
@@ -178,7 +172,45 @@ Page({
|
|
|
})
|
|
})
|
|
|
return false
|
|
return false
|
|
|
}
|
|
}
|
|
|
- },
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ // 验证码验证结果回调
|
|
|
|
|
+ handlerVerify: function (ev) {
|
|
|
|
|
+ // 如果使用了 mpvue,ev.detail 需要换成 ev.mp.detail
|
|
|
|
|
+ if (ev.detail.ret === 0) {
|
|
|
|
|
+ // 验证成功
|
|
|
|
|
+ console.log('randstr:', ev.detail.ticket)
|
|
|
|
|
+ console.log('ticket:', ev.detail.ticket)
|
|
|
|
|
+ this.send({
|
|
|
|
|
+ ticket: ev.detail.ticket,
|
|
|
|
|
+ randstr: ev.detail.randstr
|
|
|
|
|
+ })
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 验证失败
|
|
|
|
|
+ // 请不要在验证失败中调用refresh,验证码内部会进行相应处理
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 验证码准备就绪
|
|
|
|
|
+ handlerReady: function () {
|
|
|
|
|
+ console.log('验证码准备就绪')
|
|
|
|
|
+ },
|
|
|
|
|
+ // 验证码弹框准备关闭
|
|
|
|
|
+ handlerClose: function (ev) {
|
|
|
|
|
+ // 如果使用了 mpvue,ev.detail 需要换成 ev.mp.detail,ret为0是验证完成后自动关闭验证码弹窗,ret为2是用户主动点击了关闭按钮关闭验证码弹窗
|
|
|
|
|
+ if (ev && ev.detail.ret && ev.detail.ret === 2) {
|
|
|
|
|
+ console.log('点击了关闭按钮,验证码弹框准备关闭');
|
|
|
|
|
+ } else {
|
|
|
|
|
+ console.log('验证完成,验证码弹框准备关闭');
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 验证码出错
|
|
|
|
|
+ handlerError: function (ev) {
|
|
|
|
|
+ console.log(ev.detail.errMsg)
|
|
|
|
|
+ wx.showModal({
|
|
|
|
|
+ title: '提示',
|
|
|
|
|
+ content: ev.detail.errMsg,
|
|
|
|
|
+ showCancel: false
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
/**
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
*/
|
|
@@ -203,8 +235,6 @@ Page({
|
|
|
const _data = res.data
|
|
const _data = res.data
|
|
|
this.setData({
|
|
this.setData({
|
|
|
phoneNow: _data.substring(0, 3) + ' **** ' + _data.substring(7, 11)
|
|
phoneNow: _data.substring(0, 3) + ' **** ' + _data.substring(7, 11)
|
|
|
- }, () => {
|
|
|
|
|
- this.send()
|
|
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|