首次提交

This commit is contained in:
2023-09-19 15:16:00 +08:00
parent c53397c242
commit 5ff55fd8f1
3 changed files with 47 additions and 0 deletions

View File

5
api/baseurl.js Normal file
View File

@ -0,0 +1,5 @@
// var baseurl = "https://quanyidaojia.xinelu.cn";
var baseurl = "http://192.168.16.76:8080";
// var baseurl = "http://43.143.234.221:8090";
export default baseurl

42
api/request.js Normal file
View File

@ -0,0 +1,42 @@
import baseurl from './baseurl.js'
var request = function(config) {
return new Promise((resolve, rejected) => {
uni.showLoading({
title: ''
});
uni.request({
url: baseurl + config.url,
data: config.data,
method: config.method,
timeout: 10000,
header: {
Authorization: 'Bearer' + ' ' + uni.getStorageSync('token')
},
success(res) {
if (res.data.code == 9999) {
uni.clearStorageSync();
let pages = getCurrentPages();
let path = pages[pages.length - 1].$page.fullPath
let paths = path.split('?')
if (paths == '/pages/integral/integral' || paths ==
'/pages/shopping/shopping' || paths ==
'/pages/coupon/coupon' || paths ==
'/pages/materialbenefits/materialbenefits') {} else {
uni.navigateTo({
url: '/pages/login/login'
})
}
}
uni.hideLoading();
resolve(res.data)
},
fail(err) {
uni.hideLoading();
rejected(err)
}
})
})
}
export default request