|
@@ -1,154 +0,0 @@
|
|
|
-# 接口迁移进度(自动扫描结果)
|
|
|
|
|
-
|
|
|
|
|
-说明:此文档列出当前代码库中发现的直接发起网络请求(`uni.request`)位置,建议将这些请求迁移到 `src/api` 下统一管理。每一项包含:文件路径、发现的后端路径/用途、建议目标 `api` 文件、当前状态与建议操作。
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-## 概览
|
|
|
|
|
-- 扫描方式:在 `src/**` 中查找 `uni.request(...)`。
|
|
|
|
|
-- 发现的页面(不含已在 `src/api` 中的文件):
|
|
|
|
|
- - `src/pages/patient/profile/index.vue`
|
|
|
|
|
- - `src/pages/patient/profile/infos/base-info.vue`
|
|
|
|
|
- - `src/pages/patient/health/details/physical.vue`
|
|
|
|
|
- - `src/pages/patient/index/index.vue`
|
|
|
|
|
- - `src/pages/patient-family/profile/infos/base-info.vue`
|
|
|
|
|
- - `src/pages/patient-family/profile/index.vue`
|
|
|
|
|
- - `src/pages/patient-family/index/index.vue`
|
|
|
|
|
- - `src/pages/doctor/profile/infos/base-info.vue`
|
|
|
|
|
- - `src/pages/public/profile/index.vue`
|
|
|
|
|
- - `src/pages/public/profile/qr/index.vue`
|
|
|
|
|
- - `src/pages/public/login/index.vue`
|
|
|
|
|
-
|
|
|
|
|
-> 注意:`src/api` 目录内的文件(例如 `bloodGlucose.ts`、`bloodPressure.ts`)本身已经在封装请求,这里不再重复列出。
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-## 逐文件详情与建议
|
|
|
|
|
-
|
|
|
|
|
-### 1. `src/pages/patient/profile/infos/base-info.vue`
|
|
|
|
|
-- 发现的后端接口(在文件中直接使用):
|
|
|
|
|
- - `POST https://wx.baiyun.work/user_info`
|
|
|
|
|
- - `POST https://wx.baiyun.work/update_user_info`
|
|
|
|
|
- - `POST https://wx.baiyun.work/user/avatar/upload`(`uni.uploadFile`)
|
|
|
|
|
- - `GET https://wx.baiyun.work/user/avatar/{userId}`(头像下载)
|
|
|
|
|
- - `GET https://wx.baiyun.work/geo/nearest?latitude=...&longitude=...`(地理编码/附近定位)
|
|
|
|
|
-- 建议目标 `api` 文件:`src/api/user.ts`(新增或扩展函数)
|
|
|
|
|
-- 当前状态:已迁移(页面已改为调用 `src/api/user.ts` 中的 `fetchUserInfo`)
|
|
|
|
|
-- 建议操作:
|
|
|
|
|
- 1. 在 `src/api/user.ts` 中添加 `fetchUserInfo()`、`updateUserInfo(payload)`、`uploadAvatar(filePath)`(或 `uploadAvatarFormData`)、`downloadAvatar(userId)`、`geocodeNearest(lat, lon)`。
|
|
|
|
|
- 2. 将页面内的 `uni.request`/`uni.uploadFile`/`uni.downloadFile` 调用替换为导入的 API 函数,并仅在页面内保留 UI 逻辑(loading、提示、表单校验等)。
|
|
|
|
|
-
|
|
|
|
|
- - 当前状态:已迁移(头像上传/下载、地理编码与更新请求均已替换为 `src/api/user.ts` 中的封装;页面保留 UI 逻辑)。
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-### 2. `src/pages/doctor/profile/infos/base-info.vue`
|
|
|
|
|
-- 与患者 `base-info.vue` 内容基本相同,使用的接口也与用户信息相关(`user_info`、头像上传、geo 等)。
|
|
|
|
|
-- 建议目标:`src/api/user.ts`
|
|
|
|
|
-- 当前状态:已迁移(页面已改为调用 `src/api/user.ts` 中的 `fetchUserInfo`)
|
|
|
|
|
-- 建议操作:与第1项相同,统一使用 `user.ts` 中导出的函数。
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-### 3. `src/pages/patient-family/profile/infos/base-info.vue`
|
|
|
|
|
-- 与上面类似,调用 `user_info`、头像上传、geo。建议目标 `src/api/user.ts`。
|
|
|
|
|
- - 当前状态:已迁移(头像上传/下载、地理编码与更新请求均已替换为 `src/api/user.ts` 中的封装;页面保留 UI 逻辑)。
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-### 4. `src/pages/public/profile/index.vue` 和 `src/pages/public/profile/qr/index.vue`
|
|
|
|
|
-- 主要使用 `POST /user_info` 拉取用户信息;`qr` 页面也会拉取 `user_info` 用于生成二维码。
|
|
|
|
|
-- 建议目标:`src/api/user.ts`(函数名例如 `fetchUserInfo`)
|
|
|
|
|
-- 当前状态:已迁移(页面已改为调用 `src/api/user.ts` 中的 `fetchUserInfo`)
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-### 5. `src/pages/public/login/index.vue`
|
|
|
|
|
-- 使用登录流程并调用:`POST https://wx.baiyun.work/get_openid`(后端返回 token/openid)
|
|
|
|
|
-- 建议目标:`src/api/user.ts`(函数名例如 `loginWithWx(code, role)` 或 `getOpenId(code, role)`)
|
|
|
|
|
-- 当前状态:已迁移(已抽离至 `src/api/user.ts`,新增函数 `loginWithWx(code, role)`;`src/pages/public/login/index.vue` 已替换为调用该函数)
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-### 6. `src/pages/patient/index/index.vue`
|
|
|
|
|
-- 页面内调用 `POST /user_info` 并在缺少头像时下载 `GET /user/avatar/{userId}`。
|
|
|
|
|
-- 建议目标:`src/api/user.ts`(`fetchUserInfo`, `downloadAvatar`)
|
|
|
|
|
- - 当前状态:已迁移(页面已改为调用 `src/api/user.ts` 中的 `fetchUserInfo`,并在需要时使用 `downloadAvatar` 封装下载头像)
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-### 7. `src/pages/patient/health/details/physical.vue`
|
|
|
|
|
-- 发现接口:
|
|
|
|
|
- - `POST https://wx.baiyun.work/physical/list`
|
|
|
|
|
- - `POST https://wx.baiyun.work/physical/add`
|
|
|
|
|
- - `POST https://wx.baiyun.work/physical/delete`
|
|
|
|
|
-- 建议目标:新增 `src/api/physical.ts`,包含 `listPhysical`、`addPhysical`、`deletePhysical` 等函数。
|
|
|
|
|
-- 当前状态:未迁移
|
|
|
|
|
-- 当前状态:已迁移(已添加 `src/api/physical.ts` 并替换页面中的 `list/add/delete` 请求)
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-### 8. `src/pages/patient-family/index/index.vue`、`src/pages/patient-family/profile/index.vue`、其它首页和列表页
|
|
|
|
|
-- grep 显示这些文件中也存在 `uni.request` 调用(多数为 `user_info` 或与列表/分页相关的后端接口)。
|
|
|
|
|
-- 建议目标:根据具体接口归类到 `user.ts`、`doctor.ts`、`bloodGlucose.ts`、`bloodPressure.ts`、或新增模块(如 `physical.ts`、`notification.ts` 等)
|
|
|
|
|
- - 当前状态:已迁移(涉及 `user_info` 的调用已改为使用 `src/api/user.ts::fetchUserInfo`;其它接口视情况待迁移)
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-## 推荐新增/调整的 `src/api` 接口函数(示例)
|
|
|
|
|
-- `src/api/user.ts`(扩展)
|
|
|
|
|
- - `export async function fetchUserInfo()`
|
|
|
|
|
- - `export async function updateUserInfo(payload)`
|
|
|
|
|
- - `export async function uploadAvatar(filePath)`
|
|
|
|
|
- - `export async function downloadAvatar(userId)`
|
|
|
|
|
- - `export async function getOpenId(code, role)`
|
|
|
|
|
- - `(保留或兼容现有的 getUserInfo(userId))`
|
|
|
|
|
-
|
|
|
|
|
-- `src/api/physical.ts`(新建)
|
|
|
|
|
- - `export async function listPhysical(params)`
|
|
|
|
|
- - `export async function addPhysical(payload)`
|
|
|
|
|
- - `export async function deletePhysical(id)`
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
-## 迁移示例(把页面内的请求提取到 `src/api/user.ts`)
|
|
|
|
|
-```ts
|
|
|
|
|
-// src/api/user.ts
|
|
|
|
|
-export async function fetchUserInfo() {
|
|
|
|
|
- const token = uni.getStorageSync('token')
|
|
|
|
|
- const res: any = await uni.request({
|
|
|
|
|
- url: 'https://wx.baiyun.work/user_info',
|
|
|
|
|
- method: 'POST',
|
|
|
|
|
- header: { 'content-type': 'application/json', Authorization: `Bearer ${token}` },
|
|
|
|
|
- data: {}
|
|
|
|
|
- })
|
|
|
|
|
- return res
|
|
|
|
|
-}
|
|
|
|
|
-```
|
|
|
|
|
-
|
|
|
|
|
-页面中的调用替换为:
|
|
|
|
|
-```ts
|
|
|
|
|
-import { fetchUserInfo } from '@/api/user'
|
|
|
|
|
-
|
|
|
|
|
-const resp = await fetchUserInfo()
|
|
|
|
|
-// 只在页面处理 UI(loading、跳转、toast)与数据映射
|
|
|
|
|
-```
|
|
|
|
|
-
|
|
|
|
|
-## 建议迁移流程(小规模、安全)
|
|
|
|
|
-- 优先迁移全局或复用率高的用户相关接口(`user_info`、登录、头像等),因为多个页面复用了这些调用。
|
|
|
|
|
-- 为每个被迁移的接口:
|
|
|
|
|
- 1. 在 `src/api` 中添加函数并导出,写好入参/返回类型注释(TypeScript)。
|
|
|
|
|
- 2. 在页面中导入新函数,替换原来的 `uni.request` 调用,保留页面的 UI/错误处理逻辑。
|
|
|
|
|
- 3. 运行项目(或编译/类型检查)验证不会破坏页面行为。
|
|
|
|
|
-- 对于上传/下载文件(`uni.uploadFile`/`uni.downloadFile`),建议把真正的网络操作封装在 `api` 中,但可以选择让页面传递 `filePath` 并由 API 返回解析后的结果。
|
|
|
|
|
-
|
|
|
|
|
-## 后续建议/可选项
|
|
|
|
|
-- 我可以为你:
|
|
|
|
|
- - (1)自动在 `src/api/user.ts` 中添加上面列出的函数骨架并替换某些页面的调用(逐文件进行,先做 `base-info.vue` 或 `login.vue`);
|
|
|
|
|
- - (2)生成一个更详细的迁移计划(含优先级与变更 PR 模板);
|
|
|
|
|
- - (3)写一个简单的 codemod(大量替换时谨慎使用)。
|
|
|
|
|
-
|
|
|
|
|
----
|
|
|
|
|
-
|
|
|
|
|
-> 注:本次扫描仅基于 `uni.request` 的静态文本搜索,未检测动态构造的请求函数、第三方库封装(如 `axios`、自定义 `request` helper)或服务端渲染调用。若项目中存在其他请求模式,请告知我以扩展扫描策略。
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|