问题模块 框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
API和组件 微信小程序 Bug wx.showLoading 客户端 6.7.2 2.2.3
网络请求回调,还没成功就已经 hide 了,为什么 ???
wx.showLoading({
title: '请稍等...',
mask: true
})
//开始上传
if (length == 0) {
//无图片的上传
// 上传参数
var params = {
coach_code: that.data.coach_code,
uc_code: uc_code,
tag_codes: that.data.tag_codes,
content: content,
imgs: [],
avatar:avatar,
name:name
};
that.onSending(params);
}else{
this.data.filePaths.forEach(function (value, index){
wx.uploadFile({
url: config.upload_url,
filePath: value,
name: config.upload_name,
sizeType: "compressed",
success: function (res) {
count++;
clouds.push(JSON.parse(res.data).response.cloud);
if (count == length) {
// 上传参数
var params = {
coach_code: that.data.coach_code,
uc_code: uc_code,
tag_codes: that.data.tag_codes,
content: content,
imgs: clouds,
avatar:avatar,
name:name
};
that.onSending(params);
}
},
fail:function(fail){
wx.hideLoading();
wx.showModal({
title: '提示',
content: '图片上传出错',
showCancel:true
})
that.setData({
can_sub: true
});
}
});
});
}
},
/**
* 执行上传操作
*/
onSending:function(params){
var that = this;
api.request(config.Comment_create,params, function (res) {
wx.hideLoading();
console.log("----回来了");
if (res.data.code == 0) {
wx.redirectTo({
url: "../comment_success/comment_success?coach_code="+that.data.coach_code
});
} else {
wx.showModal({
title: "提示",
showCancel: false,
content: res.data.message
});
that.setData({
can_sub: true
});
}
},function(fail){
wx.hideLoading();
wx.showToast({
title: '网络好像出问题了',
icon:"none"
});
that.setData({
can_sub: true
});
},function(complete){
//操作完可再次点击
});
},
微信小程序开发问题解答
微信小程序开发者回答:
你的代码看起来,只要有一个成功了,就hide了呀。你是想等全部成功了hide吗
微信小程序开发者回答:
代码没看
不过一般都是异步问题
Promise 了解下
微信小程序开发者回答:
能说详细点吗,谢谢
微信小程序开发者回答:
https://developers.weixin.qq.com/community/develop/doc/00064cebd241a8c03567f621951000?highLine=Promise
本文网址:http://www.91bianli.com/weixinxiaochengxu/45213.html