uploadImage(successBack) {
uni.showToast({
icon: 'loading',
title: "正在添加"
});
this.uploadMoreImage([], 0, this.imgList.length, data => {
uni.hideToast();
successBack(data);
}, () => {
CommonUtils.showToast("上传失败");
uni.hideToast();
})
},
uploadMoreImage(backImgeUrl, index, length, successBack, errorBack) {
uni.uploadFile({
url: api.UPLOAD_IMAGE_URL, //仅为示例,非真实的接口地址
filePath: this.imgList[index],
name: 'file',
success: (uploadFileRes) => {
console.log(uploadFileRes.data);
index++;
if (index >= length) {
backImgeUrl.push(JSON.parse(uploadFileRes.data).data);
successBack(backImgeUrl);
} else {
backImgeUrl.push(JSON.parse(uploadFileRes.data).data);
this.uploadMoreImage(backImgeUrl, index, length, successBack, errorBack);
}
},
fail: () => {
errorBack();
}
});
},