index.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  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.img" 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. console.log(option);
  59. this.titleInfo();
  60. this.getIndexGroomList();
  61. },
  62. methods: {
  63. titleInfo: function() {
  64. if (this.type === "1") {
  65. this.name = "精品推荐";
  66. this.icon = "icon-jingpintuijian";
  67. // document.title = "精品推荐";
  68. uni.setNavigationBarTitle({
  69. title:"精品推荐"
  70. })
  71. } else if (this.type === "2") {
  72. this.name = "热门榜单";
  73. this.icon = "icon-remen";
  74. uni.setNavigationBarTitle({
  75. title:"热门榜单"
  76. })
  77. } else if (this.type === "3") {
  78. this.name = "首发新品";
  79. this.icon = "icon-xinpin";
  80. uni.setNavigationBarTitle({
  81. title:"首发新品"
  82. })
  83. }else if (this.type === "4") {
  84. this.name = "促销单品";
  85. this.icon = "icon-xinpin";
  86. uni.setNavigationBarTitle({
  87. title:"促销单品"
  88. })
  89. }
  90. },
  91. getIndexGroomList: function() {
  92. if(!this.isScroll) return
  93. let that = this;
  94. let type = this.type;
  95. getGroomList(type,{
  96. page:this.page,
  97. limit:this.limit
  98. }).then(res => {
  99. that.imgUrls = res.data.banner;
  100. that.goodsList = that.goodsList.concat(res.data.list);
  101. that.isScroll = res.data.list.length>=that.limit
  102. that.page++
  103. })
  104. .catch(function(res) {
  105. that.$util.Tips({ title: res });
  106. });
  107. }
  108. },
  109. onReachBottom() {
  110. this.getIndexGroomList()
  111. }
  112. };
  113. </script>
  114. <style lang="scss">
  115. /deep/ .empty-box{
  116. background-color: #f5f5f5;
  117. }
  118. .swiper,swiper,swiper-item,.slide-image{
  119. width: 100%;
  120. height: 280rpx;
  121. }
  122. .quality-recommend {
  123. .wrapper{
  124. background: #fff;
  125. }
  126. .title {
  127. height: 120rpx;
  128. font-size:32rpx;
  129. color: #282828;
  130. background-color: #f5f5f5;
  131. .line{
  132. width: 230rpx;
  133. height: 2rpx;
  134. background-color: #e9e9e9;
  135. }
  136. }
  137. }
  138. .txt-bar{
  139. padding: 20rpx 0;
  140. text-align: center;
  141. font-size: 26rpx;
  142. color: #666;
  143. background-color: #f5f5f5;
  144. }
  145. </style>