From 5fe11de0ada52e3df77770c6e18209e773a6ddba Mon Sep 17 00:00:00 2001 From: hflllll Date: Tue, 16 Sep 2025 19:26:39 +0800 Subject: [PATCH] =?UTF-8?q?'=E4=BF=AE=E6=94=B9request.js'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/request.js | 24 ++++++++++++++++++------ config/index.js | 12 ++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/api/request.js b/api/request.js index 9255aa3..403518b 100644 --- a/api/request.js +++ b/api/request.js @@ -16,6 +16,9 @@ export default function request ( { if (token) { header['X-Access-Token'] = token }else { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: '请先登录', icon: 'none' @@ -40,6 +43,9 @@ export default function request ( { if (res.statusCode === 200 && res.data) { // 业务成功 if (res.data.code === 200 ) { + if (showLoading) { + uni.hideLoading() + } resolve(res.data) return } @@ -48,9 +54,13 @@ export default function request ( { const errorMsg = res.data.message || '请求失败' if (showToast) { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: errorMsg, - icon: 'none' + icon: 'none', + duration: 3000 }) } reject({ @@ -82,6 +92,9 @@ export default function request ( { break; } if (showToast) { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: error.message, icon: 'none' @@ -93,6 +106,9 @@ export default function request ( { console.log(`Fail ${method} ${url}`, err); const errorMsg = err.errMsg || '请求失败' if (showToast) { + if (showLoading) { + uni.hideLoading() + } uni.showToast({ title: errorMsg, icon: 'none' @@ -105,11 +121,7 @@ export default function request ( { data: err }) }, - complete: () => { - if (showLoading) { - uni.hideLoading() - } - } + }) }) } \ No newline at end of file diff --git a/config/index.js b/config/index.js index 151cb33..2efa37d 100644 --- a/config/index.js +++ b/config/index.js @@ -12,7 +12,7 @@ const envParam = { prod: 'production', } -const env = envParam['prod'] +const env = envParam['test'] // 全局配置 const config = { @@ -46,11 +46,11 @@ const config = { staticDomain: 'https://image.hhlm1688.com/' }, production: { - aliOSS_accessKey: 'LTAI5tRqoxbC9BKrWJduKDVT', - aliOSS_secretKey: 's5ANiOq4kYpzuMLQhqPMYL4IybMR7L', - aliOSS_bucketName: 'mulinyouni', - endpoint: 'oss-cn-beijing.aliyuncs.com', - staticDomain: 'https://image.mulinyouni.com/' + aliOSS_accessKey: 'LTAI5tQSs47izVy8DLVdwUU9', + aliOSS_secretKey: 'qHI7C3PaXYZySr84HTToviC71AYlFq', + aliOSS_bucketName: 'hanhaiimage', + endpoint: 'oss-cn-shenzhen.aliyuncs.com', + staticDomain: 'https://image.hhlm1688.com/' }, },