拍照支持裁剪

This commit is contained in:
2025-09-22 09:48:37 +08:00
parent d4f357d624
commit ad4d9323ad
4 changed files with 49 additions and 18 deletions

View File

@@ -32,16 +32,43 @@ Component({
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
wx.cropImage({
src: res.tempFiles[0].tempFilePath, // 图片路径
cropScale: '16:9', // 裁剪比例
success: function (res) {
if (!/(\.jpg|\.png|\.jpeg)$/.test(res.tempFilePath.toLowerCase())) {
wx.showToast({
title: '请上传jpg、png或jpeg格式的图片',
icon: 'none',
});
return;
}
var tempFilePaths = res.tempFilePath;
loadingFunc(async () => {
const { code, message, data } = await uploadOcrFile(tempFilePaths)
if (code !== OK) {
alertError(message)
return
}
setTimeout(() => {
that.triggerEvent("finish", { number: data?.integer, success: data?.integer != null && data?.integer !== "" })
}, 100)
})
}
setTimeout(() => {
that.triggerEvent("finish", { number: data?.integer, success: data?.integer != null && data?.integer !== "" })
}, 100)
})
// 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)
// })
}
})