123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- /*
- * @Author: gaorf30153 gaorf30153@hundsun.com
- * @Date: 2024-06-18 10:39:19
- * @LastEditors: gaorf30153 gaorf30153@hundsun.com
- * @LastEditTime: 2024-06-23 17:36:15
- * @FilePath: \issuer-plugin\plugin\components\pickerTime\pickerTime.js
- * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
- */
- import Api from "../../api/index.js"
- import { requestFnc } from "../../utils/request.js"
- import { getStore, setStore } from "../../utils/index.js"
-
- Component({
- properties: {
- type: {
- type: Number,
- value: 1,
- },
- },
- data: {
- isLoading: false,
- sides: 1,
- leftPath: "",
- rightPath: "",
- identity: {},
- },
- attached: function () {},
- methods: {
- //选择图片
- chooseImage(e) {
- console.log(e.currentTarget.dataset.side)
- this.setData({
- sides: e.currentTarget.dataset.side,
- })
- this.compressRef = this.selectComponent("#compress")
- this.compressRef._changImg()
- },
- ////图片压缩成功
- compressRes(file) {
- this.setData({
- isLoading: true,
- })
- //正面
- let imgStr = ""
- if (this.data.sides == 1) {
- this.setData({
- leftPath: file.detail[0],
- })
- imgStr = this.data.leftPath.split(";")[1].split(",")[1]
- this.triggerEvent("leftImage", imgStr)
- } else {
- //反面
- this.setData({
- rightPath: file.detail[0],
- })
- imgStr = this.data.rightPath.split(";")[1].split(",")[1]
- this.triggerEvent("rightImage", imgStr)
- }
- let data = {
- filename: Api.ocrCar.filename,
- data: {
- imageStr: imgStr,
- },
- }
- requestFnc(
- Api.ocrCar.url,
- data,
- (res) => {
- let driverInfoObj = JSON.parse(res.encryptedData)
- if (this.data.sides === "1") {
- driverInfoObj.imageId1 = res.imageId
- driverInfoObj.plateNum1 = driverInfoObj.plateNum
- } else {
- driverInfoObj.imageId2 = res.imageId
- driverInfoObj.plateNum2 = driverInfoObj.plateNum
- if (driverInfoObj.outsideDimensions.length > 14 && driverInfoObj.outsideDimensions.split("×").length === 3) {
- let length =
- driverInfoObj.outsideDimensions.split("×")[0]
- let width =
- driverInfoObj.outsideDimensions.split("×")[1]
- let height = driverInfoObj.outsideDimensions
- .split("×")[2]
- .split("m")[0]
- driverInfoObj.length = length
- driverInfoObj.width = width
- driverInfoObj.height = height
- }
- }
- for (let key in driverInfoObj) {
- this.data.identity[key] = `${driverInfoObj[key]}`
- }
- this.setData({
- isLoading: false,
- identity: this.data.identity,
- })
- console.log("行驶证OCR", this.data.identity)
- // setStore("carInfo", this.data.identity)
- this.triggerEvent("ocrInfo", this.data.identity)
- },
- (msg) => {
- this.setData({
- isLoading: false,
- })
- }
- )
- },
- viewImage(e) {
- wx.previewImage({
- urls: [e.currentTarget.dataset.type],
- })
- },
- delImg(e) {
- let data = e.currentTarget.dataset.type
- wx.showModal({
- title: "提示",
- content: "确定要删除此照片吗?",
- success: (res) => {
- if (res.confirm) {
- if (data == "left") {
- this.setData({
- leftPath: "",
- })
- } else if (data == "right") {
- this.setData({
- rightPath: "",
- })
- }
- this.triggerEvent("delImg")
- }
- },
- })
- },
- },
- })
|