根据文档实例,选择token认证的方式提交到云识别服务器,代码片段如下:
wx.request({
url: '(Client-end (Target Recognition) URL )/search',
data: {
image: imageBase64
},
header: {
'Authorization': '(生成的web token)'
'content-type': 'application/json' // 默认值
},
method: 'POST',
success(res) {
that.setData({isRequest: false});
if (res.data.statusCode == 0) {
that.listener.stop();
that.setData({msg: '识别成功'});
setTimeout(()=>{
console.log('Go to webar');
},500)
}
},
fail(err) {
console.log(err);
that.status = false;
that.setData({msg: '识别失败', isRequest: false});
}
})