feat: 图片支持多张上传

This commit is contained in:
苟川东 2025-04-19 14:32:59 +08:00
parent 78c4b847f7
commit 0bbfe8a04a

View File

@ -41,21 +41,13 @@ import api from "../../api/api";
import {throttle} from "../../utils/throttle";
import enums from "../../utils/enums";
let url = 'https://allocatr.oss-cn-hangzhou.aliyuncs.com/uploads/20250418/560cb5b5baea2ba5a5ef479af7dc79e0.png'
const images = ref([
url,
url,
url,
url,
url,
url,
url,
url,
url,
url,
])
const images = ref([])
const upload = () => {
if (images.value.length >= 10) {
return helpers.showToast('最多上传 10 张图片')
}
uni.chooseImage({
count: 1,
sizeType: ['original'],
@ -75,7 +67,7 @@ const upload = () => {
url: res.cdnurl,
filePath: tempFilePath,
name: 'file',
timeout: 5 * 60 * 1000,
timeout: 30 * 1000,
formData: {
'signature': res.signature,
'ossAccessKeyId': res.OSSAccessKeyId,
@ -110,9 +102,9 @@ const delImg = (idx) => {
helpers.showToast('图片已删除')
}
//
//
const submit = throttle(() => {
if (!images.value) {
if (images.value.length === 0) {
return helpers.showToast('请上传上门的打卡照片')
}
@ -125,16 +117,18 @@ const submit = throttle(() => {
uni.showLoading({
title: '提交中'
});
// api.arrivedOnSite({order_dispatch_id: id.value, images: images.value}).then(() => {
// uni.hideLoading();
// uni.showToast({
// title: '',
// icon: "success"
// })
// setTimeout(() => {
// helpers.jumpToPage('order-info', `id=${id.value}`, 'redirectTo')
// }, 1000)
// }).catch(() => {})
let imagesStr = (images.value).join(',')
api.arrivedOnSite({order_dispatch_id: id.value, images: imagesStr}).then(() => {
uni.hideLoading();
uni.showToast({
title: '已上门',
icon: "success"
})
setTimeout(() => {
helpers.jumpToPage('order-info', `id=${id.value}`, 'redirectTo')
}, 1000)
}).catch(() => {})
}
}
});