<template>
    <view class="primary">
        <text class="text-lg font-medium text">{{ parsePrice }}</text>
        <text class="text-xs text">{{ desc }}</text>
        <text v-if="scribingPrice" class="text-xs line-through ml-2 text-muted">
            {{ scribingPrice }}{{ desc }}
        </text>
    </view>
</template>

<script setup lang="ts">
import { PriceEnum } from '@/enums/appEnums'
import { GOODS } from '@/pages/goods/index.vue'
import { formatString } from '@/utils/util'
import { computed } from 'vue'
import { ref, withDefaults } from 'vue'

/** Props Start **/
const props = withDefaults(
    defineProps<{
        price?: string | number // 价格
        desc?: string // 介绍
        scribingPrice?: string | number // 划线价
        goodsData: Partial<GOODS>
        priceType: PriceEnum
    }>(),
    {
        price: '',
        desc: '',
        scribingPrice: '',
        goodsData: {},
        priceType: PriceEnum.CUSTOMER_PRICE
    }
)
const parsePrice = computed(() => {
    const { priceType, goodsData } = props
    return priceType == PriceEnum.CUSTOMER_PRICE
        ? goodsData.goodsPrice
        : formatString(goodsData.priceRange)
})
/** Props End **/

/** Methods Start **/

/** Methods End **/
</script>

<style lang="scss" scoped>
.text {
    color: rgba(248, 113, 113);
}
</style>
