信达小程序
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.

157 lines
3.4 KiB

const app = getApp<IAppOption>()
let timer = null as null | number
1 month ago
Page({
data: {
mobile: '',
code: '',
check1: false,
check2: false,
codeText: '发送验证码',
page: '',
},
onLoad(options: any) {
this.setData({
page: options.page,
})
app.waitLogin().then(() => {
app.zdMpBehavior({ PageName: 'PG_PATIENTLOGIN' })
})
1 month ago
},
getCode() {
if (timer) return
const mobile = this.data.mobile
1 month ago
if (!mobile) {
wx.showToast({
title: '手机号不能为空',
icon: 'none',
})
return
1 month ago
}
// 验证手机号
if (!/^1[3-9,]\d{9}$/.test(mobile)) {
wx.showToast({
title: '手机号格式不正确',
icon: 'none',
})
return
1 month ago
}
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/login/send-verify-code',
1 month ago
data: {
mobile,
},
}).then((_res) => {
wx.showToast({
icon: 'none',
title: '验证码已发送~',
})
let time = 60
1 month ago
timer = setInterval(() => {
time--
1 month ago
this.setData({
codeText: `${time}s后重新发送`,
})
1 month ago
if (time <= 0) {
clearInterval(timer as number)
timer = null
1 month ago
this.setData({
codeText: '发送验证码',
})
1 month ago
}
}, 1000)
})
1 month ago
},
handleSubmit() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTLOGIN' })
const { mobile, code } = this.data
const { registrationSource, registChannel, regBusinessId } = app.globalData
1 month ago
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/login/reg-login',
1 month ago
data: {
mobile,
code,
registrationSource,
registChannel,
regBusinessId,
},
}).then((_res) => {
this.submitCallback()
})
1 month ago
},
handleWxSubmit(e: WechatMiniprogram.CustomEvent) {
app.zdMpBehavior({ PageName: 'BTN_PATIENTQUICKPATIENTLOGIN' })
const { iv, encryptedData } = e.detail
const { registrationSource, registChannel, regBusinessId } = app.globalData
1 month ago
if (iv && encryptedData) {
wx.ajax({
method: 'POST',
4 weeks ago
url: '?r=zd/login/wx-reg-login',
1 month ago
data: {
iv: encodeURIComponent(iv),
encryptedData: encodeURIComponent(encryptedData),
registrationSource,
registChannel,
regBusinessId,
},
}).then((_res) => {
this.submitCallback()
})
1 month ago
}
},
handleWxCheck() {
wx.showToast({
icon: 'none',
title: '请先同意隐私政策',
})
1 month ago
},
submitCallback() {
app.globalData.loginType = 1
app.globalData.isLogin = 1
4 weeks ago
app.updateLoginInfo((res) => {
const { loginType, isNewReg, isLogin } = res
const backPage = app.globalData.backPage
let url = backPage || '/patient/pages/index/index'
4 weeks ago
if (isNewReg === 0) {
url = '/patient/pages/enterInfo/index'
1 month ago
wx.navigateTo({
4 weeks ago
url,
})
return
1 month ago
}
4 weeks ago
wx.reLaunch({
url,
})
})
1 month ago
},
handleVisitors() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTLOOKAROUND' })
1 month ago
wx.reLaunch({
4 weeks ago
url: '/patient/pages/index/index',
})
1 month ago
},
handleDoctor() {
wx.reLaunch({
4 weeks ago
url: '/pages/login/index',
})
1 month ago
},
handleLink(e: any) {
const { url } = e.currentTarget.dataset
1 month ago
wx.navigateTo({
url,
})
1 month ago
},
handleCheck(e: any) {
const { key } = e.currentTarget.dataset
1 month ago
this.setData({
[key]: !this.data[key],
})
1 month ago
},
})
1 month ago
export {}