From 361f2955fc2d73537e9c6ea27c8aaa13cfa2ac0f Mon Sep 17 00:00:00 2001 From: donghaolin <17667510818@163.com> Date: Thu, 5 Dec 2024 13:54:19 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=99=E6=98=AF=E5=8A=A0=E4=BA=86token?= =?UTF-8?q?=E6=8B=A6=E6=88=AA=E8=BF=98=E6=9C=89=E9=80=9A=E8=BF=87token?= =?UTF-8?q?=E8=8E=B7=E5=8F=96=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vue/gold-system/src/util/http.js | 20 +- vue/gold-system/src/views/audit/rechargeAudit.vue | 1020 ++++++++++++-------- vue/gold-system/src/views/audit/refundAudit.vue | 981 +++++++++++-------- vue/gold-system/src/views/consume/addConsume.vue | 39 +- vue/gold-system/src/views/consume/allConsume.vue | 21 +- vue/gold-system/src/views/index.vue | 30 +- vue/gold-system/src/views/login.vue | 6 +- .../src/views/managerecharge/activity.vue | 761 ++++++++------- vue/gold-system/src/views/managerecharge/rate.vue | 52 +- vue/gold-system/src/views/recharge/addRecharge.vue | 33 +- .../src/views/recharge/adminRecharge.vue | 17 +- vue/gold-system/src/views/recharge/allRecharge.vue | 15 +- vue/gold-system/src/views/refund/addRefund.vue | 31 +- vue/gold-system/src/views/refund/allRefund.vue | 27 +- vue/gold-system/src/views/usergold/index.vue | 431 +++++---- 15 files changed, 2047 insertions(+), 1437 deletions(-) diff --git a/vue/gold-system/src/util/http.js b/vue/gold-system/src/util/http.js index 07c2402..2d4e309 100644 --- a/vue/gold-system/src/util/http.js +++ b/vue/gold-system/src/util/http.js @@ -3,10 +3,10 @@ import axios from 'axios'; export default function (options) { //配置每次发送请求都从localStorage中获取名字叫token的数据, //添加到请求头部的Authorization属性中 - + const token = localStorage.getItem('token'); //Object.assign用于合并对象的数据 options.headers = Object.assign( - { Authorization: localStorage.getItem('token') }, + { token: token }, options.headers || {} ); //axios() 返回一个promise对象,用于异步请求 @@ -22,11 +22,21 @@ export default function (options) { if (status == 200) { return data; } else { - throw new Error(statusText); + throw new e(statusText); } }) .catch(e=>{ + // 检查是否是因为token过期导致的401错误 + if (e.response && e.response.status === 401) { + // 清除localStorage中的token + localStorage.removeItem('token'); + // 执行重新登录的逻辑,例如跳转到登录页面 + window.location.href = '/login'; + // 可以在这里返回一个特定的值或者对象,以便调用者知道需要重新登录 + return { needsLogin: true }; + } else { + // 其他类型的错误,直接抛出 return Promise.reject(e); - //return Promise.reject(e.message); - }); + } + }); } \ No newline at end of file diff --git a/vue/gold-system/src/views/audit/rechargeAudit.vue b/vue/gold-system/src/views/audit/rechargeAudit.vue index 86ecc19..fd51ff2 100644 --- a/vue/gold-system/src/views/audit/rechargeAudit.vue +++ b/vue/gold-system/src/views/audit/rechargeAudit.vue @@ -1,17 +1,18 @@ - - - - - - - 活动名称: - - - - - - - - 支付方式: - - - - - - - - - 所属地区: - - - - - - - - - - 充值时间: - - 今 - 昨 - 近7天 - - - - - 重置 - 查询 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 已通过 - - - - - - 待审核 - - - - - - 已驳回 - - - - - - - - {{ moment(scope.row.rechargeTime).format('YYYY-MM-DD HH:mm:ss') }} - - - - - - - - - - 通过 - - - - 取消 - - 确定 - - - - - 驳回 - - - - - - - - - - - - 共{{ total }}条,每页 - - - - 条 - - - 跳至 - - 页 - - - - - - - - - - - - - - - - - - - -