hot.vue 4.2 KB

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