记录一下文件的上传
submit(){
this.getammeternumber(this.data.list,0,this.data.list.length);
},
// 使用递归的方法去上传图片
getammeternumber:function(fileList,i,length){
var that = this;
var imgUrl = fileList[i];
wx.uploadFile({
//上传图片的网路请求地址
url: app.globalData.imgTestUrl + 'api/files',
filePath: imgUrl,
name: 'file',
success: function (res) {
if (++i< length) {
that.getammeternumber(type,fileList, i, length);
}else{
console.log("图片上传结束!")
return false;
}
},
fail: function (res) {
console.log(res);
that.tishiBox('tips',res.errMsg)
}
});
},
//预览图片
showImg:function(e){
var that=this;
wx.previewImage({
urls: that.data.list,
current: that.data.list[e.currentTarget.dataset.index]
})
},