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

176 lines
3.8 KiB

const app = getApp<IAppOption>()
let timer = null as null | number
6 months ago
Page({
data: {
popupShow: false,
popupType: 'popup10', // 隐私协议二级确认弹窗
popupParams: {
close: true,
} as any,
6 months ago
mobile: '',
code: '',
check1: false,
check2: false,
codeText: '发送验证码',
page: '',
},
onLoad(options: any) {
this.setData({
page: options.page,
})
app.waitLogin().then(() => {
6 months ago
app.mpBehavior({ PageName: 'PG_PatientLogin' })
})
6 months ago
},
getCode() {
if (timer)
return
const mobile = this.data.mobile
6 months ago
if (!mobile) {
wx.showToast({
title: '手机号不能为空',
icon: 'none',
})
return
6 months ago
}
// 验证手机号
if (!/^1[3-9,]\d{9}$/.test(mobile)) {
wx.showToast({
title: '手机号格式不正确',
icon: 'none',
})
return
6 months ago
}
wx.ajax({
method: 'POST',
6 months ago
url: '?r=zd/login/send-verify-code',
6 months ago
data: {
mobile,
},
}).then((_res) => {
wx.showToast({
icon: 'none',
title: '验证码已发送~',
})
let time = 60
6 months ago
timer = setInterval(() => {
time--
6 months ago
this.setData({
codeText: `${time}s后重新发送`,
})
6 months ago
if (time <= 0) {
clearInterval(timer as number)
timer = null
6 months ago
this.setData({
codeText: '发送验证码',
})
6 months ago
}
}, 1000)
})
6 months ago
},
handleSubmit() {
const { mobile, code } = this.data
const { registrationSource, registChannel, regBusinessId } = app.globalData
6 months ago
wx.ajax({
method: 'POST',
6 months ago
url: '?r=zd/login/reg-login',
6 months ago
data: {
mobile,
code,
registrationSource,
registChannel,
regBusinessId,
},
}).then((_res) => {
this.submitCallback()
})
6 months ago
},
handleWxSubmit(e: WechatMiniprogram.CustomEvent) {
console.log("DEBUGPRINT[171]: index.ts:92: e=", e)
6 months ago
app.mpBehavior({ PageName: 'BTN_PatientQuickLogin' })
const { iv, encryptedData } = e.detail
const { registrationSource, registChannel, regBusinessId } = app.globalData
this.handlePopupCancel()
6 months ago
if (iv && encryptedData) {
wx.ajax({
method: 'POST',
6 months ago
url: '?r=zd/login/wx-reg-login',
6 months ago
data: {
iv: encodeURIComponent(iv),
encryptedData: encodeURIComponent(encryptedData),
registrationSource,
registChannel,
regBusinessId,
},
}).then((_res) => {
this.submitCallback()
})
6 months ago
}
},
handleWxCheck() {
6 months ago
app.mpBehavior({ PageName: 'BTN_PatientQuickLogin' })
this.setData({
popupShow: true,
popupType: 'popup10',
popupParams: {
close: false,
},
})
6 months ago
},
submitCallback() {
app.globalData.loginType = 1
app.globalData.isLogin = 1
6 months ago
app.updateLoginInfo((res) => {
const { isNewReg } = res
const backPage = app.globalData.backPage
let url = backPage || '/patient/pages/index/index'
6 months ago
if (isNewReg === 0) {
url = '/patient/pages/enterInfo/index'
6 months ago
wx.navigateTo({
6 months ago
url,
})
return
6 months ago
}
6 months ago
wx.reLaunch({
url,
})
})
6 months ago
},
handleVisitors() {
6 months ago
app.mpBehavior({ PageName: 'BTN_PatientLookAround' })
6 months ago
wx.reLaunch({
6 months ago
url: '/patient/pages/index/index',
})
6 months ago
},
handleDoctor() {
6 months ago
wx.redirectTo({
6 months ago
url: '/pages/login/index',
})
6 months ago
},
handleLink(e: any) {
const { url } = e.currentTarget.dataset
6 months ago
wx.navigateTo({
url,
})
6 months ago
},
handleCheck(e: any) {
6 months ago
app.mpBehavior({ PageName: 'BTN_PatientPrivacyAgree' })
const { key } = e.currentTarget.dataset
6 months ago
this.setData({
[key]: !this.data[key],
})
6 months ago
},
handlePopupOk() {},
handlePopupCancel() {
this.setData({
popupShow: false,
})
},
})
6 months ago
export {}