From 0bd10c6a0d89f9dff9f6716869cdc827194e0149 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=B9=E6=88=90?= Date: Sun, 28 Dec 2025 22:48:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E5=A5=96=E5=8A=B1=E5=9B=BE=E7=89=87=E5=A4=84=E7=90=86=E3=80=81?= =?UTF-8?q?=E7=99=BB=E5=BD=95=E6=B5=81=E7=A8=8B=E5=8F=8AAuthorization?= =?UTF-8?q?=E5=A4=B4=E8=AE=BE=E7=BD=AE=EF=BC=8C=E5=B9=B6=E6=94=B9=E8=BF=9B?= =?UTF-8?q?=E5=AF=B9=E5=AF=B9=E7=A2=B0=E6=B4=BB=E5=8A=A8=E5=A5=96=E5=8A=B1?= =?UTF-8?q?=E5=B1=95=E7=A4=BA=E5=92=8C=E6=8E=92=E5=BA=8F=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/activity/LotteryResultPopup.vue | 28 +++++++- components/activity/RewardsPreview.vue | 2 +- pages-activity/activity/duiduipeng/index.vue | 21 ++++-- pages/login/index.vue | 68 ++++++++++++++++---- utils/activity.js | 22 +++++-- utils/request.js | 3 +- 6 files changed, 117 insertions(+), 27 deletions(-) diff --git a/components/activity/LotteryResultPopup.vue b/components/activity/LotteryResultPopup.vue index 2a3a939..1d3b9b8 100644 --- a/components/activity/LotteryResultPopup.vue +++ b/components/activity/LotteryResultPopup.vue @@ -76,6 +76,32 @@ const props = defineProps({ const emit = defineEmits(['update:visible', 'close']) +function cleanUrl(u) { + if (!u) return '/static/logo.png' + let s = String(u).trim() + + // 尝试解析 JSON 数组字符串 (针对后端返回的 JSON 字符串图片地址) + if (s.startsWith('[') && s.endsWith(']')) { + try { + const arr = JSON.parse(s) + if (Array.isArray(arr) && arr.length > 0) { + s = arr[0] + } + } catch (e) { + console.warn('JSON parse failed for prize image:', s) + } + } + + // 清理反引号、引号和空格 + s = s.replace(/[`'"]/g, '').trim() + + // 提取 http 链接 + const m = s.match(/https?:\/\/[^\s]+/) + if (m && m[0]) return m[0] + + return s || '/static/logo.png' +} + const groupedResults = computed(() => { const map = new Map() const arr = Array.isArray(props.results) ? props.results : [] @@ -90,7 +116,7 @@ const groupedResults = computed(() => { } else { map.set(key, { title: item.title || item.name || '神秘奖品', - image: item.image || item.img || item.pic || '', + image: cleanUrl(item.image || item.img || item.pic || ''), reward_id: rewardId, quantity: 1 }) diff --git a/components/activity/RewardsPreview.vue b/components/activity/RewardsPreview.vue index 973c8ff..d48160e 100644 --- a/components/activity/RewardsPreview.vue +++ b/components/activity/RewardsPreview.vue @@ -14,7 +14,7 @@ - {{ item.boss ? 'BOSS' : group.level }} + BOSS {{ item.title }} diff --git a/pages-activity/activity/duiduipeng/index.vue b/pages-activity/activity/duiduipeng/index.vue index 0aa32b2..2b7c943 100644 --- a/pages-activity/activity/duiduipeng/index.vue +++ b/pages-activity/activity/duiduipeng/index.vue @@ -317,13 +317,21 @@ const currentIssueRewards = computed(() => { const rewardGroups = computed(() => { const groups = {} currentIssueRewards.value.forEach(item => { - const level = item.level || '赏' + let level = item.level || '赏' + if (item.min_score > 0 && level !== 'BOSS') { + level = `${item.min_score}对子` + } if (!groups[level]) groups[level] = [] groups[level].push(item) }) return Object.keys(groups).sort((a, b) => { - if (a === 'BOSS') return -1 - if (b === 'BOSS') return 1 + if (a === 'Last' || a === 'BOSS') return -1 + if (b === 'Last' || b === 'BOSS') return 1 + const numA = parseInt(a) + const numB = parseInt(b) + if (!isNaN(numA) && !isNaN(numB)) { + return numB - numA + } return a.localeCompare(b) }).map(key => { const rewards = groups[key] @@ -506,11 +514,13 @@ function normalizeIssues(list) { function normalizeRewards(list) { const arr = unwrap(list) const items = arr.map((i, idx) => ({ + ...i, // Spread original properties first id: i.product_id ?? i.id ?? String(idx), title: i.name ?? i.title ?? '', image: cleanUrl(i.product_image ?? i.image ?? i.img ?? i.pic ?? i.banner ?? ''), weight: Number(i.weight) || 0, boss: detectBoss(i), + min_score: Number(i.min_score) || 0, // Extract min_score level: levelToAlpha(i.prize_level ?? i.level ?? (detectBoss(i) ? 'BOSS' : '赏')) })) const total = items.reduce((acc, it) => acc + (it.weight > 0 ? it.weight : 0), 0) @@ -518,7 +528,8 @@ function normalizeRewards(list) { ...it, percent: total > 0 ? Math.round((it.weight / total) * 1000) / 10 : 0 })) - enriched.sort((a, b) => (b.percent - a.percent)) + // 移除前端按百分比强制排序逻辑,保留后端原始排序 + // enriched.sort((a, b) => (b.percent - a.percent)) return enriched } async function fetchRewardsForIssues(activityId) { @@ -974,7 +985,7 @@ async function finishAndReport() { ) return { title: item.title || item.name || found?.name || found?.title || '神秘奖励', - image: item.image || item.img || found?.image || found?.pic || found?.product_image || '', + image: cleanUrl(item.image || item.img || found?.image || found?.pic || found?.product_image || ''), reward_id: item.reward_id || item.id } }) diff --git a/pages/login/index.vue b/pages/login/index.vue index 8f57a72..2b55baa 100644 --- a/pages/login/index.vue +++ b/pages/login/index.vue @@ -22,14 +22,14 @@ :class="{ active: loginMode === 'wechat' }" @tap="switchMode('wechat')" > - 微信快捷登录 + 手机号快捷登录 - 手机号登录 + 验证码登录 @@ -43,8 +43,8 @@ 💬 - 微信一键授权 - 使用微信授权获取手机号,安全快速 + 一键获取手机号 + 授权获取本机手机号,安全快速登录 @@ -146,6 +146,8 @@