product_item.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view class="product-item" @click="handleClick">
  3. <view class="product-image">
  4. <image :src="item.picurl" mode="aspectFill" />
  5. <!-- 视频播放图标 -->
  6. <view v-if="item.isVideo" class="play-icon">
  7. <i class="icon-font icon-play"></i>
  8. </view>
  9. </view>
  10. <view class="product-info">
  11. <view class="product-title">{{ item.goodsName }}</view>
  12. <view class="product-middle">
  13. <view class="product-sales">
  14. <trans _t="已售" />
  15. {{ item.sale }}</view
  16. >
  17. <view class="favorite-icon" @click.stop="toggleFavorite">
  18. <image
  19. class="img"
  20. :src="
  21. item.iscollect
  22. ? '/static/seller/collect_active.png'
  23. : '/static/seller/collect.png'
  24. "
  25. ></image>
  26. </view>
  27. </view>
  28. <view class="product-price">
  29. <text class="current-price">{{ symbol }} {{ item.price }}</text>
  30. <text class="original-price"
  31. >{{ symbol }} {{ item.originalprice }}</text
  32. >
  33. </view>
  34. </view>
  35. </view>
  36. </template>
  37. <script setup>
  38. import { computed } from "vue";
  39. import { useSystemStore } from "@/store";
  40. const useSystem = useSystemStore();
  41. const symbol = computed(() => useSystem.getSymbol.symbol);
  42. const props = defineProps({
  43. item: {
  44. type: Object,
  45. required: true,
  46. },
  47. });
  48. const emit = defineEmits(["click", "favorite"]);
  49. const handleClick = () => {
  50. emit("click", props.item);
  51. };
  52. const toggleFavorite = () => {
  53. emit("favorite", props.item);
  54. };
  55. </script>
  56. <style lang="less" scoped>
  57. @import url("@/style.less");
  58. .product-item {
  59. background: var(--light);
  60. border-radius: 16rpx;
  61. overflow: hidden;
  62. margin-bottom: 20rpx;
  63. box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
  64. .product-image {
  65. width: 100%;
  66. height: 300rpx;
  67. position: relative;
  68. image {
  69. width: 100%;
  70. height: 100%;
  71. }
  72. .play-icon {
  73. position: absolute;
  74. top: 20rpx;
  75. left: 20rpx;
  76. width: 60rpx;
  77. height: 60rpx;
  78. background: rgba(0, 0, 0, 0.6);
  79. border-radius: 50%;
  80. display: flex;
  81. align-items: center;
  82. justify-content: center;
  83. .icon-play {
  84. color: white;
  85. font-size: 32rpx;
  86. }
  87. }
  88. }
  89. .product-info {
  90. padding: 24rpx;
  91. .product-title {
  92. font-size: 28rpx;
  93. color: var(--black);
  94. line-height: 1.4;
  95. margin-bottom: 12rpx;
  96. .ellipsis(2);
  97. }
  98. .product-middle {
  99. width: 100%;
  100. .flex_position(space-between);
  101. margin-bottom: 12rpx;
  102. .product-sales {
  103. .size(24rpx);
  104. color: #fe7907;
  105. }
  106. .favorite-icon {
  107. width: 32rpx;
  108. height: 32rpx;
  109. .img {
  110. width: 100%;
  111. height: 100%;
  112. }
  113. }
  114. }
  115. .product-price {
  116. display: flex;
  117. align-items: baseline;
  118. gap: 12rpx;
  119. .current-price {
  120. font-size: 32rpx;
  121. font-weight: bold;
  122. color: var(--red);
  123. }
  124. .original-price {
  125. font-size: 24rpx;
  126. color: var(--text-01);
  127. text-decoration: line-through;
  128. }
  129. }
  130. }
  131. }
  132. </style>