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.
94 lines
2.2 KiB
94 lines
2.2 KiB
import { parseScene } from '@/utils/util' |
|
const app = getApp<IAppOption>() |
|
|
|
Page({ |
|
data: {}, |
|
onLoad(options) { |
|
// 解析扫码参数 |
|
let t = '' |
|
let pharmacistId = '' // 药店人员ID |
|
let promoterId = '' // 地推人员ID |
|
let projectId = '' |
|
|
|
if (options.scene) { |
|
const sceneData = parseScene(options.scene) as { |
|
t: string |
|
pharmacistId?: string |
|
projectId?: string |
|
promoterId?: string |
|
} |
|
t = sceneData.t || '' // 1-地推人员码,2-药店人员码 |
|
pharmacistId = sceneData.pharmacistId || '' |
|
promoterId = sceneData.promoterId || '' |
|
projectId = sceneData.projectId || '' |
|
} |
|
|
|
// 保存到全局数据 |
|
if (pharmacistId) { |
|
app.globalData.pharmacistId = pharmacistId |
|
} |
|
if (promoterId) { |
|
app.globalData.promoterId = promoterId |
|
} |
|
if (projectId) { |
|
app.globalData.projectId = projectId |
|
} |
|
|
|
app.waitLogin().then(() => { |
|
const { isLogin, isRegister, loginIdentity } = app.globalData.initLoginInfo |
|
|
|
// 扫码进入用户处理 |
|
if (t == '1') { |
|
if (loginIdentity === 4 && isLogin && isRegister) { |
|
wx.reLaunch({ |
|
url: '/doctor/pages/home/index?bind=1', |
|
}) |
|
} else { |
|
wx.reLaunch({ |
|
url: '/doctor/pages/login/index', |
|
}) |
|
} |
|
return |
|
} |
|
if (t == '2') { |
|
wx.reLaunch({ |
|
url: '/pages/index/index', |
|
}) |
|
return |
|
} |
|
|
|
// 未注册,根据身份跳转到对应注册页面 |
|
if (!isLogin) { |
|
if (loginIdentity === 2) { |
|
wx.reLaunch({ |
|
url: '/pages/index/index', |
|
}) |
|
return |
|
} |
|
wx.reLaunch({ |
|
url: '/pages/tourists/index', |
|
}) |
|
return |
|
} |
|
|
|
if (loginIdentity === 4 && isRegister === 0) { |
|
wx.reLaunch({ |
|
url: '/doctor/pages/login/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 {}
|
|
|