From 9904175cc3c7b9449a27d2b0ef7758fef4205438 Mon Sep 17 00:00:00 2001 From: YangWork Date: Fri, 10 Feb 2023 18:07:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8C=81=E7=BB=AD=E5=AE=8C=E5=96=84=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E4=BF=A1=E6=81=AF...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: YangWork --- common/ajax.js | 42 +++++++++++--------- components/ywx-auth-model/ywx-auth-model.vue | 34 +++++++++------- pages/tabbar/my/my.vue | 12 +++--- store/modules/user.js | 11 ++++- 4 files changed, 60 insertions(+), 39 deletions(-) diff --git a/common/ajax.js b/common/ajax.js index fe37d6b..7ddcc38 100644 --- a/common/ajax.js +++ b/common/ajax.js @@ -5,32 +5,38 @@ import ajax from '@/uni_modules/u-ajax' // 创建请求实例 const instance = ajax.create({ - // 初始配置 - baseURL: 'https://dev.xixingwl.cn/api' + // 初始配置 + baseURL: 'https://dev.xixingwl.cn/api' }) // 添加请求拦截器 instance.interceptors.request.use( - config => { - // 在发送请求前做些什么 - return config - }, - error => { - // 对请求错误做些什么 - return Promise.reject(error) - } + config => { + // 在发送请求前做些什么 + return config + }, + error => { + // 对请求错误做些什么 + return Promise.reject(error) + } ) // 添加响应拦截器 instance.interceptors.response.use( - response => { - // 对响应数据做些什么 - return response.data - }, - error => { - // 对响应错误做些什么 - return Promise.reject(error) - } + response => { + if (response.statusCode == 200) { + + return response.data + } + // 对响应数据做些什么 + console.log(response) + + return response.data + }, + error => { + // 对响应错误做些什么 + return Promise.reject(error) + } ) // 导出 create 创建后的实例 diff --git a/components/ywx-auth-model/ywx-auth-model.vue b/components/ywx-auth-model/ywx-auth-model.vue index a2badfe..fcd8f61 100644 --- a/components/ywx-auth-model/ywx-auth-model.vue +++ b/components/ywx-auth-model/ywx-auth-model.vue @@ -54,22 +54,23 @@