9 changed files with 292 additions and 235 deletions
@ -1,191 +1,63 @@ |
|||||||
const app = getApp<IAppOption>() |
const app = getApp<IAppOption>() |
||||||
let timer = null as null | number |
|
||||||
|
|
||||||
Page({ |
Page({ |
||||||
data: { |
data: { |
||||||
menuTop: 0, |
menuTop: 0, |
||||||
mobile: '', |
checked: false, |
||||||
code: '', |
|
||||||
|
|
||||||
check1: false, |
|
||||||
check2: false, |
|
||||||
|
|
||||||
codeText: '发送验证码', |
|
||||||
page: '', |
|
||||||
|
|
||||||
toastShow: false, |
|
||||||
toastType: '', |
|
||||||
toastParams: {} as any, |
|
||||||
}, |
}, |
||||||
onLoad(options) { |
onLoad(_options) { |
||||||
const menuRes = wx.getMenuButtonBoundingClientRect() |
const menuRes = wx.getMenuButtonBoundingClientRect() |
||||||
this.setData({ |
this.setData({ |
||||||
menuTop: menuRes.top, |
menuTop: menuRes.top, |
||||||
}) |
}) |
||||||
|
app.waitLogin({ type: 'any' }).then(() => {}) |
||||||
if (timer) { |
|
||||||
clearInterval(timer) |
|
||||||
timer = null |
|
||||||
this.setData({ codeText: '发送验证码' }) |
|
||||||
} |
|
||||||
this.setData({ |
|
||||||
page: options.page, |
|
||||||
}) |
|
||||||
}, |
}, |
||||||
onUnload() { |
handleCheck() { |
||||||
if (timer) { |
|
||||||
clearInterval(timer) |
|
||||||
timer = null |
|
||||||
} |
|
||||||
}, |
|
||||||
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: '?r=igg4/login/send-verify-code', |
|
||||||
data: { |
|
||||||
mobile, |
|
||||||
}, |
|
||||||
}).then((_res) => { |
|
||||||
wx.showToast({ |
|
||||||
icon: 'none', |
|
||||||
title: '验证码已发送~', |
|
||||||
}) |
|
||||||
let time = 60 |
|
||||||
timer = setInterval(() => { |
|
||||||
time-- |
|
||||||
this.setData({ |
this.setData({ |
||||||
codeText: `${time}s后重新发送`, |
checked: !this.data.checked, |
||||||
}) |
|
||||||
if (time <= 0) { |
|
||||||
clearInterval(timer as number) |
|
||||||
timer = null |
|
||||||
this.setData({ |
|
||||||
codeText: '发送验证码', |
|
||||||
}) |
|
||||||
} |
|
||||||
}, 1000) |
|
||||||
}) |
|
||||||
}, |
|
||||||
handleSubmit() { |
|
||||||
const { mobile, code } = this.data |
|
||||||
const { registrationSource, registChannel, regBusinessId } = app.globalData |
|
||||||
wx.ajax({ |
|
||||||
method: 'POST', |
|
||||||
url: '?r=igg4/login/reg-login', |
|
||||||
data: { |
|
||||||
mobile, |
|
||||||
code, |
|
||||||
registrationSource, |
|
||||||
registChannel, |
|
||||||
regBusinessId, |
|
||||||
}, |
|
||||||
}).then((_res) => { |
|
||||||
this.submitCallback() |
|
||||||
}) |
}) |
||||||
}, |
}, |
||||||
handleWxSubmit(e: WechatMiniprogram.CustomEvent) { |
handleWxSubmit(e: WechatMiniprogram.CustomEvent) { |
||||||
const { iv, encryptedData } = e.detail |
const { iv, encryptedData } = e.detail |
||||||
const { registrationSource, registChannel, regBusinessId } = app.globalData |
|
||||||
if (iv && encryptedData) { |
if (iv && encryptedData) { |
||||||
|
const channelId = app.globalData.scene?.channelId || '' |
||||||
wx.ajax({ |
wx.ajax({ |
||||||
method: 'POST', |
method: 'POST', |
||||||
url: '?r=igg4/login/wx-reg-login', |
url: '?r=psvt/patient/phone-register', |
||||||
data: { |
data: { |
||||||
iv: encodeURIComponent(iv), |
iv: encodeURIComponent(iv), |
||||||
encryptedData: encodeURIComponent(encryptedData), |
encryptedData: encodeURIComponent(encryptedData), |
||||||
registrationSource, |
channelId, |
||||||
registChannel, |
|
||||||
regBusinessId, |
|
||||||
}, |
}, |
||||||
}).then((_res) => { |
}).then(() => { |
||||||
this.submitCallback() |
this.submitCallback() |
||||||
}) |
}) |
||||||
} |
} |
||||||
}, |
}, |
||||||
handleWxCheck() { |
handleWxCheck() { |
||||||
this.setData({ |
wx.showToast({ |
||||||
toastShow: true, |
title: '请先阅读并同意相关协议', |
||||||
toastType: 'popup11', |
icon: 'none', |
||||||
toastParams: { isDoctor: false }, |
|
||||||
}) |
}) |
||||||
}, |
}, |
||||||
submitCallback() { |
submitCallback() { |
||||||
app.globalData.loginType = 1 |
app.globalData.initLoginInfo.isReg = 1 |
||||||
app.globalData.isLogin = true |
wx.redirectTo({ |
||||||
app.getUserInfo(this, true, (userInfo) => { |
url: '/pages/confirmInfo/index', |
||||||
// 1-空白用户,2-注册用户,3-疾病患者,4-用药患者
|
|
||||||
const { PatientId, UserType } = userInfo |
|
||||||
const backPage = app.globalData.backPage |
|
||||||
let urlKey = '' |
|
||||||
if (UserType >= 3) { |
|
||||||
urlKey = 'home' |
|
||||||
} else if (!PatientId) { |
|
||||||
urlKey = 'enterInfo' |
|
||||||
} |
|
||||||
const navUrl = { |
|
||||||
home: backPage || '/pages/index/index', |
|
||||||
enterInfo: '/pages/enterInfo/index', |
|
||||||
}[urlKey] |
|
||||||
|
|
||||||
if (['enterInfo'].includes(urlKey)) { |
|
||||||
wx.navigateTo({ |
|
||||||
url: navUrl, |
|
||||||
}) |
|
||||||
} else { |
|
||||||
wx.reLaunch({ |
|
||||||
url: navUrl, |
|
||||||
}) |
|
||||||
} |
|
||||||
}) |
}) |
||||||
}, |
}, |
||||||
handleVisitors() { |
handleVisitors() { |
||||||
app.globalData.anyWhere = true |
app.globalData.anyWhere = true |
||||||
app.globalData.first = true |
|
||||||
app.globalData.loginType = 1 |
|
||||||
wx.reLaunch({ |
wx.reLaunch({ |
||||||
url: '/pages/index/index', |
url: '/pages/index/index', |
||||||
}) |
}) |
||||||
}, |
}, |
||||||
handleDoctor() { |
|
||||||
wx.reLaunch({ |
|
||||||
url: '/doctor/pages/d_login/index', |
|
||||||
}) |
|
||||||
}, |
|
||||||
handleLink(e: any) { |
handleLink(e: any) { |
||||||
const { url } = e.currentTarget.dataset |
const { url } = e.currentTarget.dataset |
||||||
wx.navigateTo({ |
wx.navigateTo({ |
||||||
url, |
url, |
||||||
}) |
}) |
||||||
}, |
}, |
||||||
handleCheck(e: any) { |
|
||||||
const { key } = e.currentTarget.dataset |
|
||||||
this.setData({ |
|
||||||
[key]: !this.data[key], |
|
||||||
}) |
|
||||||
}, |
|
||||||
handleToastCancel() { |
|
||||||
this.setData({ |
|
||||||
toastShow: false, |
|
||||||
toastType: '', |
|
||||||
}) |
|
||||||
}, |
|
||||||
}) |
}) |
||||||
|
|
||||||
export {} |
export {} |
||||||
|
|||||||
Loading…
Reference in new issue