From e205e63ff07855901547111b572e498d156bd070 Mon Sep 17 00:00:00 2001 From: zpc Date: Sun, 28 Dec 2025 19:19:32 +0800 Subject: [PATCH] 123 --- uniapp/WorkCameraf/pages/index/index.vue | 175 +++++++++++++++++------ 1 file changed, 132 insertions(+), 43 deletions(-) diff --git a/uniapp/WorkCameraf/pages/index/index.vue b/uniapp/WorkCameraf/pages/index/index.vue index e270f3e..e20ff20 100644 --- a/uniapp/WorkCameraf/pages/index/index.vue +++ b/uniapp/WorkCameraf/pages/index/index.vue @@ -35,17 +35,18 @@ - + - 图片预览 ({{ imageList.length }}/{{ MAX_IMAGES }}) + 图片列表 ({{ imageList.length }}/{{ MAX_IMAGES }}) @@ -61,12 +62,16 @@ @click="handleAddMorePhoto" > + - 继续拍摄 + 添加 + - - + + + 当前图片预览 + + - - - - + + + + + + + + + @@ -234,6 +246,7 @@ const originalImageSrc = ref(""); // 多图支持 const imageList = ref([]); // 存储多张图片 [{original, watermark, sizeInfo}] const MAX_IMAGES = 15; // 最大图片数量 +const currentImageIndex = ref(0); // 当前选中的图片索引 const imageSizeInfo = ref({ original: { width: 0, @@ -374,23 +387,56 @@ const addImageToList = async (imgPath) => { }); }; -// 删除图片 +// 删除图片(带二次确认弹窗) const removeImage = (index) => { - if (imageList.value.length > index) { - imageList.value.splice(index, 1); - // 更新当前显示的图片 - if (imageList.value.length > 0) { - const newIndex = Math.min(index, imageList.value.length - 1); - imageSrc.value = imageList.value[newIndex].watermark; - originalImageSrc.value = imageList.value[newIndex].original; - } else { - imageSrc.value = ""; - originalImageSrc.value = ""; + uni.showModal({ + title: '提示', + content: '确定要删除该图片吗?', + confirmText: '确定', + cancelText: '取消', + success: (res) => { + if (res.confirm) { + // 用户点击确定,执行删除 + if (imageList.value.length > index) { + imageList.value.splice(index, 1); + // 更新当前显示的图片 + if (imageList.value.length > 0) { + const newIndex = Math.min(index, imageList.value.length - 1); + currentImageIndex.value = newIndex; + imageSrc.value = imageList.value[newIndex].watermark; + originalImageSrc.value = imageList.value[newIndex].original; + } else { + currentImageIndex.value = 0; + imageSrc.value = ""; + originalImageSrc.value = ""; + } + } + } + // 用户点击取消,关闭弹窗,不做任何操作 } - } + }); }; -// 预览指定索引的图片 +// 删除当前选中的图片(底部按钮调用) +const handleDeleteCurrentImage = () => { + if (imageList.value.length === 0) { + uni.showToast({ + title: '没有可删除的图片', + icon: 'none' + }); + return; + } + removeImage(currentImageIndex.value); +}; + +// 选中指定索引的图片(点击缩略图) +const handleSelectImage = (index) => { + currentImageIndex.value = index; + imageSrc.value = imageList.value[index].watermark; + originalImageSrc.value = imageList.value[index].original; +}; + +// 预览指定索引的图片(长按或双击可用) const handlePreviewImage = (index) => { const urls = imageList.value.map((img) => img.watermark); uni.previewImage({ @@ -898,6 +944,15 @@ onLoad(async () => { padding: 20rpx; margin-bottom: 20rpx; text-align: center; + border-bottom: 1rpx solid #eee; +} + +/* 当前图片预览区域 */ +.current-preview-box { + background: #fff; + padding: 20rpx; + margin-bottom: 20rpx; + text-align: center; } .preview-title { @@ -924,6 +979,14 @@ onLoad(async () => { border-radius: 8rpx; overflow: hidden; box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.15); + border: 4rpx solid transparent; + box-sizing: border-box; +} + +/* 选中状态 */ +.preview-item-selected { + border: 4rpx solid #007aff; + box-shadow: 0 4rpx 12rpx rgba(0, 122, 255, 0.4); } .preview-thumb { @@ -1055,8 +1118,23 @@ onLoad(async () => { .footer { display: flex; - justify-content: space-between; + flex-direction: column; + gap: 20rpx; margin-top: 40rpx; + padding-bottom: 40rpx; +} + +.footer-row { + display: flex; + justify-content: space-between; + gap: 16rpx; +} + +.btn-action { + flex: 1; + font-size: 26rpx; + padding: 16rpx 0; + margin: 0; } .btn-cancel { @@ -1064,6 +1142,16 @@ onLoad(async () => { color: #fff; } +.btn-continue { + background: #17a2b8; + color: #fff; +} + +.btn-delete { + background: #dc3545; + color: #fff; +} + .btn-save { background: #28a745; color: #fff; @@ -1075,7 +1163,8 @@ onLoad(async () => { } .btn-save:disabled, -.btn-submit:disabled { +.btn-submit:disabled, +.btn-action:disabled { background: #ccc !important; color: #999 !important; opacity: 0.6;