위챗 애플릿 wx.uploadFile의 두 개의 구덩이

2925 단어
setImage:function(e){
    var _this = this  // 1
    wx.chooseImage({
      count: 1, 
      sizeType: ['original', 'compressed'], 
      sourceType: ['album', 'camera'], 
      success: function (res) {
        var tempFilePaths = res.tempFilePaths
        console.log(tempFilePaths)
        wx.uploadFile({
          url: app.globalData.myhost+'customer-header?access_token='+app.globalData.itoken,
          filePath: tempFilePaths[0],
          name: 'uploadFile',
          formData: {
            'userId': app.globalData.iuserId
          },
          success: function (res) {var data = JSON.parse(res.data)  // 2: wx.request ,wx.uploadFile [ ], JSON 
            console.log(' ')
            _this.setData({    // 1:wx.uploadFile this, var _this = this  this 
              headerImageUrl: data.headerImageUrl
            })
            console.log(' ')
          }
        })
      }
    })
  },

좋은 웹페이지 즐겨찾기