1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- const _my = require("../../__antmove/api/index.js")(my);
- const wx = _my;
- // components/ocrLicense/index.js
- const { baseUrl } = require("../../utils/func/request");
- const upload_image = require("../../utils/upload/upload_image");
- const { getOCRDetail } = require("../../utils/api/api");
- Component({
- /**
- * 组件的属性列表
- */
- properties: {
- type: {
- type: String
- }
- },
- /**
- * 组件的初始数据
- */
- data: {
- fileList: []
- },
- /**
- * 组件的方法列表
- */
- methods: {
- afterRead(event) {
- var that = this;
- const { file } = event.detail;
- wx.showLoading({
- title: "上传中~"
- // : 'uploading...',
- });
- upload_image({
- url: file.url
- })
- .then(img => {
- wx.hideLoading();
- var data = {
- passportUrl: img.url
- };
- wx.showLoading({
- title: "识别中..."
- // title: that.data.isChinese ? '识别中...' : 'recognizing..',
- });
- getOCRDetail(data)
- .then(res => {
- if (res.code == 200) {
- wx.hideLoading();
- this.triggerEvent("enterpriseOCR", res.data);
- // wx.showToast({
- // title: that.data.isChinese ? '识别成功' : 'recognize success',
- // title: '识别成功'
- // });
- } else {
- wx.hideLoading();
- wx.showToast({
- title: res.msg
- });
- }
- })
- .catch(err => {
- wx.hideLoading();
- });
- })
- .catch(() => {
- wx.hideLoading();
- });
- // 当设置 mutiple 为 true 时, file 为数组格式,否则为对象格式
- // wx.uploadFile({
- // url: baseUrl, // 仅为示例,非真实的接口地址
- // filePath: file.url + '',
- // name: 'file',
- // formData: {
- // user: 'test'
- // },
- // success(res) {
- // // 上传完成需要更新 fileList
- // const {
- // fileList = []
- // } = this.data;
- // fileList.push({
- // ...file,
- // url: res.data
- // });
- // this.setData({
- // fileList
- // });
- // },
- // });
- }
- }
- });
|