uploadImage(index){
let that=this;
wx.cloud.uploadFile({
cloudPath:'drinkImages/' + new Date().getTime() + "_" + Math.floor(Math.random()*1000) + ".jpg",
filePath:that.data.imgList[index],
success: res => {
console.log("上传成功",res.fileID);
that.data.imagesSuccessList[index] = res.fileID;
that.data.imagesSuccessCount = that.data.imagesSuccessCount + 1;
if(that.data.imagesSuccessCount == that.data.imgList.length){
console.log("上传成功:", that.data.imagesSuccessList);
that.uploadData();
wx.hideLoading();
} else {
that.uploadImage(index+1);
}
},
fail: err =>{
wx.hideLoading();
console.log("上传失败",err);
that.setData({
imagesSuccessList:[],
imagesSuccessCount: 0
})
wx.showToast({
icon:'none',
title: '上传失败,请重新上传',
})
}
})
},