From 26cdfd718f34e2d3e87194e82b4110ec70ce0c07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=90=A6?= Date: Sat, 8 Aug 2026 10:33:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BF=AE=E5=A4=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=88=E5=81=A5=E5=BA=B7=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E3=80=81VIP=E3=80=81=E5=8C=BB=E7=94=9F=E7=AB=AF=E5=81=A5?= =?UTF-8?q?=E5=BA=B7=E4=BF=A1=E6=81=AF=E5=AF=BC=E5=85=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .cursor/rules/Api-Response.mdc | 49 +++++ .cursor/rules/Code-Standards.md | 1 + .cursor/rules/Code-Standards.mdc | 2 + components/vip-gate/vip-gate.vue | 40 ++++ .../components/UserPatientDetail.vue | 32 ++- .../user-patient/detail.vue | 32 ++- subPackages/sub_my/prescriptionList.vue | 16 +- .../components/MedicalRecordPanel.vue | 171 +++++++++++++++- .../sub_workbench/prescription_v2/index.vue | 37 ++-- .../utils/mapHealthInquiryToMrHistory.js | 65 ++++++ .../sub_workbench/workbench_infoPatient.vue | 192 +++++++++++++++++- utils/api-response.js | 78 +++++++ utils/vip.js | 87 ++++++++ 13 files changed, 776 insertions(+), 26 deletions(-) create mode 100644 .cursor/rules/Api-Response.mdc create mode 100644 components/vip-gate/vip-gate.vue create mode 100644 subPackages/sub_workbench/prescription_v2/utils/mapHealthInquiryToMrHistory.js create mode 100644 utils/api-response.js create mode 100644 utils/vip.js diff --git a/.cursor/rules/Api-Response.mdc b/.cursor/rules/Api-Response.mdc new file mode 100644 index 0000000..3f1b7a5 --- /dev/null +++ b/.cursor/rules/Api-Response.mdc @@ -0,0 +1,49 @@ +--- +description: Yii 与 xk-api 接口响应取值规范(按后端固定写死,禁止混取) +alwaysApply: true +--- + +# 接口响应取值(Yii vs xk-api) + +写请求代码时**先确认该接口走哪个后端**,再按对应字段固定取值。 +**禁止**运行时猜测(如「有 code 就取 result」),**禁止** `result || data` / `code ?? errcode` 混写兼容。 + +## 形态对照 + +| | Yii(oldApi) | xk-api(Laravel jok) | +|---|---|---| +| 成功码 | `errcode: 0` | `code: 0` | +| 业务数据 | `data` | `result` | +| 提示文案 | `msg` | `message` | + +## 强制用法 + +统一用 `@/utils/api-response.js`,按后端选方法: + +```js +// 该接口是 xk-api(医生端拦截器多已返回 body) +import { unwrapXkApi } from '@/utils/api-response.js' +const { ok, payload, message } = unwrapXkApi(res) + +// 该接口是 Yii +import { unwrapYiiApi } from '@/utils/api-response.js' +const { ok, payload, message } = unwrapYiiApi(res) +``` + +也可直接写死: + +```js +// xk-api(拦截器已解包时) +if (res.code == 0) { const data = res.result } + +// Yii +if (res.errcode == 0) { const data = res.data } +``` + +API 封装文件注释里标明后端。 + +## 禁止 + +- 禁止 `unwrapApi` 一类「自动识别后端再取值」 +- 禁止 `res.result || res.data` +- 禁止同一处同时判断 `code` 与 `errcode` 做兼容分支 diff --git a/.cursor/rules/Code-Standards.md b/.cursor/rules/Code-Standards.md index 4e74dd2..600712f 100644 --- a/.cursor/rules/Code-Standards.md +++ b/.cursor/rules/Code-Standards.md @@ -10,3 +10,4 @@ alwaysApply: true 5. 数据库的(created_at、updated_at、deleted_at)统一使用时间戳,不要使用字符串,并且我在查询器中一级格式化成字符串了,无需再次格式化 6. 微信小程序 `.vue` 模板(会编译成 WXML)禁止使用 `??`、`?.` 等现代运算符,否则会报 `unexpected token '?'`;模板里用 `||` / 显式判断,脚本里可用 `??`/`?.` 7. 微信小程序模板里 `:class` / `:style` 禁止写 `fn(arg)` 方法调用(如 `:class="sexClass(p)"` 会编译失败);用对象/数组字面量(如 `:class="{ male: p.sex == 1 }"`),或把结果先算进 data/computed 再绑定 +8. 接口取值:写代码时先确认接口是 xk-api 还是 Yii,再固定用 `code/result/message` 或 `errcode/data/msg`(可用 `unwrapXkApi` / `unwrapYiiApi`);禁止运行时猜测、禁止 `result || data`(详见 Api-Response.mdc) diff --git a/.cursor/rules/Code-Standards.mdc b/.cursor/rules/Code-Standards.mdc index 4e74dd2..b21997f 100644 --- a/.cursor/rules/Code-Standards.mdc +++ b/.cursor/rules/Code-Standards.mdc @@ -10,3 +10,5 @@ alwaysApply: true 5. 数据库的(created_at、updated_at、deleted_at)统一使用时间戳,不要使用字符串,并且我在查询器中一级格式化成字符串了,无需再次格式化 6. 微信小程序 `.vue` 模板(会编译成 WXML)禁止使用 `??`、`?.` 等现代运算符,否则会报 `unexpected token '?'`;模板里用 `||` / 显式判断,脚本里可用 `??`/`?.` 7. 微信小程序模板里 `:class` / `:style` 禁止写 `fn(arg)` 方法调用(如 `:class="sexClass(p)"` 会编译失败);用对象/数组字面量(如 `:class="{ male: p.sex == 1 }"`),或把结果先算进 data/computed 再绑定 +8. 接口取值:写代码时先确认接口是 xk-api 还是 Yii,再固定用 `code/result/message` 或 `errcode/data/msg`(可用 `unwrapXkApi` / `unwrapYiiApi`);禁止运行时猜测、禁止 `result || data`(详见 Api-Response.mdc) +9. VIP 功能判断:统一用 `@/utils/vip.js` 的 `hasVipPermission` / `fetchStoreVipPermissions` / `VIP_FEATURE`;模板显隐用 ``;禁止各页手写 `permissions.indexOf` 或重复解析 get-current-store-type diff --git a/components/vip-gate/vip-gate.vue b/components/vip-gate/vip-gate.vue new file mode 100644 index 0000000..2f031d6 --- /dev/null +++ b/components/vip-gate/vip-gate.vue @@ -0,0 +1,40 @@ + + + diff --git a/subPackages/sub_business_shared/components/UserPatientDetail.vue b/subPackages/sub_business_shared/components/UserPatientDetail.vue index f52b1e3..0bde474 100644 --- a/subPackages/sub_business_shared/components/UserPatientDetail.vue +++ b/subPackages/sub_business_shared/components/UserPatientDetail.vue @@ -89,6 +89,10 @@ 健康信息