From 36a50f1cda1f1d535ea74353e669ba3e64257a3c Mon Sep 17 00:00:00 2001 From: WindowBird <13870814+windows-bird@user.noreply.gitee.com> Date: Mon, 22 Sep 2025 10:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E9=98=B2=E6=8A=96=E5=A4=84?= =?UTF-8?q?=E7=90=86=E8=BF=87=E6=9C=9F=E5=BC=B9=E7=AA=97=E7=9A=84=E9=87=8D?= =?UTF-8?q?=E5=A4=8D=E5=BC=B9=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/request.js | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/utils/request.js b/utils/request.js index 2e3fdfc..94a7b68 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,11 +1,13 @@ // 统一请求工具 import { getAppId, getTempToken, shouldUseTempToken } from "@/config/dev.js"; +import debounce from "uview-ui/libs/function/debounce"; // 环境配置 const ENV_CONFIG = { release: { // 正式版 - baseUrl: "http://192.168.2.158:4501", + // baseUrl: "http://192.168.2.158:4501", + baseUrl: "https://tech-ape.top/prod-api", appId: 1, }, }; @@ -167,22 +169,10 @@ export function request(options = {}) { success: (res) => { // 隐藏加载状态 - // 请求成功处理 + console.log("@@@@@@@@@@@@@", res); if (res.statusCode === 200) { if (res.data.code === 401) { - uni.showModal({ - title: "登录已过期", - content: "请先登录后再进行操作", - confirmText: "去登录", - cancelText: "取消", - success: (res) => { - if (res.confirm) { - uni.navigateTo({ - url: "/pages/login/login", - }); - } - }, - }); + Expired(); } resolve(res.data); } else { @@ -221,6 +211,25 @@ export function request(options = {}) { reject(err); }, }; + const Expired = () => { + debounce( + function () { + uni.showModal({ + title: "登录已过期", + content: "请先登录后再进行操作", + confirmText: "去登录", + cancelText: "取消", + success: (res) => { + if (res.confirm) { + uni.navigateTo({ url: "/pages/login/login" }); + } + }, + }); + }, + 1000, + true, + ); + }; // 特殊接口处理(不需要token的接口) const noTokenUrls = ["/wxLogin", "/user/login"];