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 }}条,每页 - - - - 条 - - - 跳至 - - 页 - - - - - - - - - - - - - - - - - - - -