feat: 套装卡片显示折扣率(会员价后再X折)
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Failing after 6s
Test / e2e-test (push) Has been skipped
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Failing after 5s
PR Preview / deploy-preview (pull_request) Has been skipped

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-14 12:55:01 +00:00
parent 0e3bbf3ba7
commit 72347493d7
2 changed files with 15 additions and 1 deletions

View File

@@ -86,11 +86,23 @@ export function useKitCost() {
return KITS.map(kit => { return KITS.map(kit => {
const perDrop = calcKitPerDrop(kit) const perDrop = calcKitPerDrop(kit)
const recipes = getKitRecipes(kit) const recipes = getKitRecipes(kit)
// Calculate discount rate for display
const resolved = kit.oils.map(name => resolveOilName(name))
const bc = kit.bottleCount || {}
let totalBP = 0
for (const name of resolved) {
const meta = oils.oilsMeta[name]
totalBP += meta ? meta.bottlePrice * (bc[name] || 1) : 0
}
const totalValue = totalBP + (kit.accessoryValue || 0)
const discountRate = totalValue > 0 ? Math.min(kit.price / totalValue, 1) : 1
return { return {
...kit, ...kit,
perDrop, perDrop,
recipes, recipes,
recipeCount: recipes.length, recipeCount: recipes.length,
discountRate,
} }
}).sort((a, b) => a.recipeCount - b.recipeCount) }).sort((a, b) => a.recipeCount - b.recipeCount)
}) })

View File

@@ -22,6 +22,7 @@
> >
<div class="kit-name">{{ ka.name }}</div> <div class="kit-name">{{ ka.name }}</div>
<div class="kit-price">¥{{ ka.price }}</div> <div class="kit-price">¥{{ ka.price }}</div>
<div class="kit-discount">会员价后再{{ (ka.discountRate * 10).toFixed(1) }}</div>
<div class="kit-stats"> <div class="kit-stats">
<span>{{ ka.oils.length }} 种精油</span> <span>{{ ka.oils.length }} 种精油</span>
<span class="kit-recipe-count">可做 {{ ka.recipeCount }} 个配方</span> <span class="kit-recipe-count">可做 {{ ka.recipeCount }} 个配方</span>
@@ -416,7 +417,8 @@ async function exportExcel(mode) {
box-shadow: 0 2px 8px rgba(74, 157, 126, 0.15); box-shadow: 0 2px 8px rgba(74, 157, 126, 0.15);
} }
.kit-name { font-weight: 600; font-size: 14px; color: #3e3a44; margin-bottom: 4px; } .kit-name { font-weight: 600; font-size: 14px; color: #3e3a44; margin-bottom: 4px; }
.kit-price { font-size: 18px; font-weight: 700; color: #4a9d7e; margin-bottom: 6px; } .kit-price { font-size: 18px; font-weight: 700; color: #4a9d7e; margin-bottom: 2px; }
.kit-discount { font-size: 11px; color: #e65100; margin-bottom: 6px; }
.kit-stats { font-size: 12px; color: #6b6375; display: flex; flex-direction: column; gap: 2px; } .kit-stats { font-size: 12px; color: #6b6375; display: flex; flex-direction: column; gap: 2px; }
.kit-recipe-count { color: #4a9d7e; font-weight: 500; } .kit-recipe-count { color: #4a9d7e; font-weight: 500; }