Browse Source

患者端迁移bug处理

dev
kola-web 4 weeks ago
parent
commit
069b32a473
  1. 20
      src/app.ts
  2. 9
      src/pages/start/index.ts
  3. 66
      src/patient/pages/adl/index.ts
  4. 120
      src/patient/pages/adlResult/index.ts
  5. 136
      src/patient/pages/adlTest/index.ts
  6. 4
      src/patient/pages/start/index.json
  7. 4
      src/patient/pages/start/index.scss
  8. 33
      src/patient/pages/start/index.ts
  9. 1
      src/patient/pages/start/index.wxml
  10. 2
      typings/index.d.ts

20
src/app.ts

@ -140,7 +140,7 @@ App<IAppOption>({ @@ -140,7 +140,7 @@ App<IAppOption>({
return new Promise((resolve) => {
const checkLogin = () => {
if (this.globalData.loginState) {
if (this.checkLoginType(type)) {
if (this.checkLoginType(type as pageType[] | 'any')) {
resolve();
}
return;
@ -239,23 +239,7 @@ App<IAppOption>({ @@ -239,23 +239,7 @@ App<IAppOption>({
},
zdGetTheme() {
return new Promise((resolve) => {
const checkUserType = () => {
const zdUserInfo = this.globalData.zdUserInfo;
if (zdUserInfo.UserType) {
// resolve(zdUserInfo.UserType >= 4 ? 'DRUG' : 'PATIENT')
resolve('PATIENT');
return true;
}
return false;
};
const tryResolve = () => {
if (!checkUserType()) {
setTimeout(tryResolve, 30);
}
};
tryResolve();
resolve('PATIENT');
});
},
zdWaitLogin({ isReg = true, loginPage = false, pub = false } = { isReg: true, loginPage: false, pub: false }) {

9
src/pages/start/index.ts

@ -30,10 +30,15 @@ Page({ @@ -30,10 +30,15 @@ Page({
return;
}
if (loginType === 2) {
if (isNewReg === 1) {
wx.reLaunch({
url: '/pages/home/index',
});
return;
}
wx.reLaunch({
url: '/pages/index/index',
url: '/pages/login/index',
});
return;
}
});
},

66
src/patient/pages/adl/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp<IAppOption>()
const app = getApp<IAppOption>();
Page({
data: {
@ -18,38 +18,38 @@ Page({ @@ -18,38 +18,38 @@ Page({
},
videoContext: null as WechatMiniprogram.VideoContext | null,
async onLoad(options) {
await this.handleScene(options)
await this.handleScene(options);
this.videoContext = wx.createVideoContext('video')
this.videoContext = wx.createVideoContext('video');
this.setData({
m_d: options.m_d,
nrdl: options.nrdl,
})
app.zdWaitLogin({ isReg: false }).then(() => {
app.zdMpBehavior({ PageName: 'PG_PATIENTASSESSMENTSTART' })
app.getZdUserInfo(this, true)
this.getAdlScore()
});
app.waitLogin({ type: [0, 1] }).then(() => {
app.zdMpBehavior({ PageName: 'PG_PATIENTASSESSMENTSTART' });
app.getZdUserInfo(this, true);
this.getAdlScore();
if (options.adlPushId) {
wx.ajax({
method: 'POST',
url: '?r=zd/push-click/adl-push-click',
data: { adlPushId: options.adlPushId },
})
});
}
if (options.es === '201502') {
app.globalData.IsAliQiWei = 1
app.zdMpBehavior({ PageName: 'JUMP_INSURANCE_ADL_PAGE' })
app.globalData.IsAliQiWei = 1;
app.zdMpBehavior({ PageName: 'JUMP_INSURANCE_ADL_PAGE' });
}
})
});
},
// 拦截通过小程序码进入的场景
handleScene(options: any) {
return new Promise((resolve) => {
console.log(options)
const { scene, ...reset } = wx.getLaunchOptionsSync()
console.log(scene)
console.log(reset)
console.log(options);
const { scene, ...reset } = wx.getLaunchOptionsSync();
console.log(scene);
console.log(reset);
if (
[1047, 1048, 1049, 1089].includes(scene) &&
options.scene?.includes('doctorId') &&
@ -58,12 +58,12 @@ Page({ @@ -58,12 +58,12 @@ Page({
app.zdPermissionVerification(3, 15, `/patient/pages/index/index`).then(() => {
wx.reLaunch({
url: '/patient/pages/index/index',
})
})
});
});
} else {
resolve(true)
resolve(true);
}
})
});
},
getAdlScore() {
wx.ajax({
@ -73,38 +73,38 @@ Page({ @@ -73,38 +73,38 @@ Page({
}).then((res) => {
this.setData({
rewardScore: res.rewardScore,
})
})
});
});
},
handlePlay() {
this.videoContext?.play()
this.videoContext?.requestFullScreen({})
this.videoContext?.play();
this.videoContext?.requestFullScreen({});
},
handleFullScreen(e) {
if (!e.detail.fullScreen) {
this.videoContext?.pause()
this.videoContext?.seek(0)
this.videoContext?.pause();
this.videoContext?.seek(0);
}
},
handleShare() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTSTARTSHARE' })
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTSTARTSHARE' });
wx.navigateTo({
url: '/patient/pages/adlShare/index',
})
});
},
handleTest() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTSTART' })
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTSTART' });
wx.navigateTo({
url: `/patient/pages/adlTest/index?m_d=${this.data.m_d}&nrdl=${this.data.nrdl}`,
})
});
},
handleBack() {
wx.navigateBack()
wx.navigateBack();
},
onShareAppMessage() {
return {
title: 'MG-ADL测评表:评估重症肌无力患者症状对生活质量的影响',
path: '/patient/pages/adl/index',
}
};
},
})
});

120
src/patient/pages/adlResult/index.ts

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
import dayjs from 'dayjs'
const app = getApp<IAppOption>()
import dayjs from 'dayjs';
const app = getApp<IAppOption>();
Page({
data: {
@ -69,19 +69,19 @@ Page({ @@ -69,19 +69,19 @@ Page({
unreadCount: 0,
},
onLoad(options) {
console.log(options)
console.log(options);
app.zdGetTheme().then((res) => {
this.setData({
theme: res,
})
})
});
});
const SystemInfo = app.globalSystemInfo
const SystemInfo = app.globalSystemInfo;
if (SystemInfo) {
const { bottom } = SystemInfo.capsulePosition
const { bottom } = SystemInfo.capsulePosition;
this.setData({
bottom,
})
});
}
this.setData({
id: options.id,
@ -90,27 +90,27 @@ Page({ @@ -90,27 +90,27 @@ Page({
nrdl: options.nrdl,
sendWeiYi: options.wy === '1',
idafa: options.idafa === '1',
})
app.zdWaitLogin({ loginPage: true }).then(() => {
app.zdMpBehavior({ PageName: 'PG_PATIENTASSESSMENTRESULTS' })
app.getZdUserInfo(this, false)
this.getUnreadCount()
this.getDetail()
this.getQrCode()
});
app.waitLogin({ type: [0, 1] }).then(() => {
app.zdMpBehavior({ PageName: 'PG_PATIENTASSESSMENTRESULTS' });
app.getZdUserInfo(this, false);
this.getUnreadCount();
this.getDetail();
this.getQrCode();
if (options.nrdl === '1') {
this.getOpenPatientList()
this.getOpenPatientList();
}
const pages = getCurrentPages() //获取当前页面js里面的pages里的所有信息。
const prevPage = pages[pages.length - 2]
const adlResultInfo = wx.getStorageSync('adlResultInfo')
console.log(options.idafa === '1')
const pages = getCurrentPages(); //获取当前页面js里面的pages里的所有信息。
const prevPage = pages[pages.length - 2];
const adlResultInfo = wx.getStorageSync('adlResultInfo');
console.log(options.idafa === '1');
if (options.idafa === '1') {
this.setData({
toastShow: true,
toastType: 'adlLevelUp',
toastParams: {},
})
});
} else if (adlResultInfo && prevPage.route == 'pages/adl/index' && !Array.isArray(adlResultInfo)) {
this.setData({
toastShow: true,
@ -119,10 +119,10 @@ Page({ @@ -119,10 +119,10 @@ Page({
...adlResultInfo,
Records: adlResultInfo.Records?.reverse(),
},
})
wx.removeStorageSync('adlResultInfo')
});
wx.removeStorageSync('adlResultInfo');
}
})
});
},
getQrCode() {
wx.ajax({
@ -132,8 +132,8 @@ Page({ @@ -132,8 +132,8 @@ Page({
}).then((res) => {
this.setData({
qrcode: res.src,
})
})
});
});
},
getUnreadCount() {
wx.ajax({
@ -143,11 +143,11 @@ Page({ @@ -143,11 +143,11 @@ Page({
}).then((res) => {
this.setData({
unreadCount: res,
})
})
});
});
},
getDetail() {
const { id } = this.data
const { id } = this.data;
wx.ajax({
method: 'GET',
url: '?r=zd/adl/view',
@ -155,21 +155,21 @@ Page({ @@ -155,21 +155,21 @@ Page({
Id: id,
},
}).then((res) => {
let grade = 1
let grade = 1;
if (res.TotalScore < 5) {
grade = 1
grade = 1;
} else if (res.TotalScore >= 5 && res.TotalScore < 15) {
grade = 2
grade = 2;
} else {
grade = 3
grade = 3;
}
this.setData({
detail: res,
grade,
LastCreateDate: dayjs(res.LastCreateTime).format('MM月DD日'),
dateDiff: dayjs(res.CreateTime).from(res.LastCreateTime).replace(' ', ''),
})
})
});
});
},
getOpenPatientList() {
wx.ajax({
@ -179,24 +179,24 @@ Page({ @@ -179,24 +179,24 @@ Page({
}).then((res) => {
this.setData({
patientInfo: res,
})
})
});
});
},
handleDetail() {
const { scurt, noFinish } = this.data
if (noFinish) return
const { scurt, noFinish } = this.data;
if (noFinish) return;
this.setData({
scurt: (scurt + 1) % 2,
noFinish: true,
})
});
},
handleDetailFinish() {
this.setData({
noFinish: false,
})
});
},
handleReset() {
const id = this.data.id
const id = this.data.id;
wx.showModal({
title: '确认重新测试?',
content: '重新测试后,此次评测结果将自动删除',
@ -212,61 +212,61 @@ Page({ @@ -212,61 +212,61 @@ Page({
}).then(() => {
wx.redirectTo({
url: '/patient/pages/adlTest/index',
})
})
});
});
}
},
})
});
},
handleSave() {
app.zdPermissionVerification(3, 2, ``).then(() => {})
app.zdPermissionVerification(3, 2, ``).then(() => {});
},
handleMyHealth() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTGETNOTES' })
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTGETNOTES' });
wx.navigateTo({
url: '/gift/patient/pages/myHealthRecord/index',
})
});
},
handleShare() {
wx.navigateTo({
url: '/patient/pages/adlShare/index',
})
});
},
handleToastOk() {
if (this.data.toastType === 'adlLevelUp') {
wx.navigateTo({
url: '/patient/pages/webview/index',
})
});
}
this.handleToastCancel()
this.handleToastCancel();
},
handleToastCancel() {
this.setData({
toastShow: false,
})
});
},
handleBack() {
wx.navigateBack()
wx.navigateBack();
},
routerTo(e) {
const { url } = e.currentTarget.dataset
const { url } = e.currentTarget.dataset;
if (url === '/patient/pages/interactivePatient/index') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTDOCTORCARD' })
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTDOCTORCARD' });
}
if (url === '/patient/pages/webview/index') {
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTAPPLYINSURANCE' })
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTAPPLYINSURANCE' });
}
wx.navigateTo({
url,
})
});
},
hanldeCodeLong() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTQRCODELONGPRESS' })
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTRESULTQRCODELONGPRESS' });
},
onShareAppMessage() {
return {
title: 'MG-ADL测评表:评估重症肌无力患者症状对生活质量的影响',
path: '/patient/pages/adl/index',
}
};
},
})
});

136
src/patient/pages/adlTest/index.ts

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
const app = getApp<IAppOption>()
const app = getApp<IAppOption>();
Page({
data: {
@ -208,15 +208,15 @@ Page({ @@ -208,15 +208,15 @@ Page({
icon: '9',
},
] as {
title: string
key: string
icon: string
type: string
title: string;
key: string;
icon: string;
type: string;
list: {
id: string
title: string
active?: boolean
}[]
id: string;
title: string;
active?: boolean;
}[];
}[],
params: {},
@ -226,115 +226,115 @@ Page({ @@ -226,115 +226,115 @@ Page({
focus: false,
},
onLoad(options) {
const SystemInfo = app.globalSystemInfo
const SystemInfo = app.globalSystemInfo;
if (SystemInfo) {
const { bottom } = SystemInfo.capsulePosition
const { bottom } = SystemInfo.capsulePosition;
this.setData({
bottom,
})
});
}
this.setData({
m_d: options.m_d,
nrdl: options.nrdl,
})
});
app.zdWaitLogin({ isReg: false }).then(() => {
this.handleMp(this.data.nav)
})
app.waitLogin({ type: [0, 1] }).then(() => {
this.handleMp(this.data.nav);
});
},
handleSelect(e) {
const { index } = e.currentTarget.dataset
const { nav, question } = this.data
const questionItem = question[nav]
const { index } = e.currentTarget.dataset;
const { nav, question } = this.data;
const questionItem = question[nav];
questionItem.list = questionItem.list.map((item, i) => {
if (index == i) {
item.active = true
item.active = true;
} else {
item.active = false
item.active = false;
}
return item
})
return item;
});
this.setData({
[`question[${nav}]`]: questionItem,
})
});
setTimeout(() => {
this.setData({
nav: nav == 8 ? 8 : nav + 1,
showSubmit: nav == 8,
})
this.handleMp(this.data.nav)
}, 500)
});
this.handleMp(this.data.nav);
}, 500);
},
stopTouchMove() {
return false
return false;
},
bindtransition() {
this.setData({
nav: this.data.nav,
})
});
},
handlePrev() {
const { nav } = this.data
const { nav } = this.data;
this.setData({
nav: nav - 1,
})
});
},
handleSubmit() {
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTQ9COMPLETE' })
app.zdMpBehavior({ PageName: 'BTN_PATIENTASSESSMENTQ9COMPLETE' });
wx.showLoading({
title: '提交中',
})
const { question } = this.data
const params = {}
});
const { question } = this.data;
const params = {};
question.forEach((item) => {
if (item.type === 'intenseDose') {
params[item.key] = this.data[item.key]
params[item.key] = this.data[item.key];
} else {
params[item.key] = item.list.findIndex((subItem) => subItem.active)
params[item.key] = item.list.findIndex((subItem) => subItem.active);
}
})
});
this.setData({
params,
})
});
},
handleFinish(e) {
const that = this
const url = `${app.globalData.upFileUrl}?r=file-service/upload-img`
const that = this;
const url = `${app.globalData.upFileUrl}?r=file-service/upload-img`;
wx.uploadFile({
filePath: e.detail,
name: 'file',
url,
success(res) {
const data = JSON.parse(res.data)
that.submitCreate(data.data.Url)
const data = JSON.parse(res.data);
that.submitCreate(data.data.Url);
},
})
});
},
handleHorSelect(e) {
const { id } = e.currentTarget.dataset
const { SteroidDailyDose } = this.data
const { id } = e.currentTarget.dataset;
const { SteroidDailyDose } = this.data;
if (!id) {
this.setData({
popupHormone: SteroidDailyDose > 0 ? SteroidDailyDose : '',
popupShow: true,
})
});
setTimeout(() => {
this.setData({
popupFocus: true,
})
}, 300)
return
});
}, 300);
return;
}
this.setData({
SteroidDailyDose: id * 1,
showSubmit: Boolean(id),
})
});
},
handlePopupCancel() {
this.setData({
popupShow: false,
popupFocus: false,
})
});
},
handlePopupSure() {
// if (!Number(this.data.popupHormone)) {
@ -347,21 +347,21 @@ Page({ @@ -347,21 +347,21 @@ Page({
this.setData({
SteroidDailyDose: Number(this.data.popupHormone),
showSubmit: true,
})
this.handlePopupCancel()
});
this.handlePopupCancel();
},
submitCreate(Url) {
const params = this.data.params
const params = this.data.params;
wx.ajax({
method: 'POST',
url: '?r=zd/adl/create',
data: params,
}).then((res) => {
this.updateAdlImg(res.Id, Url, res)
})
this.updateAdlImg(res.Id, Url, res);
});
},
updateAdlImg(id, Url, params) {
const { m_d, nrdl } = this.data
const { m_d, nrdl } = this.data;
wx.ajax({
method: 'POST',
url: '?r=zd/adl/update-img',
@ -370,29 +370,29 @@ Page({ @@ -370,29 +370,29 @@ Page({
ImgUrl: Url,
},
}).then(() => {
wx.hideLoading()
wx.setStorageSync('adlResultInfo', params.ScoreInfo)
wx.hideLoading();
wx.setStorageSync('adlResultInfo', params.ScoreInfo);
wx.redirectTo({
url: `/patient/pages/adlResult/index?id=${id}&reset=1&m_d=${m_d}&nrdl=${nrdl}&wy=${Number(params.sendWeiYi)}&idafa=${Number(params.inviteDoctorAndFirstAdl)}`,
})
})
});
});
},
handleInput(e) {
if (e.detail.value) {
this.setData({
// eslint-disable-next-line regexp/optimal-quantifier-concatenation
popupHormone: e.detail.value.replace(/^(-)?(\d{0,3})(\.\d?)?.*$/, '$1$2$3'),
})
});
}
},
handleBack() {
wx.navigateBack()
wx.navigateBack();
},
onShareAppMessage() {
return {
title: 'MG-ADL测评表:评估重症肌无力患者症状对生活质量的影响',
path: '/patient/pages/adl/index',
}
};
},
handleMp(index) {
@ -406,7 +406,7 @@ Page({ @@ -406,7 +406,7 @@ Page({
6: 'PG_PATIENTASSESSMENTQ7',
7: 'PG_PATIENTASSESSMENTQ8',
8: 'PG_PATIENTASSESSMENTQ9',
}[index]
app.zdMpBehavior({ PageName })
}[index];
app.zdMpBehavior({ PageName });
},
})
});

4
src/patient/pages/start/index.json

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
{
"navigationStyle": "custom",
"usingComponents": {}
}

4
src/patient/pages/start/index.scss

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
.page{
width: 100vw;
height: 100vh;
}

33
src/patient/pages/start/index.ts

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
const app = getApp<IAppOption>()
Page({
data: {},
onLoad() {
app.zdWaitLogin().then((_res) => {
const { isLogin, anyWhere } = app.globalData
if (isLogin) {
const url = {
1: '/patient/pages/index/index',
2: '/doctor/patient/pages/d_home/index',
}[app.globalData.loginType]
wx.reLaunch({
url: url || '/patient/pages/index/index',
})
return
}
if (anyWhere) {
wx.reLaunch({
url: '/patient/pages/index/index',
})
return
}
const url = {
1: '/patient/pages/login/index',
2: '/doctor/patient/pages/d_login/index',
}[app.globalData.loginType]
wx.reLaunch({
url: url || '/patient/pages/login/index',
})
})
},
})

1
src/patient/pages/start/index.wxml

@ -1 +0,0 @@ @@ -1 +0,0 @@
<image class="page" mode="aspectFill" src="{{imageUrl}}za-images/1/start.png?t={{Timestamp}}"></image>

2
typings/index.d.ts vendored

@ -41,6 +41,8 @@ interface IAppOption { @@ -41,6 +41,8 @@ interface IAppOption {
getUserInfo: (type: 0 | 1 | 2) => Promise<never>;
mpBehavior: (data: { PositionId: string; OperateType: string; OperateId: string }) => void;
zdMpBehavior: (data: { PageName: string; doctor?: boolean }) => void;
zdGetTheme: () => Promise<'PATIENT'>;
zdWaitLogin: (obj?: { isReg?: boolean; loginPage?: boolean; pub?: boolean }) => Promise<any>
[propName: string]: any;
}

Loading…
Cancel
Save