From 9fe6eeaf29724a995b9c22707e10c7ba3e94a8ac Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Tue, 14 Apr 2026 00:00:45 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=85=A8=E7=B2=BE=E6=B2=B9=E6=A4=B0?= =?UTF-8?q?=E5=AD=90=E6=B2=B9=E6=8C=89=E5=AE=9E=E9=99=85295mL(2.57?= =?UTF-8?q?=E7=93=B6)=E8=AE=A1=E7=AE=97=E6=88=90=E6=9C=AC=E5=92=8C?= =?UTF-8?q?=E5=8F=AF=E7=94=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 套装配置支持 bottleCount 字段指定某种油的瓶数倍率 Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/composables/useKitCost.js | 11 +++++++---- frontend/src/config/kits.js | 3 +++ 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/frontend/src/composables/useKitCost.js b/frontend/src/composables/useKitCost.js index 3ddf351..f3f46a2 100644 --- a/frontend/src/composables/useKitCost.js +++ b/frontend/src/composables/useKitCost.js @@ -24,12 +24,14 @@ export function useKitCost() { // Calculate per-drop costs for a kit function calcKitPerDrop(kit) { const resolved = kit.oils.map(name => resolveOilName(name)) - // Sum of bottle prices for all oils in kit + const bc = kit.bottleCount || {} // e.g. { '椰子油': 2.57 } + // Sum of bottle prices for all oils in kit (accounting for multiple bottles) let totalBottlePrice = 0 const oilBottlePrices = {} for (const name of resolved) { const meta = oils.oilsMeta[name] - const bp = meta ? meta.bottlePrice : 0 + const count = bc[name] || 1 + const bp = meta ? meta.bottlePrice * count : 0 oilBottlePrices[name] = bp totalBottlePrice += bp } @@ -41,10 +43,11 @@ export function useKitCost() { const perDrop = {} for (const name of resolved) { const meta = oils.oilsMeta[name] + const count = bc[name] || 1 const bp = oilBottlePrices[name] const kitCostForOil = (bp / totalBottlePrice) * effectivePrice - const drops = meta ? meta.dropCount : 1 - perDrop[name] = drops > 0 ? kitCostForOil / drops : 0 + const totalDrops = meta ? meta.dropCount * count : 1 + perDrop[name] = totalDrops > 0 ? kitCostForOil / totalDrops : 0 } return perDrop } diff --git a/frontend/src/config/kits.js b/frontend/src/config/kits.js index 6f75cc4..8b173d5 100644 --- a/frontend/src/config/kits.js +++ b/frontend/src/config/kits.js @@ -1,5 +1,6 @@ // doTERRA 套装配置 // 价格和内容更新频率低,手动维护即可 +// bottleCount: 某种油在套装中的瓶数(用于成本分摊和可做次数计算,默认1) export const KITS = [ { id: 'aroma', @@ -52,5 +53,7 @@ export const KITS = [ '柑橘清新', '顺畅呼吸', '净化清新', '赋活呼吸', '天然防护', '椰子油', ], + // 115mL×1 + 30mL×6 = 295mL, 标准瓶115mL, 约2.57瓶 + bottleCount: { '椰子油': 2.57 }, }, ]