if (_self.needUploadImgs.length == 0) {} else {
uni.showLoading({
title: "图片上传中"
})
for (var i = 0; i < _self.needUploadImgs.length; i++) {
uni.uploadFile({
url: apis.ceshi + '/operation/patrol/upload2',
filePath: _self.needUploadImgs[i],
fileType: "image",
name: "upfile",
formData: {
"pointId": _self.pointId,
"patrolId": _self.patrolId
},
header: {
'token': _self.uerInfo.token //自定义请求头信息
},
success: function(res) {
console.log("----", res);
console.log("----1", i);
console.log("----2", _self.needUploadImgs.length);
if ( _self.needUploadImgs.length==i ) {
uni.hideLoading();
uni.showToast({
title: "图片上传成功",
duration: 3000,
icon: 'none'
})
}
},
fail: err => {
uni.showToast({
title: "图片上传失败:" + err,
duration: 3000,
icon: 'none'
})
console.log(err);
}
});
}
?记得让后端根据ID获取拼接
|