微信小程序多图上传

uploadFile:function (imgArr,data){
      var _this = this,
        i = imgArr.i ? imgArr.i : 0;
        if (i == 0 && imgArr.length > 0) {
          wx.showLoading({
            title: '上传中',
          })

        }else{
return ;
} wx.uploadFile({ url:
'urp', filePath: imgArr[i], name: 'file', header: { 'Content-type': 'multipart/form-data' // 默认值 }, formData: { data: JSON.stringify(data) }, success(res) { var resCode = JSON.parse(res.data) if (resCode.msg == 'ok') { i++; if (i == imgArr.length) { wx.hideLoading({ success:function(){ wx.showToast({ title: '提交成功', icon: 'success', duration: 1000, success:function(){ setTimeout(function(){ wx.navigateBack({ delta: 1 }) },1000) } }) } }) }else{ imgArr.i = i; _this.uploadFile(imgArr,id,requstType) } }else{ wx.showToast({ title: '上传失败', icon: 'fail', duration: 1000, }) } } })
posted @ 2019-09-26 16:14  AINIJJ  阅读(207)  评论(0编辑  收藏  举报