收藏
回答

takePhoto点击报错说未定义并且无法拍照?

takePhoto()

{

var that = this;

this.ctx.takePhoto

({

quality: 'high',

success:(res)=>

{

this.setData

({

src:res.tempImagePath

})

/******上传识别图片*******/

wx.showLoading

({

title: '识别中...',

})

var tempFilePaths = res.tempImagePath

wx.uploadFile

({

url: app.globalData.serverUrl + '/c-paizhao/api.php?action=upimg',

header: { "Content-Type": "multipart/form-data" },

filePath: tempFilePaths,

name: encodeURI('img'),

formData:

{

uid: encodeURI('test')

},

success(res) {

console.log(res)

var dataarr = JSON.parse(res.data);

//console.log(dataarr);

that.setData({ itemdata: dataarr.result })

//that.data.itemdata = dataarr.result;

},

fail: function (error)

{

wx.hideLoading();

wx.showToast

({

title: '请求超时',

icon: 'loading',

duration: 2000

});

console.log(error)

},

complete: function ()

{

wx.hideLoading();

}

})

}

})

},


最后一次编辑于  2019-12-17
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容
问题标签