recommend.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. <template>
  2. <view class="content">
  3. <view class="recommend">
  4. <view class="commodity-item" v-for="(item, index) in recommendList" @click="navToDetailPages(item)">
  5. <view class="commodity-prc">
  6. <image :src="item.image" mode=""></image>
  7. <!-- <view class="fanli" v-if="item.type == 1">
  8. <view class="fanli-bg"><image src="../../static/img/index-fanl.png" mode=""></image></view>
  9. <view class="fanli-font flex">
  10. <view class="font-left">购物最高可返消费金额的</view>
  11. <view class="font-right">10<text>%</text></view>
  12. </view>
  13. </view> -->
  14. </view>
  15. <view class="commodity-info">
  16. <view class="commodity-name clamp">{{ item.store_name }}</view>
  17. <view class="commodity-systom clamp">{{ item.systom }}</view>
  18. <view class="commodity-price">
  19. ¥{{ item.price }}
  20. <text>¥{{ item.ot_price }}</text>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import { productIndexs } from '@/api/index.js';
  29. export default {
  30. data() {
  31. return {
  32. recommendList: [],
  33. id: ''
  34. };
  35. },
  36. onLoad(option) {
  37. if (option.type) {
  38. this.id = option.type;
  39. }
  40. this.loadData();
  41. },
  42. methods: {
  43. // 获取首页数据
  44. loadData() {
  45. productIndexs({}, this.id).then(({ data }) => {
  46. this.recommendList = data.list; // 为你推荐
  47. console.log('为你推荐', this.recommendList);
  48. });
  49. },
  50. // 跳转热销商品
  51. navToDetailPage(item) {
  52. uni.navigateTo({
  53. url: '/pages/product/product?id=' + item.id
  54. });
  55. },
  56. navToDetailPages(e) {
  57. uni.navigateTo({
  58. url: '/pages/product/product?id=' + e.id
  59. });
  60. }
  61. }
  62. };
  63. </script>
  64. <style lang="scss">
  65. .recommend {
  66. padding: 36rpx 20rpx;
  67. margin-top: 20rpx;
  68. display: flex;
  69. flex-wrap: wrap;
  70. background-color: #FFFFFF;
  71. }
  72. .commodity-item {
  73. width: 334rpx;
  74. background: #ffffff;
  75. box-shadow: 0px 0px 20rpx 0px rgba(50, 50, 52, 0.06);
  76. border-radius: 10rpx;
  77. margin: 0 10rpx;
  78. .commodity-prc {
  79. width: 330rpx;
  80. height: 330rpx;
  81. border-radius: 10rpx;
  82. position: relative;
  83. image {
  84. border-radius: 10rpx;
  85. width: 100%;
  86. height: 100%;
  87. }
  88. .fanli {
  89. position: absolute;
  90. bottom: 0;
  91. left: 0;
  92. width: 344rpx;
  93. height: 96rpx;
  94. .fanli-bg {
  95. position: absolute;
  96. bottom: 0;
  97. left: 0;
  98. width: 344rpx;
  99. height: 96rpx;
  100. }
  101. .fanli-font {
  102. position: relative;
  103. z-index: 10;
  104. color: #ffffff;
  105. height: 96rpx;
  106. align-items: flex-end;
  107. padding: 36rpx 10rpx 10rpx;
  108. .font-left {
  109. width: 226px;
  110. font-size: 20rpx;
  111. font-family: PingFang SC;
  112. font-weight: 500;
  113. color: #ffffff;
  114. }
  115. .font-right {
  116. font-size: 62rpx;
  117. font-family: Microsoft YaHei;
  118. font-weight: bold;
  119. color: #ffffff;
  120. text {
  121. font-size: 26rpx;
  122. }
  123. }
  124. }
  125. }
  126. }
  127. .commodity-info {
  128. padding: 28rpx 20rpx 35rpx 24rpx;
  129. .commodity-name {
  130. width: 100%;
  131. font-size: 30rpx;
  132. font-family: PingFang SC;
  133. font-weight: bold;
  134. color: #333333;
  135. }
  136. .commodity-systom {
  137. margin-top: 16rpx;
  138. font-size: 26rpx;
  139. font-family: PingFang SC;
  140. font-weight: 500;
  141. color: #666666;
  142. }
  143. .commodity-price {
  144. margin-top: 34rpx;
  145. font-size: 36rpx;
  146. font-family: PingFang SC;
  147. font-weight: bold;
  148. color: #e83f30;
  149. text {
  150. display: inline-block;
  151. padding-left: 6rpx;
  152. font-size: 26rpx;
  153. font-family: PingFang SC;
  154. font-weight: bold;
  155. text-decoration: line-through;
  156. color: #999999;
  157. }
  158. }
  159. }
  160. }
  161. </style>