This commit is contained in:
熊丽君
2021-09-01 10:55:59 +08:00
commit 1d6989e2b1
156 changed files with 30472 additions and 0 deletions

39
common/request.js Normal file
View File

@ -0,0 +1,39 @@
const request = (config) => {
uni.showLoading({
title: '数据加载中...',
mask: true
})
// 处理 apiUrl
config.url = 'http://192.168.0.125:1777' + config.url;
if(!config.data){
config.data = {};
}
// if (config.url.indexOf('/distribution') !== -1) {
// config.header = {
// token: uni.getStorageSync('fxToken')
// }
// }
// else if (config.url.indexOf('.do') !== -1) {
// config.header = {
// token: uni.getStorageSync('token')
// }
// }
console.log(JSON.stringify(config.data));
let promise = new Promise(function(resolve, reject) {
uni.request(config).then(responses => {
// 异常
if (responses[0]) {
reject({message : "网络超时"});
} else {
let response = responses[1].data; // 如果返回的结果是data.data的嫌麻烦可以用这个return res,这样只返回一个data
resolve(response);
}
uni.hideLoading()
}).catch(error => {
reject(error);
})
})
return promise;
};
export default request;