重构第一版 智控助手小程序
This commit is contained in:
@@ -2,29 +2,34 @@
|
||||
let show = 0;
|
||||
export default async function reqeust(params) {
|
||||
show++;
|
||||
return new Promise((resolve, reject) => {
|
||||
|
||||
// 判断是否需要显示loading弹窗
|
||||
const needLoading = params.title !== undefined && params.title !== null && params.title !== '';
|
||||
|
||||
if (needLoading) {
|
||||
wx.showLoading({
|
||||
title: params.title,
|
||||
mask:true
|
||||
})
|
||||
wx.request({
|
||||
mask: true
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
wx.request({
|
||||
header: {
|
||||
contentType: 'application/x-www-form-urlencoded', // 填入服务名称
|
||||
},
|
||||
contentType: 'application/x-www-form-urlencoded', // 填入服务名称
|
||||
},
|
||||
url: params.url,
|
||||
method: params.method || 'post',
|
||||
data: params.data || {},
|
||||
success: res => {
|
||||
resolve(res.data)
|
||||
resolve(res.data)
|
||||
},
|
||||
fail: err => {
|
||||
reject(err)
|
||||
},
|
||||
complete:()=>{
|
||||
show--;
|
||||
if(show==0){
|
||||
wx.hideLoading()
|
||||
if (needLoading && show === 0) {
|
||||
wx.hideLoading();
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user