From b471155bb9bb99f9d82b91638b562571a665a08b Mon Sep 17 00:00:00 2001 From: dzq Date: Thu, 25 Dec 2025 17:18:37 +0800 Subject: [PATCH] =?UTF-8?q?fix(StorageCellsSummary):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E6=A0=BC=E5=8F=A3=E6=93=8D=E4=BD=9C=E6=B5=81=E7=A8=8B=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=E5=92=8C=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 添加关闭弹窗时重置格口的功能 - 调整弹窗高度和样式以适应不同状态 - 优化密码验证失败和格口不可用的提示 - 修复数据刷新后默认选中格口类型的逻辑 - 增加操作失败时的错误处理和提示持续时间 --- .../components/StorageCellsSummary.vue | 63 +++++++++++++++---- 1 file changed, 52 insertions(+), 11 deletions(-) diff --git a/src/pages/cabinet/components/StorageCellsSummary.vue b/src/pages/cabinet/components/StorageCellsSummary.vue index b5e3d84..023be33 100644 --- a/src/pages/cabinet/components/StorageCellsSummary.vue +++ b/src/pages/cabinet/components/StorageCellsSummary.vue @@ -80,6 +80,7 @@ v-model:show="popupVisible" position="bottom" round + :close-on-click-overlay="false" :style="popupStyle" @close="handlePopupCancel"> @@ -156,7 +157,8 @@ import { showToast } from 'vant' import { availableStorageCells, storeItemApi, - openByPassword + openByPassword, + resetByPassword } from '@/common/apis/cabinet' import type { AvailableStorageCellDTO } from '@/common/apis/cabinet/type' import { usePopupState } from '@/common/composables/usePopupState' @@ -217,7 +219,6 @@ const { showCancelButton, transitionTo, handlePasswordInputChange, - handlePopupCancel, handleKeyboardInput, handleKeyboardDelete, handleKeyboardClose @@ -227,13 +228,14 @@ const { const popupStyle = computed(() => { const baseStyle = { padding: '32px', - background: '#fff' + background: '#fff', + height: 'calc(100vh - 120px)', } if (keyboardVisible.value) { return { ...baseStyle, - maxHeight: 'calc(100vh - 360px)', + height: 'calc(100vh - 80px)', overflow: 'auto' } } @@ -288,6 +290,11 @@ async function refresh() { const response = await availableStorageCells(props.shopId) cellsData.value = response.data || [] emit('refresh') + + const availableTypes = cellTypeStats.value.filter(stat => stat.count > 0) + if (availableTypes.length > 0) { + selectedCellType.value = availableTypes[0].type + } } catch (err) { error.value = err as Error emit('error', err as Error) @@ -347,15 +354,48 @@ async function handleDepositFlow() { showToast({ message: (err as any)?.message || '操作失败', type: 'fail', - duration: 3000 + duration: 5000, + overlay: true }) transitionTo({ type: 'idle' }) } finally { depositLoading.value = false + // 刷新数据 + await refresh() } } // 弹窗相关事件处理 +async function handlePopupCancel() { + const state = currentState.value + + // 如果在密码验证状态点击取消,需要重置格口 + if (state.type === 'password-verify') { + try { + await resetByPassword({ + shopId: props.shopId, + password: state.correctPassword + }) + showToast({ + message: '格口已重置', + type: 'success' + }) + } catch (err) { + console.error('重置格口失败:', err) + showToast({ + message: '重置格口失败', + type: 'fail' + }) + } + } + + // 切换回空闲状态 + transitionTo({ type: 'idle' }) + + // 刷新列表 + await refresh() +} + async function handlePopupConfirm() { const state = currentState.value @@ -395,18 +435,18 @@ async function performOpenByPassword(password: string, action: 'deposit' | 'retr message: '格口已打开', type: 'success' }) - - // 刷新数据 - await refresh() } catch (err) { console.error('打开格口失败:', err) showToast({ - message: (err as any)?.message || '操作失败', + message: '密码错误', type: 'fail', - duration: 3000 + duration: 4000, + overlay: true }) } finally { transitionTo({ type: 'idle' }) + // 刷新数据 + await refresh() } } @@ -442,7 +482,8 @@ function handleCellTypeSelect(stat: { type: number; count: number }) { showToast({ message: '该类型格口暂不可用', type: 'fail', - duration: 1500 + duration: 5000, + overlay: true }) return }