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 }, }, ]