|
@@ -86,6 +86,7 @@
|
|
|
import speak from '@/utils/speaks.js';
|
|
|
let ALog = uni.requireNativePlugin("AndroidLog");
|
|
|
let device = uni.requireNativePlugin("DeviceInfo");
|
|
|
+ let ocr = uni.requireNativePlugin("OcrPlug");
|
|
|
//#endif
|
|
|
export default {
|
|
|
data() {
|
|
@@ -221,55 +222,64 @@
|
|
|
},
|
|
|
getPic(){
|
|
|
let that = this;
|
|
|
- uni.chooseImage({
|
|
|
- count: 1, //默认9
|
|
|
- sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
- sourceType: ['camera'], //
|
|
|
- success: function (res) {
|
|
|
- console.log('img',res)
|
|
|
- that.confirmData.carImg = res.tempFilePaths[0];
|
|
|
- uni.showLoading({});
|
|
|
- const tempFilePaths = res.tempFilePaths;
|
|
|
- // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
|
|
|
- uni.uploadFile({
|
|
|
- url: `${that.config.fileUrl}/baidu/ocr`,
|
|
|
- filePath: tempFilePaths[0],
|
|
|
- name: 'file',
|
|
|
- formData: {
|
|
|
- 'isUpload': '1' // 上传附带参数
|
|
|
- },
|
|
|
- success: (res) => {
|
|
|
- // 根据接口具体返回格式 赋值具体对应url
|
|
|
- // alert(uploadFileRes.data);
|
|
|
- let resobj=eval("("+res.data+")");
|
|
|
- uni.hideLoading();
|
|
|
- if(resobj.code==200){
|
|
|
- console.log(resobj);
|
|
|
- //#ifdef APP-PLUS
|
|
|
- speak(resobj.data.vehicleNo);
|
|
|
- //#endif
|
|
|
- that.confirmData.vehicleNo = resobj.data.vehicleNo;
|
|
|
- that.confirmData.vehicleClor = resobj.data.vehicleClor;
|
|
|
- that.confirmData.vehicleImage = resobj.data.url;
|
|
|
- console.log('that.confirmData',that.confirmData);
|
|
|
- }else{
|
|
|
- that.$refs.uToast.show({
|
|
|
- title: resobj.msg,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- };
|
|
|
- console.log('resobj',resobj);
|
|
|
- },
|
|
|
- fail: (err) => {
|
|
|
- that.$refs.uToast.show({
|
|
|
- title:err.msg,
|
|
|
- type: 'error'
|
|
|
- });
|
|
|
- uni.hideLoading();
|
|
|
- }
|
|
|
- });
|
|
|
+ ocr.ocrVehicleNo((ret) => {
|
|
|
+ if (ret.success){
|
|
|
+ that.confirmData.vehicleNo = ret.vehicleNo;
|
|
|
+ //that.vehicleImage = 'data:image/png;base64,' + ret.imageBase64;
|
|
|
+ // speak('成功识别车牌' + ret.vehicleNo);
|
|
|
+ }else {
|
|
|
+ plus.nativeUI.toast('识别失败');
|
|
|
}
|
|
|
});
|
|
|
+ // uni.chooseImage({
|
|
|
+ // count: 1, //默认9
|
|
|
+ // sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
+ // sourceType: ['camera'], //
|
|
|
+ // success: function (res) {
|
|
|
+ // console.log('img',res)
|
|
|
+ // that.confirmData.carImg = res.tempFilePaths[0];
|
|
|
+ // uni.showLoading({});
|
|
|
+ // const tempFilePaths = res.tempFilePaths;
|
|
|
+ // // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
|
|
|
+ // uni.uploadFile({
|
|
|
+ // url: `${that.config.fileUrl}/baidu/ocr`,
|
|
|
+ // filePath: tempFilePaths[0],
|
|
|
+ // name: 'file',
|
|
|
+ // formData: {
|
|
|
+ // 'isUpload': '1' // 上传附带参数
|
|
|
+ // },
|
|
|
+ // success: (res) => {
|
|
|
+ // // 根据接口具体返回格式 赋值具体对应url
|
|
|
+ // // alert(uploadFileRes.data);
|
|
|
+ // let resobj=eval("("+res.data+")");
|
|
|
+ // uni.hideLoading();
|
|
|
+ // if(resobj.code==200){
|
|
|
+ // console.log(resobj);
|
|
|
+ // //#ifdef APP-PLUS
|
|
|
+ // speak(resobj.data.vehicleNo);
|
|
|
+ // //#endif
|
|
|
+ // that.confirmData.vehicleNo = resobj.data.vehicleNo;
|
|
|
+ // that.confirmData.vehicleClor = resobj.data.vehicleClor;
|
|
|
+ // that.confirmData.vehicleImage = resobj.data.url;
|
|
|
+ // console.log('that.confirmData',that.confirmData);
|
|
|
+ // }else{
|
|
|
+ // that.$refs.uToast.show({
|
|
|
+ // title: resobj.msg,
|
|
|
+ // type: 'error'
|
|
|
+ // });
|
|
|
+ // };
|
|
|
+ // console.log('resobj',resobj);
|
|
|
+ // },
|
|
|
+ // fail: (err) => {
|
|
|
+ // that.$refs.uToast.show({
|
|
|
+ // title:err.msg,
|
|
|
+ // type: 'error'
|
|
|
+ // });
|
|
|
+ // uni.hideLoading();
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // }
|
|
|
+ // });
|
|
|
},
|
|
|
confirmIn(){
|
|
|
let files = [];
|