index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <template>
  2. <view class="goodsList">
  3. <view class="item" v-for="(item, index) in tempArr" :key="index" @click="goDetail(item)">
  4. <view class="pictrue">
  5. <span class="pictrue_log pictrue_log_class" v-if="item.activity && item.activity.type === '1'">{{ $t(`秒杀`) }}</span>
  6. <span class="pictrue_log pictrue_log_class" v-if="item.activity && item.activity.type === '2'">{{ $t(`砍价`) }}</span>
  7. <span class="pictrue_log pictrue_log_class" v-if="item.activity && item.activity.type === '3'">{{ $t(`拼团`) }}</span>
  8. <image :src="item.recommend_image" mode="" v-if="item.recommend_image"></image>
  9. <image :src="item.image" mode="" v-else></image>
  10. </view>
  11. <view class="text line2">{{ item.store_name }}</view>
  12. <view class="bottom acea-row row-between-wrapper">
  13. <view class="sales acea-row row-middle">
  14. <view class="money font-color">
  15. <text>{{ $t(`¥`) }}</text>
  16. {{ item.price }}
  17. </view>
  18. <view>{{ $t(`已售`) }}{{ item.sales }}</view>
  19. </view>
  20. <view v-if="item.stock > 0">
  21. <view
  22. class="bnt"
  23. v-if="(item.activity && (item.activity.type === '1' || item.activity.type === '2' || item.activity.type === '3')) || item.is_virtual || !item.cart_button"
  24. >
  25. {{ $t(`立即购买`) }}
  26. </view>
  27. <view v-else>
  28. <!-- 多规格 -->
  29. <view class="bnt" @click.stop="goCartDuo(item)" v-if="item.spec_type">
  30. {{ $t(`加入购物车`) }}
  31. <view class="num" v-if="isLogin && item.cart_num">{{ item.cart_num }}</view>
  32. </view>
  33. <!-- 单规格 -->
  34. <view class="bnt" v-if="!item.spec_type && !item.cart_num" @click.stop="goCartDan(item, index)">
  35. {{ $t(`加入购物车`) }}
  36. </view>
  37. <view class="cart acea-row row-middle" v-if="!item.spec_type && item.cart_num">
  38. <view class="iconfont icon-jianhao" @click.stop="CartNumDes(index, item)"></view>
  39. <view class="num">{{ item.cart_num }}</view>
  40. <view class="iconfont icon-jiahao" @click.stop="CartNumAdd(index, item)"></view>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="bnt end" v-else>{{ $t(`已售罄`) }}</view>
  45. </view>
  46. </view>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. name: 'catGoodList',
  52. props: {
  53. dataConfig: {
  54. type: Object,
  55. default: () => {}
  56. },
  57. tempArr: {
  58. type: Array,
  59. default: []
  60. },
  61. isLogin: {
  62. type: Boolean,
  63. default: false
  64. }
  65. },
  66. data() {
  67. return {
  68. addIng: false
  69. };
  70. },
  71. created() {},
  72. mounted() {},
  73. methods: {
  74. goDetail(item) {
  75. this.$emit('detail', item);
  76. },
  77. goCartDuo(item) {
  78. this.$emit('gocartduo', item);
  79. },
  80. goCartDan(item, index) {
  81. this.$emit('gocartdan', item, index);
  82. },
  83. CartNumDes(index, item) {
  84. if (this.addIng) return;
  85. this.addIng = true;
  86. this.$emit('ChangeCartNumDan', false, index, item);
  87. },
  88. CartNumAdd(index, item) {
  89. if (this.addIng) return;
  90. this.addIng = true;
  91. this.$emit('ChangeCartNumDan', true, index, item);
  92. }
  93. }
  94. };
  95. </script>
  96. <style lang="scss">
  97. .goodsList {
  98. padding: 0 30rpx;
  99. .item {
  100. width: 100%;
  101. box-sizing: border-box;
  102. margin-bottom: 63rpx;
  103. .pictrue {
  104. // width: 100%;
  105. // height: 290rpx;
  106. border-radius: 16rpx;
  107. position: relative;
  108. padding-top: 40%;
  109. image {
  110. border-radius: 10rpx;
  111. position: absolute;
  112. top: 0;
  113. left: 0;
  114. width: 100%;
  115. height: 100%;
  116. object-fit: cover;
  117. }
  118. }
  119. .text {
  120. font-size: 30rpx;
  121. font-family: PingFang SC;
  122. font-weight: bold;
  123. color: #282828;
  124. margin: 20rpx 0;
  125. }
  126. .bottom {
  127. .sales {
  128. font-size: 22rpx;
  129. color: #8e8e8e;
  130. .money {
  131. font-size: 42rpx;
  132. font-weight: bold;
  133. margin-right: 18rpx;
  134. text {
  135. font-size: 28rpx;
  136. }
  137. }
  138. }
  139. .cart {
  140. height: 56rpx;
  141. .pictrue {
  142. color: var(--view-theme);
  143. font-size: 46rpx;
  144. width: 50rpx;
  145. height: 50rpx;
  146. text-align: center;
  147. line-height: 50rpx;
  148. }
  149. .num {
  150. font-size: 30rpx;
  151. color: #282828;
  152. font-weight: bold;
  153. width: 80rpx;
  154. text-align: center;
  155. }
  156. }
  157. .bnt {
  158. padding: 0 30rpx;
  159. height: 56rpx;
  160. line-height: 56rpx;
  161. background: var(--view-theme);
  162. border-radius: 42rpx;
  163. font-size: 26rpx;
  164. color: #fff;
  165. position: relative;
  166. &.end {
  167. background: rgba(203, 203, 203, 1);
  168. }
  169. .num {
  170. background-color: var(--view-priceColor);
  171. min-width: 12rpx;
  172. color: #fff;
  173. border-radius: 15px;
  174. position: absolute;
  175. right: -14rpx;
  176. top: -15rpx;
  177. font-size: 22rpx;
  178. padding: 0 10rpx;
  179. height: 34rpx;
  180. line-height: 34rpx;
  181. }
  182. }
  183. }
  184. }
  185. }
  186. </style>