50 lines
1.2 KiB
JavaScript
50 lines
1.2 KiB
JavaScript
// pages/writeReading/components/photo/index.js
|
|
import { uploadOcrFile } from "../../../../service/public"
|
|
import request from "../../../../utils/request"
|
|
import { alertError, alertInfo, alertSuccess, loadingFunc } from "../../../../utils/index"
|
|
const { OK } = request;
|
|
Component({
|
|
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
|
|
},
|
|
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
chooseImage() {
|
|
const that = this;
|
|
wx.chooseMedia({
|
|
count: 1,
|
|
mediaType: ['image'],
|
|
sourceType: ['album', 'camera'],
|
|
success: async function(res) {
|
|
// console.log(res.tempFiles[0].tempFilePath)
|
|
// console.log(res.tempFiles[0].size)
|
|
loadingFunc(async () => {
|
|
const { code, message, data } = await uploadOcrFile(res.tempFiles[0].tempFilePath)
|
|
if (code !== OK) {
|
|
alertError(message)
|
|
return
|
|
}
|
|
setTimeout(() => {
|
|
that.triggerEvent("finish", { number: data?.integer, success: data?.integer != null && data?.integer !== "" })
|
|
}, 100)
|
|
})
|
|
|
|
}
|
|
})
|
|
}
|
|
}
|
|
}) |