recommend.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <template>
  2. <view class="recommend">
  3. <view class="home_recommend_ul flex">
  4. <view class="home_recommend_li" v-for="(item,index) in shopList" :key="index" @click="goMessage(item,0)">
  5. <view class="home_recommend_li_img">
  6. <view class="home_recommend_li_img_top flex">
  7. <view class="home_recommend_li_img_box">
  8. <image :src="item.image" mode="aspectFill"></image>
  9. </view>
  10. <view class="home_recommend_li_img_right" v-if="item.right.length != 0">
  11. <image :src="items" mode="aspectFill" v-for="(items,index) in item.right" :key="index"></image>
  12. </view>
  13. </view>
  14. <view class="home_recommend_li_img_bot">
  15. <image :src="items" mode="aspectFill" v-for="(items,index) in item.bot" :key="index"></image>
  16. </view>
  17. </view>
  18. <view class="home_recommend_li_main">
  19. <view class="home_recommend_li_price">价值:¥{{ item.price_min }}~¥{{ item.price_max }}</view>
  20. <view class="home_recommend_li_name">{{ item.box_name }}</view>
  21. <view class="home_recommend_li_glod flex">
  22. <text>{{ item.coin_price }}金币</text>
  23. <text>共{{ item.goods_num }}款商品</text>
  24. </view>
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. </template>
  30. <script>
  31. export default {
  32. data() {
  33. return {
  34. page:1,
  35. pages:0,//
  36. shopList:[],//推荐列表
  37. };
  38. },
  39. methods:{
  40. //去详情
  41. goMessage (item,type) {
  42. uni.navigateTo({url:'/pages/index/details?id=' + item.box_id + '&type=' + type})
  43. },
  44. //获取推荐列表
  45. getShopList () {
  46. this.$api.recommend().then(res=>{
  47. if (res.code === 1) {
  48. res.data.data.forEach(item=>{
  49. item.image = item.goods_images[0]
  50. item.right = []
  51. item.bot = []
  52. item.goods_images.forEach((em,index)=>{
  53. if (index > 0 && index < 3) {
  54. item.right.push(em)
  55. }
  56. if (index > 2) {
  57. item.bot.push(em)
  58. }
  59. })
  60. })
  61. this.shopList = this.page == 1 ? res.data.data : [...this.shopList,...res.data.data],
  62. this.pages = res.data.last_page
  63. }
  64. })
  65. },
  66. },
  67. onLoad() {
  68. this.getShopList()
  69. }
  70. }
  71. </script>
  72. <style lang="scss">
  73. .recommend {
  74. padding-top: 30rpx;
  75. }
  76. .home_recommend_ul {
  77. flex-wrap: wrap;
  78. padding: 0 28rpx;
  79. .home_recommend_li {
  80. width: 332rpx;
  81. padding: 20rpx;
  82. margin-bottom: 30rpx;
  83. background: #FFFFFF;
  84. box-shadow: 0rpx 0rpx 10rpx 0rpx rgba(153, 153, 153, 0.1);
  85. border-radius: 10rpx;
  86. .home_recommend_li_img {
  87. height: 295rpx;
  88. .home_recommend_li_img_top {
  89. align-items: flex-start;
  90. }
  91. .home_recommend_li_img_bot {
  92. display: flex;
  93. margin-top: 20rpx;
  94. justify-content: flex-end;
  95. image {
  96. width: 85rpx;
  97. height: 85rpx;
  98. margin-left: 20rpx;
  99. &:first-child {
  100. margin-left: 0;
  101. }
  102. border-radius: 6rpx;
  103. }
  104. }
  105. .home_recommend_li_img_box {
  106. image {
  107. width: 190rpx;
  108. height: 190rpx;
  109. border-radius: 6rpx;
  110. }
  111. }
  112. .home_recommend_li_img_right {
  113. image {
  114. width: 85rpx;
  115. height: 85rpx;
  116. border-radius: 6rpx;
  117. &:first-child {
  118. margin-bottom: 20rpx;
  119. }
  120. }
  121. }
  122. }
  123. .home_recommend_li_price {
  124. // width: 280rpx;
  125. height: 40rpx;
  126. color: #FFFFFF;
  127. margin: 20rpx 0;
  128. font-size: 26rpx;
  129. line-height: 40rpx;
  130. padding-left: 18rpx;
  131. background: #F6AF32;
  132. border-radius: 20rpx;
  133. }
  134. .home_recommend_li_name {
  135. font-size: 28rpx;
  136. display: -webkit-box;
  137. -webkit-box-orient: vertical;
  138. -webkit-line-clamp: 2;
  139. overflow: hidden;
  140. height: 76rpx;
  141. }
  142. .home_recommend_li_glod {
  143. margin-top: 30rpx;
  144. text {
  145. color: #CF271B;
  146. font-size: 26tpx;
  147. &:last-child {
  148. color: #666666;
  149. font-size: 24rpx;
  150. }
  151. }
  152. }
  153. }
  154. }
  155. </style>