|
@@ -1,6 +1,6 @@
|
|
<template>
|
|
<template>
|
|
<view>
|
|
<view>
|
|
- <view class="taking-pictures">
|
|
|
|
|
|
+ <view class="taking-pictures" @click="getPic">
|
|
|
|
|
|
</view>
|
|
</view>
|
|
<view class="wrap">
|
|
<view class="wrap">
|
|
@@ -26,6 +26,7 @@
|
|
keyboardshow:false,
|
|
keyboardshow:false,
|
|
newPlateNumber:'',
|
|
newPlateNumber:'',
|
|
spaceId:'',
|
|
spaceId:'',
|
|
|
|
+ vehicleClor:''
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onLoad(){
|
|
onLoad(){
|
|
@@ -35,6 +36,55 @@
|
|
|
|
|
|
},
|
|
},
|
|
methods:{
|
|
methods:{
|
|
|
|
+ getPic(){
|
|
|
|
+ let that = this;
|
|
|
|
+ uni.chooseImage({
|
|
|
|
+ count: 1, //默认9
|
|
|
|
+ sizeType: ['compressed'], //可以指定是原图还是压缩图,默认二者都有
|
|
|
|
+ sourceType: ['camera'], //
|
|
|
|
+ success: function (res) {
|
|
|
|
+ // console.log('img',res)
|
|
|
|
+ uni.showLoading({});
|
|
|
|
+ const tempFilePaths = res.tempFilePaths;
|
|
|
|
+ // 若多选,需循环调用uni.uploadFile ,因微信小程序只支持单文件上传
|
|
|
|
+ uni.uploadFile({
|
|
|
|
+ url: `${that.config.fileUrl}/baidu/ocr`,
|
|
|
|
+ filePath: tempFilePaths[0],
|
|
|
|
+ name: 'file',
|
|
|
|
+ formData: {
|
|
|
|
+ 'test': 'test' // 上传附带参数
|
|
|
|
+ },
|
|
|
|
+ success: (res) => {
|
|
|
|
+ // 根据接口具体返回格式 赋值具体对应url
|
|
|
|
+ // alert(uploadFileRes.data);
|
|
|
|
+ let resobj=eval("("+res.data+")");
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ if(resobj.code==200){
|
|
|
|
+ console.log(resobj);
|
|
|
|
+ that.newPlateNumber = resobj.data.vehicleNo;
|
|
|
|
+ that.vehicleClor = resobj.data.vehicleClor;
|
|
|
|
+ }else{
|
|
|
|
+ that.$refs.uToast.show({
|
|
|
|
+ title: resobj.msg,
|
|
|
|
+ type: 'error'
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ console.log(res);
|
|
|
|
+ },
|
|
|
|
+ fail: (err) => {
|
|
|
|
+ that.$refs.uToast.show({
|
|
|
|
+ title:err.msg,
|
|
|
|
+ type: 'error'
|
|
|
|
+ });
|
|
|
|
+ uni.hideLoading();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ },
|
|
messageInputClick(){
|
|
messageInputClick(){
|
|
this.keyboardshow = true;
|
|
this.keyboardshow = true;
|
|
},
|
|
},
|