This commit is contained in:
wwz
2025-02-10 11:25:48 +08:00
parent 5add1f1282
commit ede860cec3
24 changed files with 2536 additions and 17657 deletions

View File

@@ -1,31 +1,5 @@
import {
fill
} from "lodash"
import store from "../store"
const preCacheKeyClearFetch = 'storage:clear:fetch:'
uni.pro.interceptor('request', {
config(paramOptions) {
let options = Object.assign({}, paramOptions)
options.url = uni.conf.baseUrl + paramOptions.url
this.options = options
return options
},
success(res) {
if (res.data.code == 0) {
return res.data
} else {
return res.data
}
},
fill(err) {
uni.showToast({
title: err.message || err.msg,
icon: "none",
})
}
})
function requestrequest(options) {
return new Promise((resolve, reject) => {
uni.request({
@@ -59,18 +33,10 @@ async function request(options) {
}
try {
if (options.toast) {
// #ifdef MP-WEIXIN || MP-ALIPAY || APP-PLUS
uni.showLoading({
title: '加载中',
mask: true
})
// #endif
// #ifdef H5
uni.pro.showLoading({
title: '加载中',
mask: true
})
// #endif
}
if (options.type == 1) {
options.header = {
@@ -87,7 +53,6 @@ async function request(options) {
// #endif
// #ifdef MP-ALIPAY
environment: 'alipay',
// environment: 'alipay',
// #endif
token: uni.cache.get('token'),
openId: uni.cache.get('miniAppOpenId'),
@@ -98,13 +63,8 @@ async function request(options) {
} else {
}
// #ifdef MP-WEIXIN || MP-ALIPAY || APP-PLUS
options.url = uni.conf.baseUrl + options.url
let res = await requestrequest(options);
// #endif
// #ifdef H5
let res = await uni.pro.request(options);
// #endif
if (res.code != 0) {
if (res.code == -4) {
// uni.showToast({
@@ -116,9 +76,8 @@ async function request(options) {
// // }, 1000)
// }
// })
uni.$u.throttle(store.dispatch("loginEvent"), 1000); //获取shapid
} else if (res.code == 482) {
let nowTime = new Date() / 1000 | 0
let offset = parseInt(res.data.message) - parseInt(nowTime);
@@ -131,9 +90,7 @@ async function request(options) {
success: () => {
setTimeout(res => {
if (options.toast) {
// #ifndef MP-WEIXIN || MP-ALIPAY
uni.pro.hideLoading()
// #endif
}
}, 2000)
}