|
|
|
|
const app = getApp<IAppOption>()
|
|
|
|
|
let timer = null as null | number
|
|
|
|
|
|
|
|
|
|
Page({
|
|
|
|
|
data: {
|
|
|
|
|
mobile: '',
|
|
|
|
|
code: '',
|
|
|
|
|
codeText: '发送验证码',
|
|
|
|
|
back: false,
|
|
|
|
|
showForm: false,
|
|
|
|
|
check: false,
|
|
|
|
|
},
|
|
|
|
|
onLoad(option) {
|
|
|
|
|
if (option.back) {
|
|
|
|
|
this.setData({
|
|
|
|
|
back: true,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
getCode() {
|
|
|
|
|
if (timer) return
|
|
|
|
|
const mobile = this.data.mobile
|
|
|
|
|
if (!mobile) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '手机号不能为空',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
// 验证手机号
|
|
|
|
|
if (!/^1[3-9,]\d{9}$/.test(mobile)) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
title: '手机号格式不正确',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '/app/common/common/send-code',
|
|
|
|
|
data: {
|
|
|
|
|
phone: mobile,
|
|
|
|
|
type: 1,
|
|
|
|
|
},
|
|
|
|
|
}).then((_res) => {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '验证码已发送~',
|
|
|
|
|
})
|
|
|
|
|
let time = 60
|
|
|
|
|
timer = setInterval(() => {
|
|
|
|
|
time--
|
|
|
|
|
this.setData({
|
|
|
|
|
codeText: `${time}s后重新发送`,
|
|
|
|
|
})
|
|
|
|
|
if (time <= 0) {
|
|
|
|
|
clearInterval(timer as number)
|
|
|
|
|
timer = null
|
|
|
|
|
this.setData({
|
|
|
|
|
codeText: '发送验证码',
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}, 1000)
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleSubmit() {
|
|
|
|
|
if (!this.data.mobile) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '请输入手机号',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!this.data.code) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '请输入验证码',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if (!this.data.check) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '请同意用户协议',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '/app/promoter/promoter/sms-login',
|
|
|
|
|
data: {
|
|
|
|
|
phone: this.data.mobile,
|
|
|
|
|
code: this.data.code,
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
app.startLogin(() => {
|
|
|
|
|
this.submitCallback()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleWxSubmit(e: WechatMiniprogram.CustomEvent) {
|
|
|
|
|
if (!this.data.check) {
|
|
|
|
|
wx.showToast({
|
|
|
|
|
icon: 'none',
|
|
|
|
|
title: '请同意用户协议',
|
|
|
|
|
})
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
const { iv, encryptedData } = e.detail
|
|
|
|
|
if (iv && encryptedData) {
|
|
|
|
|
const sessionKey = app.globalData.initLoginInfo?.sessionKey || ''
|
|
|
|
|
|
|
|
|
|
wx.ajax({
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: '/app/promoter/promoter/wx-login',
|
|
|
|
|
data: {
|
|
|
|
|
sessionKey,
|
|
|
|
|
encryptedData,
|
|
|
|
|
iv,
|
|
|
|
|
},
|
|
|
|
|
}).then(() => {
|
|
|
|
|
app.startLogin(() => {
|
|
|
|
|
this.submitCallback()
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
submitCallback() {
|
|
|
|
|
wx.reLaunch({
|
|
|
|
|
url: '/ground/pages/home/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handlePatient() {
|
|
|
|
|
wx.restartMiniProgram({
|
|
|
|
|
path: '/pages/start/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleTelCode() {
|
|
|
|
|
this.setData({
|
|
|
|
|
showForm: !this.data.showForm,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleLink() {
|
|
|
|
|
wx.navigateTo({
|
|
|
|
|
url: '/privacy/pages/policy/index',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleCheck() {
|
|
|
|
|
this.setData({
|
|
|
|
|
check: !this.data.check,
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
handleBack() {
|
|
|
|
|
wx.navigateBack()
|
|
|
|
|
},
|
|
|
|
|
})
|