diff --git a/src/pages/index/index.ts b/src/pages/index/index.ts index 4d3f63c..b41e302 100644 --- a/src/pages/index/index.ts +++ b/src/pages/index/index.ts @@ -92,9 +92,16 @@ Page({ }, getProjectInfo() { + const params: any = {} + // 如果有 projectId,传入获取指定项目信息 + if (this.data.projectId) { + params.projectId = this.data.projectId + } + wx.ajax({ method: 'GET', url: '/app/patient/patient/project-info', + data: params, }).then((res: any) => { this.setData({ projectId: res.projectId, @@ -151,76 +158,66 @@ Page({ const { iv, encryptedData } = e.detail if (iv && encryptedData) { - wx.login({ - success: (loginRes) => { - wx.ajax({ + const app = getApp() + const sessionKey = app.globalData.initLoginInfo?.sessionKey || '' + + // 解密手机号 + wx.ajax({ + method: 'POST', + url: '/app/patient/patient/wx-login', + data: { + sessionKey, + encryptedData, + iv, + }, + }) + .then(() => { + // 选择适应症 + return wx.ajax({ method: 'POST', - url: '/app/common/common/wx-login', + url: '/app/patient/patient/select-indication', data: { - code: loginRes.code, + projectId: this.data.projectId, + indicationId: selectedOption.indicationId, }, }) - .then((loginRes: any) => { - // 解密手机号 - return wx.ajax({ - method: 'POST', - url: '/app/common/common/wx-phone', - data: { - sessionKey: loginRes.sessionKey, - encryptedData, - iv, - }, - }) - }) - .then(() => { - // 选择适应症 - return wx.ajax({ - method: 'POST', - url: '/app/patient/patient/select-indication', - data: { - projectId: this.data.projectId, - indicationId: selectedOption.indicationId, - }, - }) + }) + .then((res: any) => { + const jumpUrl = res.jumpUrl + + // 如果有药师ID,创建绑定关系 + if (this.data.pharmacistId) { + wx.ajax({ + method: 'POST', + url: '/app/patient/patient/bind-pharmacist', + data: { + pharmacistId: Number.parseInt(this.data.pharmacistId), + projectId: this.data.projectId, + indicationId: selectedOption.indicationId, + }, }) - .then((res: any) => { - const jumpUrl = res.jumpUrl - - // 如果有药师ID,创建绑定关系 - if (this.data.pharmacistId) { - wx.ajax({ - method: 'POST', - url: '/app/patient/patient/bind-pharmacist', - data: { - pharmacistId: this.data.pharmacistId, - projectId: this.data.projectId, - indicationId: selectedOption.indicationId, - }, + .then(() => { + // 绑定成功后跳转 + wx.navigateToMiniProgram({ + appId: 'wx05551c5ee1fd1c12', + path: jumpUrl, }) - .then(() => { - // 绑定成功后跳转 - wx.navigateToMiniProgram({ - appId: 'wx05551c5ee1fd1c12', - path: jumpUrl, - }) - }) - .catch(() => { - // 绑定失败也跳转 - wx.navigateToMiniProgram({ - appId: 'wx05551c5ee1fd1c12', - path: jumpUrl, - }) - }) - } else { - // 没有药师ID,直接跳转 + }) + .catch(() => { + // 绑定失败也跳转 wx.navigateToMiniProgram({ appId: 'wx05551c5ee1fd1c12', path: jumpUrl, }) - } + }) + } else { + // 没有药师ID,直接跳转 + wx.navigateToMiniProgram({ + appId: 'wx05551c5ee1fd1c12', + path: jumpUrl, }) - }, - }) + } + }) } }, diff --git a/src/pages/start/index.ts b/src/pages/start/index.ts index 977da05..3e7a646 100644 --- a/src/pages/start/index.ts +++ b/src/pages/start/index.ts @@ -10,6 +10,7 @@ Page({ if (options.scene) { const sceneData = parseScene(options.scene) as { pharmacistId?: string; projectId?: string } + console.log('sceneData: ', sceneData); pharmacistId = sceneData.pharmacistId || '' projectId = sceneData.projectId || '' }