Browse Source

api stash

master
kola-web 1 week ago
parent
commit
84a17b414a
  1. 115
      src/pages/index/index.ts
  2. 1
      src/pages/start/index.ts

115
src/pages/index/index.ts

@ -92,9 +92,16 @@ Page({
}, },
getProjectInfo() { getProjectInfo() {
const params: any = {}
// 如果有 projectId,传入获取指定项目信息
if (this.data.projectId) {
params.projectId = this.data.projectId
}
wx.ajax({ wx.ajax({
method: 'GET', method: 'GET',
url: '/app/patient/patient/project-info', url: '/app/patient/patient/project-info',
data: params,
}).then((res: any) => { }).then((res: any) => {
this.setData({ this.setData({
projectId: res.projectId, projectId: res.projectId,
@ -151,76 +158,66 @@ Page({
const { iv, encryptedData } = e.detail const { iv, encryptedData } = e.detail
if (iv && encryptedData) { if (iv && encryptedData) {
wx.login({ const app = getApp<IAppOption>()
success: (loginRes) => { const sessionKey = app.globalData.initLoginInfo?.sessionKey || ''
wx.ajax({
// 解密手机号
wx.ajax({
method: 'POST',
url: '/app/patient/patient/wx-login',
data: {
sessionKey,
encryptedData,
iv,
},
})
.then(() => {
// 选择适应症
return wx.ajax({
method: 'POST', method: 'POST',
url: '/app/common/common/wx-login', url: '/app/patient/patient/select-indication',
data: { data: {
code: loginRes.code, projectId: this.data.projectId,
indicationId: selectedOption.indicationId,
}, },
}) })
.then((loginRes: any) => { })
// 解密手机号 .then((res: any) => {
return wx.ajax({ const jumpUrl = res.jumpUrl
method: 'POST',
url: '/app/common/common/wx-phone', // 如果有药师ID,创建绑定关系
data: { if (this.data.pharmacistId) {
sessionKey: loginRes.sessionKey, wx.ajax({
encryptedData, method: 'POST',
iv, url: '/app/patient/patient/bind-pharmacist',
}, data: {
}) pharmacistId: Number.parseInt(this.data.pharmacistId),
}) projectId: this.data.projectId,
.then(() => { indicationId: selectedOption.indicationId,
// 选择适应症 },
return wx.ajax({
method: 'POST',
url: '/app/patient/patient/select-indication',
data: {
projectId: this.data.projectId,
indicationId: selectedOption.indicationId,
},
})
}) })
.then((res: any) => { .then(() => {
const jumpUrl = res.jumpUrl // 绑定成功后跳转
wx.navigateToMiniProgram({
// 如果有药师ID,创建绑定关系 appId: 'wx05551c5ee1fd1c12',
if (this.data.pharmacistId) { path: jumpUrl,
wx.ajax({
method: 'POST',
url: '/app/patient/patient/bind-pharmacist',
data: {
pharmacistId: this.data.pharmacistId,
projectId: this.data.projectId,
indicationId: selectedOption.indicationId,
},
}) })
.then(() => { })
// 绑定成功后跳转 .catch(() => {
wx.navigateToMiniProgram({ // 绑定失败也跳转
appId: 'wx05551c5ee1fd1c12',
path: jumpUrl,
})
})
.catch(() => {
// 绑定失败也跳转
wx.navigateToMiniProgram({
appId: 'wx05551c5ee1fd1c12',
path: jumpUrl,
})
})
} else {
// 没有药师ID,直接跳转
wx.navigateToMiniProgram({ wx.navigateToMiniProgram({
appId: 'wx05551c5ee1fd1c12', appId: 'wx05551c5ee1fd1c12',
path: jumpUrl, path: jumpUrl,
}) })
} })
} else {
// 没有药师ID,直接跳转
wx.navigateToMiniProgram({
appId: 'wx05551c5ee1fd1c12',
path: jumpUrl,
}) })
}, }
}) })
} }
}, },

1
src/pages/start/index.ts

@ -10,6 +10,7 @@ Page({
if (options.scene) { if (options.scene) {
const sceneData = parseScene(options.scene) as { pharmacistId?: string; projectId?: string } const sceneData = parseScene(options.scene) as { pharmacistId?: string; projectId?: string }
console.log('sceneData: ', sceneData);
pharmacistId = sceneData.pharmacistId || '' pharmacistId = sceneData.pharmacistId || ''
projectId = sceneData.projectId || '' projectId = sceneData.projectId || ''
} }

Loading…
Cancel
Save