/**
|
* @param {string} url url地址
|
* @param {any} postData 参数
|
* @param {string} method 请求方式
|
* @param {boolean} hideLoading 是否load
|
* @description: 格式化时间
|
*/
|
export function request(url, postData, method = 'POST', hideLoading = 'false') {
|
if (!hideLoading) {
|
uni.showLoading({
|
title: '请稍候...',
|
mask: true
|
})
|
}
|
return new Promise((resolve, reject) => {
|
const token = uni.getStorageSync('token');
|
// const URL = 'http://47.76.147.249:8080/rsf-server/pda' + url;
|
// const URL = 'http://test.zoneyung.net:8080/rsf-server/pda' + url;
|
let baseUrl = uni.getStorageSync('baseUrl');
|
if (!baseUrl) {
|
baseUrl = 'http://127.0.0.1:8085/rsf-server/pda';
|
}
|
const URL = baseUrl + url;
|
uni.request({
|
url: URL,
|
data: postData,
|
header: {
|
'content-type': 'application/json',
|
'authorization': token
|
},
|
method: method, //'GET','POST'
|
dataType: 'json',
|
success: (res) => {
|
!hideLoading && uni.hideLoading()
|
resolve(res.data)
|
|
},
|
fail: (res) => {
|
// !hideLoading && toast("网络不给力,请稍后再试~")
|
//wx.hideLoading()
|
reject(res)
|
}
|
})
|
})
|
}
|