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();
}
})
}
})
},