|
|
@@ -24,6 +24,7 @@ const { open } = useOrderPopup()
|
|
|
const { request } = useApi()
|
|
|
const { userProfile } = useAuth()
|
|
|
const { openConversation: openImPopup } = useImPopup()
|
|
|
+const firstOrderDiscountStore = useFirstOrderDiscountStore()
|
|
|
|
|
|
const playmateInfo = ref<PlaymateInfoVO | null>(null)
|
|
|
|
|
|
@@ -40,9 +41,15 @@ const selectedSkill = computed(() => {
|
|
|
return skills.value.find(item => item.id === activeSkillId.value) ?? skills.value[0]
|
|
|
})
|
|
|
|
|
|
-const totalPrice = computed(
|
|
|
- () => (selectedSkill.value ? selectedSkill.value.price * quantity.value : 0),
|
|
|
-)
|
|
|
+const displayPriceForSkill = (price: number) =>
|
|
|
+ firstOrderDiscountStore.getDisplayPrice(price, playmateInfo.value?.userNo, userProfile.value?.userNo)
|
|
|
+
|
|
|
+const totalPrice = computed(() => {
|
|
|
+ if (!selectedSkill.value)
|
|
|
+ return 0
|
|
|
+ const unitPrice = displayPriceForSkill(selectedSkill.value.price)
|
|
|
+ return unitPrice * quantity.value
|
|
|
+})
|
|
|
|
|
|
const formattedTotalPrice = computed(() => new Intl.NumberFormat('en-US').format(totalPrice.value))
|
|
|
|
|
|
@@ -210,7 +217,7 @@ const handleOrder = () => {
|
|
|
avatar: playmateInfo.value.avatar,
|
|
|
name: playmateInfo.value.nickname,
|
|
|
productType: selectedSkill.value.name,
|
|
|
- rate: selectedSkill.value.price,
|
|
|
+ rate: displayPriceForSkill(selectedSkill.value.price),
|
|
|
unit: selectedSkill.value.unit,
|
|
|
specificQuantity: quantity.value,
|
|
|
// 普通技能下单,传入 skillId
|
|
|
@@ -389,6 +396,12 @@ const handleOpenIm = () => {
|
|
|
</div>
|
|
|
<div class="skill-card__price">
|
|
|
<span class="skill-card__amount">
|
|
|
+ {{ formatNumber(displayPriceForSkill(skill.price)) }}
|
|
|
+ </span>
|
|
|
+ <span
|
|
|
+ v-if="firstOrderDiscountStore.isDiscountEligible(skill.price, playmateInfo?.userNo, userProfile?.userNo)"
|
|
|
+ class="text-[#8e8e8e] line-through ml-0.5"
|
|
|
+ >
|
|
|
{{ formatNumber(skill.price) }}
|
|
|
</span>
|
|
|
<span class="skill-card__unit">
|
|
|
@@ -457,6 +470,7 @@ const handleOpenIm = () => {
|
|
|
:skills="skills"
|
|
|
:active-skill-id="activeSkillId"
|
|
|
:formatted-total-price="formattedTotalPrice"
|
|
|
+ :owner-user-no="playmateInfo?.userNo"
|
|
|
@select-skill="handleSelectSkill"
|
|
|
@order="handleOrder"
|
|
|
/>
|