index.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <div class="quality-recommend">
  3. <div class="slider-banner swiper">
  4. <view class="swiper">
  5. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration"
  6. indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
  7. <block v-for="(item,index) in imgUrls" :key="index">
  8. <swiper-item>
  9. <image :src="item.pic" class="slide-image"></image>
  10. </swiper-item>
  11. </block>
  12. </swiper>
  13. </view>
  14. </div>
  15. <div class="title acea-row row-center-wrapper">
  16. <div class="line"></div>
  17. <div class="name">
  18. <span class="iconfont" :class="icon"></span>{{ name }}
  19. </div>
  20. <div class="line"></div>
  21. </div>
  22. <view class="wrapper">
  23. <GoodList :bastList="goodsList" :is-sort="false"></GoodList>
  24. <view class="txt-bar" v-if="goodsList.length>0 && !isScroll">我是有底线的~</view>
  25. <emptyPage v-if="goodsList.length==0 && !isScroll" title="暂无数据~"></emptyPage>
  26. </view>
  27. </div>
  28. </template>
  29. <script>
  30. import emptyPage from '@/components/emptyPage.vue'
  31. import GoodList from "@/components/goodList";
  32. import { getGroomList } from "@/api/store";
  33. export default {
  34. name: "HotNewGoods",
  35. components: {
  36. GoodList,
  37. emptyPage,
  38. },
  39. props: {},
  40. data: function() {
  41. return {
  42. imgUrls: [],
  43. goodsList: [],
  44. name: "",
  45. icon: "",
  46. type:0,
  47. autoplay:true,
  48. circular:true,
  49. interval: 3000,
  50. duration: 500,
  51. page:1,
  52. limit:8,
  53. isScroll:true
  54. };
  55. },
  56. onLoad: function(option) {
  57. this.type = option.type
  58. this.titleInfo();
  59. this.getIndexGroomList();
  60. },
  61. methods: {
  62. titleInfo: function() {
  63. if (this.type === "1") {
  64. this.name = "精品推荐";
  65. this.icon = "icon-jingpintuijian";
  66. uni.setNavigationBarTitle({
  67. title:"精品推荐"
  68. })
  69. } else if (this.type === "2") {
  70. this.name = "热门榜单";
  71. this.icon = "icon-remen";
  72. uni.setNavigationBarTitle({
  73. title:"热门榜单"
  74. })
  75. } else if (this.type === "3") {
  76. this.name = "首发新品";
  77. this.icon = "icon-xinpin";
  78. uni.setNavigationBarTitle({
  79. title:"首发新品"
  80. })
  81. }else if (this.type === "4") {
  82. this.name = "促销单品";
  83. this.icon = "icon-xinpin";
  84. uni.setNavigationBarTitle({
  85. title:"促销单品"
  86. })
  87. }
  88. },
  89. getIndexGroomList: function() {
  90. if(!this.isScroll) return
  91. let that = this;
  92. let type = this.type;
  93. getGroomList(type,{
  94. page:this.page,
  95. limit:this.limit
  96. }).then(res => {
  97. that.imgUrls = res.data.banner;
  98. that.goodsList = that.goodsList.concat(res.data.list);
  99. that.isScroll = res.data.list.length>=that.limit
  100. that.page++
  101. })
  102. .catch(function(res) {
  103. that.$util.Tips({ title: res });
  104. });
  105. }
  106. },
  107. onReachBottom() {
  108. this.getIndexGroomList()
  109. }
  110. };
  111. </script>
  112. <style lang="scss">
  113. /deep/ .empty-box{
  114. background-color: #f5f5f5;
  115. }
  116. .swiper,swiper,swiper-item,.slide-image{
  117. width: 100%;
  118. height: 280rpx;
  119. }
  120. .quality-recommend {
  121. .wrapper{
  122. background: #fff;
  123. }
  124. .title {
  125. height: 120rpx;
  126. font-size:32rpx;
  127. color: #282828;
  128. background-color: #f5f5f5;
  129. .line{
  130. width: 230rpx;
  131. height: 2rpx;
  132. background-color: #e9e9e9;
  133. }
  134. }
  135. }
  136. .txt-bar{
  137. padding: 20rpx 0;
  138. text-align: center;
  139. font-size: 26rpx;
  140. color: #666;
  141. background-color: #f5f5f5;
  142. }
  143. </style>