diff --git a/frontend/src/stores/oils.js b/frontend/src/stores/oils.js
index c141771..234573f 100644
--- a/frontend/src/stores/oils.js
+++ b/frontend/src/stores/oils.js
@@ -94,25 +94,39 @@ export const useOilsStore = defineStore('oils', () => {
delete oilsMeta.value[name]
}
- function isMlUnit(name) {
+ const UNIT_LABELS = {
+ drop: { zh: '滴', en: 'drop', enPlural: 'drops' },
+ ml: { zh: 'ml', en: 'ml', enPlural: 'ml' },
+ g: { zh: 'g', en: 'g', enPlural: 'g' },
+ capsule: { zh: '颗', en: 'capsule', enPlural: 'capsules' },
+ }
+
+ function getUnit(name) {
const meta = oilsMeta.value[name]
- return meta && meta.unit === 'ml'
+ return (meta && meta.unit) || 'drop'
+ }
+
+ function isDropUnit(name) {
+ return getUnit(name) === 'drop'
+ }
+
+ function isMlUnit(name) {
+ return getUnit(name) === 'ml'
}
function isPortionUnit(name) {
- return isMlUnit(name)
+ return !isDropUnit(name)
}
function unitLabel(name, lang = 'zh') {
- if (isMlUnit(name)) return 'ml'
- if (name === '植物空胶囊') return lang === 'en' ? 'capsule' : '颗'
- return lang === 'en' ? 'drop' : '滴'
+ const u = UNIT_LABELS[getUnit(name)] || UNIT_LABELS.drop
+ return lang === 'en' ? u.en : u.zh
}
function unitLabelPlural(name, count, lang = 'zh') {
- if (isMlUnit(name)) return 'ml'
- if (name === '植物空胶囊') return lang === 'en' ? (count === 1 ? 'capsule' : 'capsules') : '颗'
- return lang === 'en' ? (count === 1 ? 'drop' : 'drops') : '滴'
+ const u = UNIT_LABELS[getUnit(name)] || UNIT_LABELS.drop
+ if (lang === 'en') return count === 1 ? u.en : u.enPlural
+ return u.zh
}
return {
@@ -127,6 +141,8 @@ export const useOilsStore = defineStore('oils', () => {
loadOils,
saveOil,
deleteOil,
+ getUnit,
+ isDropUnit,
isMlUnit,
isPortionUnit,
unitLabel,
diff --git a/frontend/src/views/OilReference.vue b/frontend/src/views/OilReference.vue
index f676e3a..4123a5f 100644
--- a/frontend/src/views/OilReference.vue
+++ b/frontend/src/views/OilReference.vue
@@ -227,7 +227,7 @@
-
+
总容量
{{ volumeWithDrops(selectedOilName) }}
@@ -253,19 +253,27 @@
总容量
- {{ getMeta(selectedOilName)?.dropCount || '--' }}ml
+ {{ getMeta(selectedOilName)?.dropCount || '--' }}{{ oils.unitLabel(selectedOilName) }}
会员价
{{ getMeta(selectedOilName)?.bottlePrice != null ? ('¥ ' + getMeta(selectedOilName).bottlePrice.toFixed(2)) : '--' }}
- 每ml价格
+ 每{{ oils.unitLabel(selectedOilName) }}价格
{{ oils.pricePerDrop(selectedOilName) ? ('¥ ' + oils.pricePerDrop(selectedOilName).toFixed(2)) : '--' }}
+
+ 零售价
+ ¥ {{ getMeta(selectedOilName).retailPrice.toFixed(2) }}
+
+
+ 每{{ oils.unitLabel(selectedOilName) }}价格
+ ¥ {{ (getMeta(selectedOilName).retailPrice / getMeta(selectedOilName).dropCount).toFixed(2) }}
+
-
含此{{ oils.isMlUnit(selectedOilName) ? '产品' : '精油' }}的配方
+
含此{{ oils.isDropUnit(selectedOilName) ? '精油' : '产品' }}的配方
{{ r.name }}
@@ -490,27 +498,24 @@ for (const [ml, drops] of Object.entries(VOLUME_OPTIONS)) {
DROPS_TO_VOLUME[drops] = ml + 'ml'
}
-function volumeWithDrops(name) {
- const meta = getMeta(name)
- if (!meta || !meta.dropCount) return '--'
- if (name === '植物空胶囊') return meta.dropCount + '颗'
- const ml = DROPS_TO_VOLUME[meta.dropCount]
- if (ml) return `${ml}/${meta.dropCount}滴`
- return meta.dropCount + '滴'
-}
-
function oilPriceUnit(name) {
- if (oils.isMlUnit(name)) return 'ml'
- if (name === '植物空胶囊') return '颗'
- return '滴'
+ return oils.unitLabel(name)
}
function volumeLabel(dropCount, name) {
- if (dropCount === 160) return '160颗'
- if (oils.isMlUnit(name)) return dropCount + 'ml'
+ if (!oils.isDropUnit(name)) return dropCount + oils.unitLabel(name)
return DROPS_TO_VOLUME[dropCount] || (dropCount + '滴')
}
+function volumeWithDrops(name) {
+ const meta = getMeta(name)
+ if (!meta || !meta.dropCount) return '--'
+ if (!oils.isDropUnit(name)) return meta.dropCount + oils.unitLabel(name)
+ const ml = DROPS_TO_VOLUME[meta.dropCount]
+ if (ml) return `${ml}/${meta.dropCount}滴`
+ return meta.dropCount + '滴'
+}
+
function chipStyle(name) {
const hasCard = !!getOilCard(name)
if (hasCard) return 'cursor:pointer;border-left:3px solid var(--sage);background:linear-gradient(90deg,var(--sage-mist),white)'