From 069b32a47308dc4b36193a0cd4f2031d99d9f204 Mon Sep 17 00:00:00 2001 From: kola-web Date: Sat, 16 Aug 2025 11:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=82=A3=E8=80=85=E7=AB=AF=E8=BF=81=E7=A7=BBbu?= =?UTF-8?q?g=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app.ts | 20 +----- src/pages/start/index.ts | 9 ++- src/patient/pages/adl/index.ts | 66 ++++++++--------- src/patient/pages/adlResult/index.ts | 120 +++++++++++++++---------------- src/patient/pages/adlTest/index.ts | 136 +++++++++++++++++------------------ src/patient/pages/start/index.json | 4 -- src/patient/pages/start/index.scss | 4 -- src/patient/pages/start/index.ts | 33 --------- src/patient/pages/start/index.wxml | 1 - typings/index.d.ts | 2 + 10 files changed, 172 insertions(+), 223 deletions(-) delete mode 100644 src/patient/pages/start/index.json delete mode 100644 src/patient/pages/start/index.scss delete mode 100644 src/patient/pages/start/index.ts delete mode 100644 src/patient/pages/start/index.wxml diff --git a/src/app.ts b/src/app.ts index 50e4d62..6129079 100644 --- a/src/app.ts +++ b/src/app.ts @@ -140,7 +140,7 @@ App({ 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({ }, 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 }) { diff --git a/src/pages/start/index.ts b/src/pages/start/index.ts index 766b437..d3b6b56 100644 --- a/src/pages/start/index.ts +++ b/src/pages/start/index.ts @@ -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; } }); }, diff --git a/src/patient/pages/adl/index.ts b/src/patient/pages/adl/index.ts index c0b597e..e1c8cc2 100644 --- a/src/patient/pages/adl/index.ts +++ b/src/patient/pages/adl/index.ts @@ -1,4 +1,4 @@ -const app = getApp() +const app = getApp(); Page({ data: { @@ -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({ 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({ }).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', - } + }; }, -}) +}); diff --git a/src/patient/pages/adlResult/index.ts b/src/patient/pages/adlResult/index.ts index 0d30381..993541a 100644 --- a/src/patient/pages/adlResult/index.ts +++ b/src/patient/pages/adlResult/index.ts @@ -1,5 +1,5 @@ -import dayjs from 'dayjs' -const app = getApp() +import dayjs from 'dayjs'; +const app = getApp(); Page({ data: { @@ -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({ 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({ ...adlResultInfo, Records: adlResultInfo.Records?.reverse(), }, - }) - wx.removeStorageSync('adlResultInfo') + }); + wx.removeStorageSync('adlResultInfo'); } - }) + }); }, getQrCode() { wx.ajax({ @@ -132,8 +132,8 @@ Page({ }).then((res) => { this.setData({ qrcode: res.src, - }) - }) + }); + }); }, getUnreadCount() { wx.ajax({ @@ -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({ 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({ }).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({ }).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', - } + }; }, -}) +}); diff --git a/src/patient/pages/adlTest/index.ts b/src/patient/pages/adlTest/index.ts index e8af8fa..e3e178c 100644 --- a/src/patient/pages/adlTest/index.ts +++ b/src/patient/pages/adlTest/index.ts @@ -1,4 +1,4 @@ -const app = getApp() +const app = getApp(); Page({ data: { @@ -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({ 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({ 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({ 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({ 6: 'PG_PATIENTASSESSMENTQ7', 7: 'PG_PATIENTASSESSMENTQ8', 8: 'PG_PATIENTASSESSMENTQ9', - }[index] - app.zdMpBehavior({ PageName }) + }[index]; + app.zdMpBehavior({ PageName }); }, -}) +}); diff --git a/src/patient/pages/start/index.json b/src/patient/pages/start/index.json deleted file mode 100644 index 8e0a32a..0000000 --- a/src/patient/pages/start/index.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "navigationStyle": "custom", - "usingComponents": {} -} diff --git a/src/patient/pages/start/index.scss b/src/patient/pages/start/index.scss deleted file mode 100644 index 4cc4fcd..0000000 --- a/src/patient/pages/start/index.scss +++ /dev/null @@ -1,4 +0,0 @@ -.page{ - width: 100vw; - height: 100vh; -} diff --git a/src/patient/pages/start/index.ts b/src/patient/pages/start/index.ts deleted file mode 100644 index 479366c..0000000 --- a/src/patient/pages/start/index.ts +++ /dev/null @@ -1,33 +0,0 @@ -const app = getApp() - -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', - }) - }) - }, -}) diff --git a/src/patient/pages/start/index.wxml b/src/patient/pages/start/index.wxml deleted file mode 100644 index 730e90b..0000000 --- a/src/patient/pages/start/index.wxml +++ /dev/null @@ -1 +0,0 @@ - diff --git a/typings/index.d.ts b/typings/index.d.ts index 622ffb1..b48571b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -41,6 +41,8 @@ interface IAppOption { getUserInfo: (type: 0 | 1 | 2) => Promise; 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 [propName: string]: any; }