From ae79550d783d42e1c76f9445e0ef1de6779998ac Mon Sep 17 00:00:00 2001 From: yml2213 Date: Sun, 19 Jul 2026 17:28:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9C=A8=E7=BA=BF=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=B7=A8=E5=A4=A9=E5=B9=B6=E4=BC=98=E5=8C=96=E5=8F=91?= =?UTF-8?q?=E5=B8=83=E4=B8=8E=E7=AD=9B=E9=80=89=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 允许在线时段 end 早于 start 表示跨天,统一展示「次日」文案;修复移动端价格区间清空后被 sessionStorage 回写;优化 PC/移动端在线时间控件密度与通栏展示。 --- .../internal/modules/listing/service_test.go | 17 ++- .../modules/listing/service_validation.go | 4 +- .../admin/views/AdminListingReviewView.vue | 8 +- .../listings/views/MobileHomeFilterSheet.vue | 22 ++- .../listings/views/MobileHomeView.vue | 24 +++- .../components/OrderAccountSnapshot.vue | 6 +- .../seller/composables/usePublishForm.ts | 48 +++---- .../views/MobileSellerListingCreateView.css | 125 ++++++++++++++---- .../views/MobileSellerListingCreateView.vue | 125 +++++++++++++----- .../seller/views/SellerListingCreateView.css | 97 +++++++++++--- .../seller/views/SellerListingCreateView.vue | 32 +++-- frontend/src/shared/utils/listingDisplay.ts | 38 +++++- 12 files changed, 410 insertions(+), 136 deletions(-) diff --git a/backend/internal/modules/listing/service_test.go b/backend/internal/modules/listing/service_test.go index 7cd6b8a..fa6eed1 100644 --- a/backend/internal/modules/listing/service_test.go +++ b/backend/internal/modules/listing/service_test.go @@ -93,7 +93,7 @@ func TestValidateRequiredOnlineTimeRejectsMissing(t *testing.T) { } } -func TestValidateRequiredOnlineTimeRejectsInvalidRange(t *testing.T) { +func TestValidateRequiredOnlineTimeAllowsCrossDay(t *testing.T) { req := CreateRequest{ AssetSummary: map[string]any{ "online_time": map[string]any{ @@ -103,6 +103,21 @@ func TestValidateRequiredOnlineTimeRejectsInvalidRange(t *testing.T) { }, } + if err := validateRequiredOnlineTime(req); err != nil { + t.Fatalf("expected cross-day range to be valid, got %v", err) + } +} + +func TestValidateRequiredOnlineTimeRejectsSameStartEnd(t *testing.T) { + req := CreateRequest{ + AssetSummary: map[string]any{ + "online_time": map[string]any{ + "start": "10:00", + "end": "10:00", + }, + }, + } + if err := validateRequiredOnlineTime(req); err != ErrInvalidOnlineTime { t.Fatalf("expected ErrInvalidOnlineTime, got %v", err) } diff --git a/backend/internal/modules/listing/service_validation.go b/backend/internal/modules/listing/service_validation.go index 0f70307..860a0c9 100644 --- a/backend/internal/modules/listing/service_validation.go +++ b/backend/internal/modules/listing/service_validation.go @@ -54,7 +54,9 @@ func validateRequiredOnlineTime(req CreateRequest) error { if !ok { return ErrInvalidOnlineTime } - if startMinute >= endMinute { + // 允许跨天:start > end 表示每日 start 至次日 end(如 23:00-05:00) + // 仅禁止起止时刻相同(全天请用 00:00-23:59) + if startMinute == endMinute { return ErrInvalidOnlineTime } return nil diff --git a/frontend/src/features/admin/views/AdminListingReviewView.vue b/frontend/src/features/admin/views/AdminListingReviewView.vue index a5a1dca..893d9dd 100644 --- a/frontend/src/features/admin/views/AdminListingReviewView.vue +++ b/frontend/src/features/admin/views/AdminListingReviewView.vue @@ -21,6 +21,7 @@ import { getCoinWan, getListingConsumablePrice, getListingResources, + getOnlineTimeText, getResourceQuantity, getSkinNames, readAssetNumber, @@ -424,12 +425,7 @@ function contactPhone(row: Listing) { function ownerOnlineText(row: Listing) { const text = row.asset_summary?.online_time_text if (typeof text === 'string' && text.trim()) return text - const onlineTime = row.asset_summary?.online_time - if (typeof onlineTime !== 'object' || onlineTime === null) return '-' - const start = (onlineTime as Record).start - const end = (onlineTime as Record).end - if (typeof start === 'string' && typeof end === 'string' && start && end) return `${start}-${end}` - return '-' + return getOnlineTimeText(row) || '-' } function commonRegionText(row: Listing) { diff --git a/frontend/src/features/listings/views/MobileHomeFilterSheet.vue b/frontend/src/features/listings/views/MobileHomeFilterSheet.vue index b79bafd..3fc5b57 100644 --- a/frontend/src/features/listings/views/MobileHomeFilterSheet.vue +++ b/frontend/src/features/listings/views/MobileHomeFilterSheet.vue @@ -85,11 +85,19 @@ function toggleChip(sectionKey: string, value: string) { emit('update:selectedFilters', { ...props.selectedFilters, [sectionKey]: next }) } +/** 仅保留数字与一个小数点,避免 type=number 受控输入删不干净 */ +function sanitizeRangeInput(value: string) { + const cleaned = value.replace(/[^\d.]/g, '') + const dot = cleaned.indexOf('.') + if (dot === -1) return cleaned + return cleaned.slice(0, dot + 1) + cleaned.slice(dot + 1).replace(/\./g, '') +} + function updateRange(sectionKey: string, side: 'min' | 'max', value: string) { const current = props.rangeFilters[sectionKey] || { min: '', max: '' } emit('update:rangeFilters', { ...props.rangeFilters, - [sectionKey]: { ...current, [side]: value }, + [sectionKey]: { ...current, [side]: sanitizeRangeInput(value) }, }) } @@ -214,17 +222,21 @@ function sectionTopInBody(section: HTMLElement, body: HTMLElement) { - - - + + + +
+ + +
+ +

+ {{ onlineTimeRangeHint() }} +

+

- 此在线时间指的是百分百能够联系上您的时间,若是在此期间联系不上您导致无法上号会扣除您的部分订单金额或上架押金,在线时长太短可能无法上架,请预留充足时间用于扫码以及冻结人脸,请谨慎填写 + 请填写能百分百联系上您的时间。该时段联系不上可能影响上架或扣款,请预留扫码与冻结人脸时间。

+ + + +