|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- // plugin/components/enterpriseUpload/enterpriseUpload.js
- import Api from "../../api/index.js"
- import { requestFnc } from "../../utils/request.js"
- import { getStore, setStore } from "../../utils/index.js"
- Component({
- properties: {
- showOne: {
- type: Boolean,
- value: false,
- },
- },
- 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 = file.detail[0].split(";")[1].split(",")[1]
- if (this.data.sides === "2") {
- //反面
- this.setData({
- rightPath: file.detail[0],
- isLoading: false,
- })
- let obj = {
- type: "2",
- imgStr: imgStr,
- }
- this.triggerEvent("enterpriseImage", obj)
- return
- }
- if (this.data.sides === "1") {
- //正面
- this.setData({
- leftPath: file.detail[0],
- })
- let obj = {
- type: "1",
- imgStr: imgStr,
- }
- this.triggerEvent("enterpriseImage", obj)
- let data = {
- filename: Api.ocrCorp.filename,
- data: {
- imageStr: imgStr,
- vehicleId: getStore("vehicleId"),
- },
- }
- requestFnc(
- Api.ocrCorp.url,
- data,
- (res) => {
- let corpInfoObj = JSON.parse(res.encryptedData)
- corpInfoObj.imageId = res.imageId
- for (let key in corpInfoObj) {
- this.data.identity[key] = corpInfoObj[key]
- }
- this.setData({
- isLoading: false,
- identity: this.data.identity,
- })
- this.triggerEvent(
- "enterpriseOcrInfo",
- this.data.identity
- )
- },
- (msg) => {
- this.setData({
- isLoading: false,
- })
- }
- )
- }
- },
- viewImage(e) {
- console.log(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", data)
- }
- },
- })
- },
- },
- })
|