--
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', formdat to { 'userId': app.globalData.iuserId }, Success: function (RES) { var Data = the JSON.parse (res.data) // Pit 2: and wx.request different, wx.uploadFile returns [String], into their required JSON format console.log ( ' uploaded successfully ' ) _this.setData ({ // Pit 1: wx.uploadFile this itself has a, so to external var _this = this brought to this headerImageUrl: data.headerImageUrl }) console.log ( ' Refresh success ' ) } }) } }) },
--