From c55fc2954fc5d59214f7b4d7ca1e17162799727d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=B9=E6=88=90?= Date: Tue, 27 Jan 2026 01:33:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E6=83=A0=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages-activity/activity/list/index.vue | 93 ++++++++++++++------------ pages-user/coupons/index.vue | 20 ++++-- utils/request.js | 2 +- 3 files changed, 68 insertions(+), 47 deletions(-) diff --git a/pages-activity/activity/list/index.vue b/pages-activity/activity/list/index.vue index ae52702..b435f36 100644 --- a/pages-activity/activity/list/index.vue +++ b/pages-activity/activity/list/index.vue @@ -2,17 +2,36 @@ - - - - - HOT + + + + + + + HOT + + + {{ a.title }} + + {{ a.category_name }} · {{ a.subtitle }} + GO + + - - {{ a.title }} - - {{ a.category_name }} · {{ a.subtitle }} - GO + + + + + + + HOT + + + {{ a.title }} + + {{ a.category_name }} · {{ a.subtitle }} + GO + @@ -44,6 +63,9 @@ const filteredActivities = computed(() => { }) }) +const leftList = computed(() => filteredActivities.value.filter((_, i) => i % 2 === 0)) +const rightList = computed(() => filteredActivities.value.filter((_, i) => i % 2 !== 0)) + function apiGet(url) { const token = uni.getStorageSync('token') const fn = token ? authRequest : request @@ -160,11 +182,19 @@ onShareTimeline(() => { flex: 1; padding: $spacing-lg; } -.activity-grid { - display: grid; - grid-template-columns: repeat(2, 1fr); +/* 瀑布流容器 */ +.waterfall-box { + display: flex; + justify-content: space-between; + align-items: flex-start; +} +.waterfall-col { + width: 48%; /* 给间距留出空间 */ + display: flex; + flex-direction: column; gap: $spacing-md; } + .activity-item { background: #fff; border-radius: $radius-lg; @@ -184,20 +214,14 @@ onShareTimeline(() => { .thumb-box { position: relative; width: 100%; - padding-top: 100%; /* 1:1 Aspect Ratio */ - height: 0; - background: $bg-secondary; + /* 移除固定宽高比,让 mode="widthFix" 撑开高度 */ + font-size: 0; /* 消除图片底部间隙 */ } .thumb { - position: absolute; - top: 0; - left: 0; width: 100%; - height: 100%; - object-fit: cover; - background: linear-gradient(90deg, $bg-secondary 25%, #e8e8e8 50%, $bg-secondary 75%); - background-size: 200% 100%; - animation: shimmer 1.5s infinite; + /* height 由 widthFix 自动决定 */ + background: #f0f0f0; + display: block; } .tag-hot { position: absolute; @@ -217,25 +241,20 @@ onShareTimeline(() => { padding: 20rpx 20rpx; display: flex; flex-direction: column; - flex: 1; - justify-content: space-between; + gap: 12rpx; } .name { font-size: 28rpx; font-weight: 700; color: $text-main; - margin-bottom: 16rpx; - display: -webkit-box; - -webkit-line-clamp: 2; - -webkit-box-orient: vertical; - overflow: hidden; line-height: 1.4; - height: 80rpx; + /* 移除固定高度限制,适应不同文字量 */ } .bottom-row { display: flex; justify-content: space-between; align-items: flex-end; + margin-top: 4rpx; } .price-text { font-size: 22rpx; @@ -290,15 +309,7 @@ onShareTimeline(() => { font-size: 28rpx; } -/* ============================================ - 动画增强 - ============================================ */ -@keyframes shimmer { - 0% { background-position: -200% 0; } - 100% { background-position: 200% 0; } -} - -/* 卡片交错入场 */ +/* 动画增强 */ @for $i from 1 through 10 { .activity-item:nth-child(#{$i}) { animation: fadeInUp 0.4s ease-out #{$i * 0.05}s both; diff --git a/pages-user/coupons/index.vue b/pages-user/coupons/index.vue index 2da7bac..ececbb7 100644 --- a/pages-user/coupons/index.vue +++ b/pages-user/coupons/index.vue @@ -82,11 +82,11 @@ {{ formatRules(item.rules) }} - + - 已用 {{ formatValue(item.amount - item.remaining) }} ({{ getUsedPercent(item) }}%) + 已用 ¥{{ formatValue(item.used_amount || (item.amount - item.remaining)) }} ({{ getUsedPercent(item) }}%) @@ -205,9 +205,19 @@ function formatDateTime(t) { // 计算使用百分比 function getUsedPercent(item) { - if (!item.amount || !item.remaining) return 0 - const used = item.amount - item.remaining - return Math.floor((used / item.amount) * 100) + const amount = item.amount || 0 + if (!amount) return 0 + + let used = 0 + if (item.used_amount !== undefined) { + used = item.used_amount + } else if (item.remaining !== undefined) { + used = amount - item.remaining + } + + if (used <= 0) return 0 + // use Math.min to cap at 100% just in case + return Math.min(100, Math.floor((used / amount) * 100)) } // 获取空状态文本 diff --git a/utils/request.js b/utils/request.js index c130501..e726740 100644 --- a/utils/request.js +++ b/utils/request.js @@ -1,4 +1,4 @@ -const BASE_URL = 'https://kdy.1024tool.vip' +const BASE_URL = 'http://127.0.0.1:9991' let authModalShown = false