From 6aca21f0bfcc3b038078bd0f3d19bddb0362835c Mon Sep 17 00:00:00 2001 From: kola-web Date: Thu, 30 Apr 2026 17:59:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E7=85=A7=E7=89=87?= =?UTF-8?q?=E5=AF=B9=E6=AF=94=E5=8A=9F=E8=83=BD=E5=8F=8A=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit refactor: 重构患者详情、记录列表和详情页 fix: 修复样式问题和类型定义 docs: 更新AGENTS.md文档说明 style: 统一代码格式和颜色值写法 test: 添加相关接口测试用例 chore: 更新依赖和配置文件 --- .trae/documents/proptosis_api_integration_plan.md | 240 ++++++++ .vscode/settings.json | 4 +- AGENTS.md | 37 +- README.md | 3 +- eslint.config.js | 6 +- project.config.json | 2 +- project.private.config.json | 2 +- src/app.json | 4 +- src/custom-tab-bar/index.scss | 4 +- src/pages/d_noteDetail/index.ts | 192 +++--- src/pages/d_noteDetail/index.wxml | 39 +- src/pages/d_noteDiff/index.json | 4 + src/pages/d_noteDiff/index.scss | 275 +++++++++ src/pages/d_noteDiff/index.ts | 212 +++++++ src/pages/d_noteDiff/index.wxml | 81 +++ src/pages/d_noteDiffData/index.ts | 137 ++++- src/pages/d_noteDiffData/index.wxml | 17 +- src/pages/d_noteDiffEdit/index.json | 6 + src/pages/d_noteDiffEdit/index.scss | 163 ++++++ src/pages/d_noteDiffEdit/index.ts | 156 +++++ src/pages/d_noteDiffEdit/index.wxml | 32 + src/pages/d_noteList/index.ts | 165 +++--- src/pages/d_noteList/index.wxml | 18 +- src/pages/d_patient/index.scss | 2 +- src/pages/d_patient/index.ts | 9 +- src/pages/d_patientDetail/index.scss | 2 +- src/pages/d_patientDetail/index.ts | 25 +- src/patient/components/camera/index.ts | 167 +++++- src/patient/components/camera/index.wxml | 6 +- src/patient/components/image-crop/index.json | 2 +- src/patient/components/image-merge/index.json | 2 +- src/patient/pages/note/index.scss | 11 + src/patient/pages/note/index.ts | 126 +++- src/patient/pages/note/index.wxml | 38 +- src/patient/pages/noteAdd/index.ts | 496 +++++++++++++--- src/patient/pages/noteAdd/index.wxml | 76 ++- src/patient/pages/noteDiff/index.ts | 183 +++++- src/patient/pages/noteDiff/index.wxml | 42 +- src/patient/pages/noteDiffEdit/index.scss | 122 +++- src/patient/pages/noteDiffEdit/index.ts | 178 +++++- src/patient/pages/noteDiffEdit/index.wxml | 38 +- src/patient/pages/noteHistory/index.scss | 4 +- src/patient/pages/noteHistory/index.ts | 240 +++++--- src/patient/pages/noteHistory/index.wxml | 54 +- src/sitemap.json | 6 +- typings/index.d.ts | 8 +- 接口文档.md | 675 ++++++++++++---------- 47 files changed, 3479 insertions(+), 832 deletions(-) create mode 100644 .trae/documents/proptosis_api_integration_plan.md create mode 100644 src/pages/d_noteDiff/index.json create mode 100644 src/pages/d_noteDiff/index.scss create mode 100644 src/pages/d_noteDiff/index.ts create mode 100644 src/pages/d_noteDiff/index.wxml create mode 100644 src/pages/d_noteDiffEdit/index.json create mode 100644 src/pages/d_noteDiffEdit/index.scss create mode 100644 src/pages/d_noteDiffEdit/index.ts create mode 100644 src/pages/d_noteDiffEdit/index.wxml diff --git a/.trae/documents/proptosis_api_integration_plan.md b/.trae/documents/proptosis_api_integration_plan.md new file mode 100644 index 0000000..4f7fbb7 --- /dev/null +++ b/.trae/documents/proptosis_api_integration_plan.md @@ -0,0 +1,240 @@ +# 突眼日记接口联调计划 + +## 一、项目现状分析 + +### 1.1 已有页面结构 + +**医生端 (d\_ 前缀)** + +- `d_noteList` - 突眼记录列表页(拍摄示例页) + +- `d_noteDetail` - 突眼记录详情页 + +- `d_noteDiffData` - 凸眼度对比数据页(表格展示) + +_患者端 (patient/pages/note_)\* + +- `note` - 突眼日记首页 + +- `noteAdd` - 新增记录页 + +- `noteHistory` - 历史记录页 + +- `noteDiff` - 照片对比页 + +- `noteDiffEdit` - 对比编辑页 + +- `noteDemo` - 拍摄示例页 + +### 1.2 当前状态 + +- 所有页面都是静态数据,未接入接口 + +- 请求工具已封装在 `utils/request.ts` + +- 使用 `wx.ajax` 进行接口调用(在 app.ts 中挂载) + +--- + +## 二、需要的信息 + +在开始联调前,需要你提供以下信息: + +### 2.1 环境信息 + +| 信息项 | 说明 | 是否必需 | +| -------------- | --------------------------- | -------- | +| 后端环境地址 | 开发/测试服务器地址 | 是 | +| 接口是否已部署 | 后端接口是否已上线可调用 | 是 | +| 登录态获取方式 | 如何获取 loginState/session | 是 | + +### 2.2 接口测试信息 + +| 信息项 | 说明 | 是否必需 | +| ---------- | -------------------------- | -------- | +| 测试账号 | 医生账号和患者账号 | 是 | +| 测试患者ID | 用于医生端接口测试 | 是 | +| 已有数据 | 是否有已创建的突眼记录数据 | 否 | + +### 2.3 图片上传相关 + +| 信息项 | 说明 | 是否必需 | +| ------------- | ----------------------------- | -------- | +| 图片上传方式 | 上传到腾讯云COS还是自家服务器 | 是 | +| 腾讯云IMS配置 | 是否已配置图片内容安全校验 | 否 | + +--- + +## 三、接口联调清单 + +### 3.1 患者端接口 (10个) + +| 序号 | 接口 | 用途 | 对应页面 | 优先级 | +| ---- | ------------------- | ---------------- | ----------------- | ------ | +| 1 | `baseline-status` | 获取基准照状态 | note | P0 | +| 2 | `record-list` | 获取记录列表 | note, noteHistory | P0 | +| 3 | `record-detail` | 获取记录详情 | noteHistory | P0 | +| 4 | `record-save` | 创建/更新记录 | noteAdd | P0 | +| 5 | `photo-upload` | 上传照片 | noteAdd | P0 | +| 6 | `record-delete` | 删除记录 | noteHistory | P1 | +| 7 | `compare-dates` | 获取对比可用日期 | noteDiff | P1 | +| 8 | `compare-photos` | 获取对比照片 | noteDiff | P1 | +| 9 | `get-compare-angle` | 获取对比角度列表 | noteDiffEdit | P1 | +| 10 | `get-session-id` | 获取唯一标识 | noteAdd | P2 | + +### 3.2 医生端接口 (6个) + +| 序号 | 接口 | 用途 | 对应页面 | 优先级 | +| ---- | ------------------------------------ | ---------------- | --------------- | ------ | +| 1 | `doctor/proptosis/latest` | 获取最近记录 | d_patientDetail | P0 | +| 2 | `doctor/proptosis/list` | 获取患者记录列表 | d_noteList | P0 | +| 3 | `doctor/proptosis/detail` | 获取记录详情 | d_noteDetail | P0 | +| 4 | `doctor/proptosis/export` | Excel导出 | d_noteDiffData | P1 | +| 5 | `doctor/proptosis/compare` | 获取对比数据 | d_noteDiffData | P1 | +| 6 | `doctor/proptosis/get-compare-angle` | 获取对比角度 | d_noteDiffData | P1 | + +--- + +## 四、实施步骤 + +### Phase 1: 基础联调准备 + +1. 确认后端环境可用 +2. 获取测试账号和患者ID +3. 验证登录态获取 + +### Phase 2: 患者端核心功能 + +1. 实现记录列表获取 (`record-list`) +2. 实现记录详情获取 (`record-detail`) +3. 实现记录创建/更新 (`record-save`) +4. 实现照片上传 (`photo-upload`) + +### Phase 3: 患者端对比功能 + +1. 实现对比日期获取 (`compare-dates`) +2. 实现对比照片获取 (`compare-photos`) +3. 实现对比角度获取 (`get-compare-angle`) + +### Phase 4: 医生端功能 + +1. 实现患者最近记录获取 (`doctor/proptosis/latest`) +2. 实现患者记录列表 (`doctor/proptosis/list`) +3. 实现记录详情 (`doctor/proptosis/detail`) +4. 实现对比数据获取 (`doctor/proptosis/compare`) + +### Phase 5: 导出功能 + +1. 实现Excel导出 (`doctor/proptosis/export`) + +--- + +## 五、数据结构映射 + +### 5.1 患者端 - 记录列表 + +```typescript +// 接口返回 +interface RecordItem { + recordId: string + recordDate: string + isBaseline: number + photoCount: number + firstPhotoUrl: string + treatmentCount: number + leftEye: number + rightEye: number + interorbitalDistance: number + uploadCompleted: number +} + +// 页面使用 +interface DataListItem { + date: string // recordDate 格式化 + left: string // leftEye + spacing: string // interorbitalDistance + right: string // rightEye + count: string // treatmentCount + isBaseline: boolean + photoCount: number + firstPhotoUrl: string +} +``` + +### 5.2 医生端 - 凸眼度对比表格 + +```typescript +// 接口返回 (compare 接口) +interface CompareItem { + recordId: string + recordDate: string + photoUrl: string + leftEye: number + rightEye: number + interorbitalDistance: number + treatmentCount: number +} + +// 页面使用 (d_noteDiffData) +interface TableItem { + date: string // recordDate 格式化 2026.1.5 + left: string // leftEye + spacing: string // interorbitalDistance + right: string // rightEye + count: string // treatmentCount +} +``` + +--- + +## 六、注意事项 + +### 6.1 业务规则 + +1. 同一天只能创建一条记录 +2. 必须先上传照片再保存记录(photoIds 关联) +3. 基准照只能有一张 +4. 图片需要经过腾讯云IMS安全校验 + +### 6.2 技术注意 + +1. 使用 `wx.ajax` 进行请求(已挂载在 app 上) +2. 医生端页面需要等待登录态 `app.waitLogin({ type: [2] })` +3. 患者端页面需要等待登录态 `app.waitLogin({ type: [1] })` +4. 图片URL需要拼接 `{{imageUrl}}` 前缀 + +### 6.3 角度映射 + +接口角度值与页面显示名称映射: + +```typescript +const angleMap = { + front_open: '正面睁眼', + front_closed: '正面闭眼', + front_looking_up: '正面仰头', + side_left_90: '90°左侧', + side_right_90: '90°右侧', + side_left_45: '45°左侧', + side_right_45: '45°右侧', + eye_up_left: '左上', + eye_up: '向上', + eye_up_right: '右上', + eye_left: '向左', + eye_right: '向右', + eye_down_left: '左下', + eye_down: '向下', + eye_down_right: '右下', +} +``` + +--- + +## 七、下一步 + +请提供以下信息,我将开始实施联调: + +1. **后端环境地址**(如: +2. **测试账号**(医生和患者各一个) +3. **测试患者ID**(用于医生端接口测试) +4. **接口是否已部署**(确认后端已完成开发) +5. **图片上传方式**(腾讯云COS或自家服务器) diff --git a/.vscode/settings.json b/.vscode/settings.json index 83a744d..e0ba438 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "path-autocomplete.pathMappings": { "@": "${folder}/src", - "/": "${folder}/src", + "/": "${folder}/src" }, "emmet.preferences": { "css.intUnit": "rpx", @@ -9,5 +9,5 @@ }, "css.customData": [ ".vscode/css-data.json" - ], + ] } diff --git a/AGENTS.md b/AGENTS.md index 859e23e..8bd4ddf 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -28,11 +28,14 @@ src/ ## Key Conventions ### Path Aliases + - `@/*` → `src/*` (configured in tsconfig.json and app.json `resolveAlias`) - Use `@/utils/request` not relative paths ### User Types & Routing + Login types enforced in `app.ts`: + - `0`: Not logged in - `1`: Patient (患者) → routes to `/patient/pages/*` - `2`: Doctor (医生) → routes to `/pages/*` @@ -40,13 +43,17 @@ Login types enforced in `app.ts`: Use `app.zdWaitLogin()` to guard pages that require login. ### Page/Component Wrappers + `app.ts` overrides global `Page` and `Component` with wrappers from `utils/page.ts` and `utils/component.ts`: + - Auto-sets `imageUrl` and `Timestamp` on page load - Auto-handles navbar background on scroll - Provides default share behavior ### Modal Colors (Required) + All `wx.showModal` must use: + ```ts wx.showModal({ confirmColor: '#8c75d0', @@ -54,6 +61,29 @@ wx.showModal({ }) ``` +### App Instance (Required) + +`getApp()` should be called at the top of the file, not inside methods: + +````ts +// ✅ Correct +const app = getApp() + +Page({ + onLoad() { + // Use app directly + console.log(app.globalData) + } +}) + +// ❌ Incorrect +Page({ + onLoad() { + const app = getApp() + console.log(app.globalData) + } +})``` + ## Available Commands ```bash @@ -66,13 +96,14 @@ pnpm install # Build: Use WeChat Developer Tools # - Import project with src/ as root # - project.config.json at repo root -``` +```` ## NPM Dependencies **Critical**: After `npm install`, run **Tools → Build npm** in WeChat Developer Tools to generate `miniprogram_npm/`. This is required for Vant and other packages. Key dependencies: + - `@vant/weapp`: UI components - `miniprogram-licia`: Utility library (available as `licia`) - `dayjs`: Date handling @@ -81,12 +112,14 @@ Key dependencies: ## Images & Assets **Images are stored in SVN, not git.** + - SVN URL: `svn://39.106.86.127:28386/projects/xd/proj_src/shop/frontend/web/xd/` - Local path: `src/images/` (gitignored) - Excluded from upload via `project.config.json` packOptions - Only `/images/tabbar/*` is included in uploads Image URL pattern: + ``` {{imageUrl}}/path/to/image.png?t={{Timestamp}} ``` @@ -99,6 +132,7 @@ Image URL pattern: - Types: `miniprogram-api-typings` for WX API Global types in `typings/index.d.ts`: + - `IAppOption`: Global app instance interface - `pageType`: 0 | 1 | 2 for user types - `wx.ajax`: Extended request method @@ -113,6 +147,7 @@ Global types in `typings/index.d.ts`: ## Environment Configuration Selected by App ID in `src/config.ts`: + - `wxf9ce8010f1ad24aa`: Dev/Staging (hbraas.com) - `wx71ac9c27c3c3e3f4`: Production (hbsaas.com) diff --git a/README.md b/README.md index a650a72..28005c6 100644 --- a/README.md +++ b/README.md @@ -49,9 +49,8 @@ wx.showModal({ 正整数 2 正整数 3 - - 已修改未上线内容 + 1. 医生端首页 统计数据改为实时更新 2. 就诊地图重新定位,在非北京地区重新定位会重新定位到北京,再次切换才会定位到当地 3. 患者端注册页导航栏增加返回上一页按钮 diff --git a/eslint.config.js b/eslint.config.js index 373ba86..af97eaf 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -4,6 +4,10 @@ export default antfu({ env: { es6: true, }, + ignores: [ + '**/miniprogram_npm/**', + 'src/miniprogram_npm/**', + ], parserOptions: { project: ['./tsconfig.json'] }, globals: { wx: true, @@ -18,7 +22,7 @@ export default antfu({ rules: { 'eslint-comments/no-unlimited-disable': 'off', 'ts/no-require-imports': 'off', - eqeqeq: 'off', + 'eqeqeq': 'off', }, formatters: { css: 'prettier', diff --git a/project.config.json b/project.config.json index 625d498..f6772f8 100644 --- a/project.config.json +++ b/project.config.json @@ -72,4 +72,4 @@ ] }, "appid": "wxf9ce8010f1ad24aa" -} \ No newline at end of file +} diff --git a/project.private.config.json b/project.private.config.json index a931232..95aa387 100644 --- a/project.private.config.json +++ b/project.private.config.json @@ -320,4 +320,4 @@ } }, "libVersion": "3.8.9" -} \ No newline at end of file +} diff --git a/src/app.json b/src/app.json index 0027fa5..fb1275e 100644 --- a/src/app.json +++ b/src/app.json @@ -19,7 +19,9 @@ "pages/d_qolDetail/index", "pages/d_noteDetail/index", "pages/d_noteList/index", - "pages/d_noteDiffData/index" + "pages/d_noteDiffData/index", + "pages/d_noteDiff/index", + "pages/d_noteDiffEdit/index" ], "subPackages": [ { diff --git a/src/custom-tab-bar/index.scss b/src/custom-tab-bar/index.scss index 0ebb617..da2cdc8 100644 --- a/src/custom-tab-bar/index.scss +++ b/src/custom-tab-bar/index.scss @@ -40,7 +40,7 @@ .name { margin-top: 8rpx; font-size: 22rpx; - color: #69686E; + color: #69686e; line-height: 21rpx; } &.active { @@ -53,7 +53,7 @@ } } .name { - color: #211D2E; + color: #211d2e; } } } diff --git a/src/pages/d_noteDetail/index.ts b/src/pages/d_noteDetail/index.ts index 9b95604..8e72fec 100644 --- a/src/pages/d_noteDetail/index.ts +++ b/src/pages/d_noteDetail/index.ts @@ -1,86 +1,130 @@ -const _app = getApp() +const app = getApp() + +interface Photo { + photoId: string + photoAngle: string + photoAngleName: string + photoUrl: string + uploadTime: string +} + +interface RecordDetail { + recordId: string + userId: string + patientId: string + recordDate: string + treatmentCount: number + isBaseline: number + leftEye: number + rightEye: number + interorbitalDistance: number + uploadCompleted: number + photos: Photo[] +} Page({ data: { - history: { - frontend: [ - { - title: '正面睁眼照', - content: '平视,目光看向镜头方向,自然睁眼,不眯眼、不瞪眼。', - }, - { - title: '正面闭眼照', - content: '正对镜头,面部居中,自然放松,双眼轻轻闭合,不皱眉、不挤眼。', - }, - { - title: '正面仰头照', - content: '拍摄时,正对镜头,面部居中,头部自然向上仰至约 45°,双眼同步平视,保持自然睁眼、不眯眼。', - }, - ], - backend: [ - { - title: '左侧-90°', - content: '身体与头部完全转向右侧,呈标准 90° 侧面,仅可见左侧眼睛。', - }, - { - title: '右侧-90°', - content: '身体与头部完全转向左侧,呈标准 90° 侧面,仅可见右侧眼睛。', - }, - { - title: '左侧-45°', - content: '身体与头部转向右前方 45°。', - }, - { - title: '右侧-45°', - content: '身体与头部转向左前方 45°', - }, - ], - other: [ - { - title: '正面眼睛上看', - content: '', - }, - { - title: '正面眼睛下看', - content: '', - }, - { - title: '正面眼睛左看', - content: '', - }, - { - title: '正面眼睛右看', - content: '', - }, - { - title: '正面眼睛左上看', - content: '', - }, - { - title: '正面眼睛右上看', - content: '', - }, - { - title: '正面眼睛左下看', - content: '', - }, - { - title: '正面眼睛右下看', - content: '', - }, - ], + patientId: '', + recordId: '', + recordDetail: {} as RecordDetail, + + // 角度分组 + angleGroups: { + frontend: ['front_open', 'front_closed', 'front_looking_up'], + backend: ['side_left_90', 'side_right_90', 'side_left_45', 'side_right_45'], + other: ['eye_up_left', 'eye_up', 'eye_up_right', 'eye_left', 'eye_right', 'eye_down_left', 'eye_down', 'eye_down_right'], }, + + // 角度名称映射 + angleNameMap: { + front_open: '正面睁眼照', + front_closed: '正面闭眼照', + front_looking_up: '正面仰头照', + side_left_90: '左侧-90°', + side_right_90: '右侧-90°', + side_left_45: '左侧-45°', + side_right_45: '右侧-45°', + eye_up_left: '正面眼睛左上', + eye_up: '正面眼睛上看', + eye_up_right: '正面眼睛右上', + eye_left: '正面眼睛左看', + eye_right: '正面眼睛右看', + eye_down_left: '正面眼睛左下', + eye_down: '正面眼睛下看', + eye_down_right: '正面眼睛右下', + } as Record, }, - onLoad() {}, - handlePopupOk() { + onLoad(option: any) { this.setData({ - popupShow: false, + patientId: option.patientId || '', + recordId: option.recordId || '', }) }, - handlePopupCancel() { - this.setData({ - popupShow: false, + + onShow() { + app.waitLogin({ type: [2] }).then(() => { + if (this.data.recordId) { + this.getRecordDetail() + } + }) + }, + + // 获取记录详情 + getRecordDetail() { + wx.showLoading({ title: '加载中...' }) + wx.ajax({ + method: 'GET', + url: '?r=xd/doctor/proptosis/detail', + data: { + recordId: this.data.recordId, + }, + }).then((res: any) => { + wx.hideLoading() + this.setData({ + recordDetail: res, + }) + }).catch((err) => { + wx.hideLoading() + console.error('获取记录详情失败:', err) + wx.showToast({ title: '加载失败', icon: 'none' }) + }) + }, + + // 获取指定角度的照片 + getPhotoByAngle(angle: string): Photo | undefined { + const photos = this.data.recordDetail.photos || [] + return photos.find((p: Photo) => p.photoAngle === angle) + }, + + // 返回上一页 + handleBack() { + wx.navigateBack() + }, + + // 预览图片 + handlePreview(e: any) { + const { angle } = e.currentTarget.dataset + const photo = this.getPhotoByAngle(angle) + if (photo) { + wx.previewImage({ + urls: [photo.photoUrl], + current: photo.photoUrl, + }) + } + }, + + // 眼突度对比 + handleDiffData() { + wx.navigateTo({ + url: `/pages/d_noteDiffData/index?patientId=${this.data.patientId}`, + }) + }, + + // 照片对比 + handlePhotoCompare() { + wx.navigateTo({ + url: `/pages/d_noteDiff/index?patientId=${this.data.patientId}`, }) }, }) diff --git a/src/pages/d_noteDetail/index.wxml b/src/pages/d_noteDetail/index.wxml index 39f68c4..76f1ec3 100644 --- a/src/pages/d_noteDetail/index.wxml +++ b/src/pages/d_noteDetail/index.wxml @@ -7,33 +7,33 @@ style="background: url('{{imageUrl}}bg10.png?t={{Timestamp}}') no-repeat top center/100% 610rpx;padding-top:{{pageTop+16}}px;" > - 基准照 - 2026-04-02 + 基准照 + {{recordDetail.recordDate}} 当前记录对应的替妥尤单抗使用次数: - 1 + {{recordDetail.treatmentCount}} -