oil-station/gasStation-uni/request/index.js

42 lines
761 B
JavaScript
Raw Normal View History

2023-11-27 10:42:24 +08:00
// 同时发送异步代码的次数
let ajaxTimes = 0;
export const request = (params) => {
var openid = wx.getStorageSync("openid") || '';
let header = {
...params.header
};
let urls;
if (params.url.indexOf('?')) {
2023-11-27 15:53:33 +08:00
urls = params.url
2023-11-27 10:42:24 +08:00
} else {
2023-11-27 15:53:33 +08:00
urls = params.url
2023-11-27 10:42:24 +08:00
}
// 定义公共的url
// const baseUrl="https://jfsc.lmweixin.com/";
2023-11-27 18:28:41 +08:00
const baseUrl = "http://192.168.1.4:8080/";
2023-11-27 10:42:24 +08:00
return new Promise((resolve, reject) => {
wx.request({
...params,
header: header,
2023-11-27 15:53:33 +08:00
2023-11-27 10:42:24 +08:00
url: baseUrl + urls,
success: (result) => {
resolve(result.data);
},
fail: (err) => {
reject(err);
},
complete: () => {
ajaxTimes--;
if (ajaxTimes === 0) {
// 关闭正在等待的图标
wx.hideLoading();
}
}
});
})
}