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.
 
 
 

65 lines
1.7 KiB

import { parseScene } from '@/utils/util'
const app = getApp<IAppOption>()
Page({
data: {},
onLoad(options) {
// 解析扫码参数
let pharmacistId = ''
let projectId = ''
if (options.scene) {
const sceneData = parseScene(options.scene) as { pharmacistId?: string; projectId?: string }
pharmacistId = sceneData.pharmacistId || ''
projectId = sceneData.projectId || ''
}
// 保存到全局数据
if (pharmacistId) {
app.globalData.pharmacistId = pharmacistId
}
if (projectId) {
app.globalData.projectId = projectId
}
app.waitLogin().then(() => {
const { isLogin, loginIdentity } = app.globalData.initLoginInfo
// 游客(1)或患者端(2)且有扫码参数,进入患者首页
if ((loginIdentity === 1 || loginIdentity === 2) && pharmacistId && projectId) {
wx.reLaunch({
url: '/pages/index/index',
})
return
}
// 游客(1)或患者端(2)无扫码参数,进入游客页面
if (loginIdentity === 1 || loginIdentity === 2) {
wx.reLaunch({
url: '/pages/tourists/index',
})
return
}
// 未注册,根据身份跳转到对应注册页面
if (!isLogin) {
wx.reLaunch({
url: '/pages/tourists/index',
})
return
}
// 已注册,根据身份跳转到对应首页
const homePageUrl = {
2: '/pages/index/index',
3: '/ground/pages/home/index',
4: '/doctor/pages/home/index',
}[loginIdentity as 2 | 3 | 4]
wx.reLaunch({
url: homePageUrl || '/pages/index/index',
})
})
},
})
export {}