product_item.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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. <!-- 收藏图标 -->
  10. <view class="favorite-icon" @click.stop="toggleFavorite">
  11. <i class="icon-font icon-star" :class="{ active: item.iscollect }"></i>
  12. </view>
  13. </view>
  14. <view class="product-info">
  15. <view class="product-title">{{ item.goodsName }}</view>
  16. <view class="product-tag" v-if="item.tag">{{ item.tag }}</view>
  17. <view class="product-price">
  18. <text class="current-price">{{ symbol }}{{ item.price }}</text>
  19. <text class="original-price" v-if="item.originalprice"
  20. >{{ symbol }}{{ item.originalprice }}</text
  21. >
  22. </view>
  23. </view>
  24. </view>
  25. </template>
  26. <script setup>
  27. import { defineProps, defineEmits, computed } from "vue";
  28. import { useSystemStore } from "@/store";
  29. const props = defineProps({
  30. item: {
  31. type: Object,
  32. required: true,
  33. },
  34. });
  35. const emit = defineEmits(["click", "favorite"]);
  36. const useSystem = useSystemStore();
  37. const symbol = computed(() => useSystem.getSymbol.symbol);
  38. const handleClick = () => {
  39. emit("click", props.item);
  40. // 跳转到商品详情页
  41. uni.navigateTo({
  42. url: `/pagesBuyer/shop/detail?id=${props.item.id}`,
  43. });
  44. };
  45. const toggleFavorite = () => {
  46. emit("favorite", props.item);
  47. };
  48. </script>
  49. <style lang="less" scoped>
  50. @import url("@/style.less");
  51. .product-item {
  52. background: var(--light);
  53. border-radius: 16rpx;
  54. overflow: hidden;
  55. .product-image {
  56. width: 100%;
  57. height: 300rpx;
  58. position: relative;
  59. image {
  60. width: 100%;
  61. height: 100%;
  62. }
  63. .play-icon {
  64. position: absolute;
  65. top: 20rpx;
  66. left: 20rpx;
  67. width: 60rpx;
  68. height: 60rpx;
  69. background: rgba(0, 0, 0, 0.6);
  70. border-radius: 50%;
  71. display: flex;
  72. align-items: center;
  73. justify-content: center;
  74. .icon-play {
  75. color: white;
  76. font-size: 32rpx;
  77. }
  78. }
  79. .favorite-icon {
  80. position: absolute;
  81. bottom: 20rpx;
  82. right: 20rpx;
  83. width: 60rpx;
  84. height: 60rpx;
  85. background: rgba(255, 255, 255, 0.9);
  86. border-radius: 50%;
  87. display: flex;
  88. align-items: center;
  89. justify-content: center;
  90. .icon-star {
  91. color: var(--text-01);
  92. font-size: 32rpx;
  93. &.active {
  94. color: var(--primary);
  95. }
  96. }
  97. }
  98. }
  99. .product-info {
  100. padding: 24rpx;
  101. .product-title {
  102. font-size: 28rpx;
  103. color: var(--black);
  104. line-height: 1.4;
  105. margin-bottom: 12rpx;
  106. .ellipsis(2);
  107. }
  108. .product-tag {
  109. font-size: 24rpx;
  110. color: var(--primary);
  111. margin-bottom: 12rpx;
  112. background: rgba(255, 107, 53, 0.1);
  113. padding: 4rpx 12rpx;
  114. border-radius: 8rpx;
  115. display: inline-block;
  116. }
  117. .product-price {
  118. display: flex;
  119. align-items: baseline;
  120. gap: 12rpx;
  121. .current-price {
  122. font-size: 32rpx;
  123. font-weight: bold;
  124. color: var(--red);
  125. }
  126. .original-price {
  127. font-size: 24rpx;
  128. color: var(--text-01);
  129. text-decoration: line-through;
  130. }
  131. }
  132. }
  133. }
  134. </style>