<template>
  <view class="order-item-content">
    <view class="order-item-product-info">
      <image
        :src="productImg"
        mode="aspectFit"
        class="order-item-product-cover"
      />
      <view class="order-item-product-name" v-html="title"></view>
    </view>
    <view class="order-item-product-price">
      <view class="price">{{ price }} {{ t('global.coin') }}</view>
      <view class="count">x {{ 1 }}</view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { computed } from 'vue'
interface Props {
  data: any
  type: string
}
const props = defineProps<Props>()

const productImg = computed(() => {
  
  switch (props.type) {
    case 'order':
      return props.data[0]?.product?.productImages || ''
    case 'abroadBook':
      return props.data?.images || ''
    case 'vip':
      return '/static/vip.png'
    case 'point':
      return '/static/jifen.png'
    default:
      return ''
  }
})
const title = computed(() => {
  switch (props.type) {
    case 'order':
      return props.data[0]?.product?.productName || ''
    case 'abroadBook':
      return props.data?.name || ''
    case 'vip':
      return props.data?.title + '<text style="color: #ff4703; font-weight: bold;">(' + props.data?.year + '年)</text>' || ''
    case 'point':
      return ''
    default:
      return ''
  }
})
const price = computed(() => {
  switch (props.type) {
    case 'order':
      return props.data[0]?.product?.price || 0
    case 'abroadBook':
      return props.data?.abroadPrice || 0
    case 'vip':
      return props.data?.fee || 0
    case 'point':
      return ''
    default:
      return ''
  }
})

</script>

<style lang="scss" scoped>
.order-item-content {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;

  .order-item-product-info {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;

    .order-item-product-cover {
      margin-right: 12px;
      width: 40px;
      height: 40px;
      border-radius: 4px;
      background-color: #f5f5f5;
    }

    .order-item-product-name {
      color: #333;
    }
  }
  .order-item-product-price {
    font-weight: bold;
    color: #333;
    text-align: right;
    font-size: 12px;

    .count {
      font-weight: normal;
      color: #999;
    }
  }
}
</style>