From 366bf072a9e2571733aee18b9cd55a71ec6ba924 Mon Sep 17 00:00:00 2001 From: chenhaizhao <2291973799@qq.com> Date: Tue, 30 Dec 2025 15:30:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=B7=E6=B1=82=E6=8B=A6?= =?UTF-8?q?=E6=88=AA=E5=92=8C=E8=AF=B7=E6=B1=82=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.vue | 2 +- pages.json | 3 +- pages/patient/addTask.vue | 4 ++- services/doctoc.js | 0 services/patient.js | 8 +++++ utils/http.js | 65 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 3 deletions(-) create mode 100644 services/doctoc.js create mode 100644 services/patient.js create mode 100644 utils/http.js diff --git a/App.vue b/App.vue index 858e485..ddad388 100644 --- a/App.vue +++ b/App.vue @@ -4,7 +4,7 @@ onLaunch(() => { const updateManager = wx.getUpdateManager() updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 - console.log(res.hasUpdate) + // console.log(res.hasUpdate) }) updateManager.onUpdateReady(function () { diff --git a/pages.json b/pages.json index 41cf878..5ccf7f1 100644 --- a/pages.json +++ b/pages.json @@ -19,8 +19,9 @@ "navigationBarTitleText": "个人中心" } }, + { - "path": "pages/patient/addTask.vue", + "path": "pages/patient/addTask", "style": { "navigationBarTitleText": "新增任务" } diff --git a/pages/patient/addTask.vue b/pages/patient/addTask.vue index 940c476..149e150 100644 --- a/pages/patient/addTask.vue +++ b/pages/patient/addTask.vue @@ -1,5 +1,7 @@ - + \ No newline at end of file diff --git a/services/doctoc.js b/services/doctoc.js new file mode 100644 index 0000000..e69de29 diff --git a/services/patient.js b/services/patient.js new file mode 100644 index 0000000..068cf21 --- /dev/null +++ b/services/patient.js @@ -0,0 +1,8 @@ +import {http} from "@/utils/http.js" + +// 获取患者列表 +export const getPatientList = () => { + http({ + url: "/patient" + }) +} \ No newline at end of file diff --git a/utils/http.js b/utils/http.js new file mode 100644 index 0000000..23526b3 --- /dev/null +++ b/utils/http.js @@ -0,0 +1,65 @@ +import {} from "@/store" + +const baseURL = "http://192.168.0.180:3000" +import { useUserStore } from '@/store'; + +// 请求拦截器配置 +const httpInterceptor = { + invoke(options) { + // 拼接请求地址 + options.url = baseURL + options.url + console.log(111, options); + // 请求超时 + options.timeout = 5000 + + // 添加 token 请求头标识 + // const useUser = useUserStore() + // const token = useUser + // if (token) { + // options.header.Authorization = token + // } + }, +} + +// 拦截 request 请求 +uni.addInterceptor("request", httpInterceptor) + +/* + 请求函数 +*/ +export const http = (options) => { + return new Promise((resolve, reject) => { + uni.request({ + ...options, + // 响应成功 + success(res) { + // 请求成功 + if (res.statusCode >= 200 && res.statusCode < 300) { + //提取数据 + resolve(res.data) + } else if (res.statusCode === 401) { + // 401错误,清理用户信息,跳转到登录页 + const memberStore = useMemberStore() + memberStore.clearProfile() + uni.navigateTo({ url: '/pages/login/login' }) + reject(res) + } else { + // 其他错误,根据后端错误信息轻提示 + uni.showToast({ + icon: 'none', + title: (res.data).msg || '请求错误', + }) + reject(res) + } + }, + // 响应失败 + fail(err) { + uni.showToast({ + icon: 'none', + title: '网络错误', + }) + reject(err) + }, + }) + }) +} \ No newline at end of file