commodity.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <view class="service">
  3. <view class="recommend">
  4. <view
  5. class="recommend-item"
  6. @click="onrecommend(index, item.value, '')"
  7. :class="{ red: activeIndex == index }"
  8. v-for="(item, index) in choice"
  9. :key="index"
  10. >
  11. {{ item.name }}
  12. </view>
  13. <view
  14. class="recommend-item"
  15. @click="onrecommend(index + 3, '', item.id)"
  16. :class="{ red: activeIndex == index + 3 }"
  17. v-for="(item, index) in cate"
  18. :key="index + 3"
  19. >
  20. {{ item.name }}
  21. </view>
  22. </view>
  23. <view class="content" v-if="good && good.length > 0">
  24. <view class="content-item" v-for="item in good" :key="item.id" @click="
  25. goProductDetails(item.id)
  26. ">
  27. <image :src="item.cover" mode="" class="neironga2"></image>
  28. <view class="name"> {{ item.title }} </view>
  29. <view class="number">
  30. <view class="large">
  31. <rich-text
  32. :nodes="$mUtil.priceBigSmall(item.sale_price)"
  33. ></rich-text>
  34. </view>
  35. <view class="small">¥{{ item.market_price }}</view>
  36. </view>
  37. <view class="sell"> 已售{{ item.result_sale_num }}件 </view>
  38. </view>
  39. </view>
  40. <nodata v-else :config="{ top: 1, content: '暂无商品~' }"></nodata>
  41. </view>
  42. </template>
  43. <script>
  44. export default {
  45. data() {
  46. return {
  47. choice: [
  48. {
  49. id: 1,
  50. name: "推荐",
  51. value: "recommend",
  52. },
  53. {
  54. id: 2,
  55. name: "热销",
  56. value: "hot",
  57. },
  58. {
  59. id: 3,
  60. name: "新品",
  61. value: "new",
  62. },
  63. ],
  64. activeIndex: -1,
  65. };
  66. },
  67. props: {
  68. cate: {
  69. type: Array,
  70. default: [],
  71. },
  72. good: {
  73. type: Array,
  74. default: [],
  75. },
  76. isActive:{
  77. type:Number,
  78. default:0
  79. }
  80. },
  81. watch: {
  82. cate(e){
  83. this.activeIndex =-1;
  84. },
  85. },
  86. onLoad() {
  87. this.activeIndex = this.initNum;
  88. },
  89. methods: {
  90. goProductDetails(id){
  91. uni.navigateTo({
  92. url: this.isActive==0?'/pages/product/goods/serviceGood?id='+id:'/pages/product/goods/goods?id='+id,
  93. });
  94. },
  95. onrecommend(index, type, groupId) {
  96. this.activeIndex = index;
  97. this.$emit("typeChange", { type: type, groupId: groupId });
  98. },
  99. },
  100. };
  101. </script>
  102. <style scoped lang="scss">
  103. .content {
  104. display: flex;
  105. flex-wrap: wrap;
  106. justify-content: space-between;
  107. padding: 30rpx;
  108. background-color: #f5f5f5;
  109. .content-item {
  110. background-color: #ffffff;
  111. border-radius: 18rpx;
  112. overflow: hidden;
  113. margin-bottom: 30rpx;
  114. image {
  115. width: 336rpx;
  116. height: 336rpx;
  117. background-color: red;
  118. }
  119. .number {
  120. display: flex;
  121. align-items: center;
  122. padding: 0 30rpx;
  123. .large {
  124. color: #ed3d07;
  125. font-size: 20rpx;
  126. font-weight: Medium;
  127. text {
  128. font-size: 36rpx;
  129. font-weight: Bold;
  130. }
  131. }
  132. .small {
  133. font-size: 22rpx;
  134. color: #999999;
  135. font-weight: 400;
  136. text-decoration: line-through;
  137. margin-left: 16rpx;
  138. }
  139. }
  140. .sell {
  141. padding: 0 30rpx;
  142. font-size: 22rpx;
  143. font-weight: 400;
  144. color: #999999;
  145. margin-bottom: 36rpx;
  146. margin-top: 8rpx;
  147. }
  148. .name {
  149. width: 276rpx;
  150. padding: 0 30rpx;
  151. overflow: hidden;
  152. text-overflow: ellipsis;
  153. display: -webkit-box;
  154. -webkit-line-clamp: 2;
  155. -webkit-box-orient: vertical;
  156. word-wrap: break-word;
  157. word-break: break-all;
  158. white-space: normal !important;
  159. }
  160. }
  161. }
  162. .recommend {
  163. display: flex;
  164. background-color: #f5f5f5;
  165. border-radius: 40rpx 40rpx 0 0;
  166. .recommend-item {
  167. font-weight: 500;
  168. padding: 15rpx 30rpx;
  169. background-color: #ffffff;
  170. margin: 40rpx 0 30rpx 30rpx;
  171. border-radius: 34rpx;
  172. }
  173. .red {
  174. background: #00321e;
  175. color: #d5c49b;
  176. }
  177. }
  178. </style>