scan() {
let _th = this;
uni.chooseImage({
count: 1, //默认9
sizeType: ["original", "compressed"], //可以指定是原图还是压缩图,默认二者都有
sourceType: ["album", "camera"], //从相册选择
success: function(res) {
uni.showLoading({
title: "识别中",
mask: true,
});
// console.log(res.tempFilePaths[0]);//成功则返回图片的本地文件路径列表 tempFilePaths
uni.uploadFile({//将本地资源上传到开发者服务器
url:'http://xxxx.com', //接口地址
filePath: res.tempFilePaths[0],//图片地址
name: 'file',
success: (uploadFileRes) => {
// console.log('uploadFileRes===',uploadFileRes)
let data = JSON.parse(uploadFileRes.data)
if(data.data.path_url){
let image_path = data.data.path_url;
postData('/shipment/sacn_code_for_db',{image_path}).then(res=>{
// console.log('res === ',res)
if(res.data.product_code){
getData('/rework/rework_detail',{params:{rework_id: '',product_code: res.data.product_code}}).then(r => {
// console.log('r ===' ,r)
if(r.code == 200){
uni.hideLoading()
_th.$Router.push({
path: '/repair_detail',
query: {
rework_id: '',
product_code: res.data.product_code
},
})
} else {
uni.hideLoading()
_th.show = true
}
})
} else {
uni.hideLoading()
}
})
} else {
uni.hideLoading()
}
},
fail() {
uni.hideLoading()
}
});
},
fail() {
uni.hideLoading()
}
});
}
uni upload image
于 2022-10-20 15:08:12 首次发布