import { parseScene } from '@/utils/util' const app = getApp() Page({ data: {}, onLoad(options) { // 解析扫码参数 let pharmacistId = '' let projectId = '' if (options.scene) { const sceneData = parseScene(options.scene) as { pharmacistId?: string; projectId?: string } console.log('sceneData: ', sceneData); 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) { const regPageUrl = { 2: '/pages/index/index', 3: '/ground/pages/login/index', 4: '/doctor/pages/login/index', }[loginIdentity as 2 | 3 | 4] wx.reLaunch({ url: regPageUrl || '/pages/index/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 {}