product.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <script lang="ts" setup>
  2. import { formatNumber } from '@/utils/index'
  3. defineOptions({
  4. name: 'Product', // 商品组件
  5. })
  6. const props = defineProps({
  7. item: {
  8. type: Object,
  9. required: true,
  10. },
  11. width: {
  12. type: [Number, String],
  13. default: 260,
  14. },
  15. flex: {
  16. type: Boolean,
  17. default: false,
  18. },
  19. height: {
  20. type: [Number, String],
  21. default: 260,
  22. },
  23. })
  24. const emit = defineEmits(['itemClick'])
  25. function handleClick() {
  26. emit('itemClick', props.item)
  27. }
  28. </script>
  29. <template>
  30. <view
  31. class="flex flex-col items-center border-1 border-#E0E0E0 border-solid pb-8rpx"
  32. :class="{ 'flex-[0.5]': flex }"
  33. @click="handleClick"
  34. >
  35. <view class="mb-10rpx" :style="{ maxWidth: Number.isFinite(width) ? `${width}rpx` : width, width: Number.isFinite(width) ? `${width}rpx` : width, height: Number.isFinite(height) ? `${height}rpx` : height }">
  36. <image
  37. :src="item.image"
  38. class="h-full w-full"
  39. mode="aspectFit"
  40. />
  41. </view>
  42. <view class="box-border w-full px-8rpx text-24rpx">
  43. <view class="truncate">
  44. {{ item.storeName }}
  45. </view>
  46. <view class="flex items-center justify-between">
  47. <view class="text-24rpx text-#FF334A font-bold">
  48. ৳ {{ formatNumber(item.price) }}
  49. </view>
  50. <view class="text-24rpx text-#898989">
  51. {{ item.sales }} Sold
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <style lang="scss" scoped>
  58. //
  59. </style>