index.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <!-- 精品推荐模块 -->
  3. <div class="quality-recommend" :style="colorStyle">
  4. <div class="slider-banner swiper">
  5. <view class="swiper">
  6. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval"
  7. :duration="duration" indicator-color="rgba(255,255,255,0.6)" indicator-active-color="#fff">
  8. <block v-for="(item, index) in imgUrls" :key="index">
  9. <swiper-item>
  10. <image :src="item.img" class="slide-image" @click="goPages(item)"></image>
  11. </swiper-item>
  12. </block>
  13. </swiper>
  14. </view>
  15. </div>
  16. <div class="title acea-row row-center-wrapper">
  17. <div class="line"></div>
  18. <div class="name">
  19. <span class="iconfont" :class="icon"></span>
  20. <!-- {{ name }}1=精品推荐,=热门榜单,3=首发新品,4=促销单品 -->
  21. <span v-if="type == 1">精品推荐</span>
  22. <span v-if="type == 2">热门榜单</span>
  23. <span v-if="type == 3">首发新品</span>
  24. <span v-if="type == 4">促销单品</span>
  25. </div>
  26. <div class="line"></div>
  27. </div>
  28. <view class="wrapper">
  29. <GoodList :bastList="goodsList" :is-sort="false"></GoodList>
  30. <view class="txt-bar" v-if="goodsList.length > 0 && !isScroll">没有更多内容啦~</view>
  31. <emptyPage v-if="goodsList.length == 0 && !isScroll" title="暂无数据~"></emptyPage>
  32. </view>
  33. <home v-if="navigation"></home>
  34. <pageFooter v-if="footerStatus"></pageFooter>
  35. </div>
  36. </template>
  37. <script>
  38. import emptyPage from '@/components/emptyPage.vue';
  39. import GoodList from '@/components/goodList';
  40. import pageFooter from '@/components/pageFooter/index.vue';
  41. import {
  42. getGroomList
  43. } from '@/api/store';
  44. import {
  45. goPage
  46. } from '@/libs/order.js';
  47. import home from '@/components/home/index.vue'
  48. import colors from "@/mixins/color";
  49. export default {
  50. name: 'HotNewGoods',
  51. components: {
  52. GoodList,
  53. emptyPage,
  54. home,
  55. pageFooter
  56. },
  57. props: {},
  58. mixins: [colors],
  59. data: function() {
  60. return {
  61. imgUrls: [],
  62. goodsList: [],
  63. name: '',
  64. icon: '',
  65. type: 0,
  66. autoplay: true,
  67. circular: true,
  68. interval: 3000,
  69. duration: 500,
  70. page: 1,
  71. limit: 8,
  72. isScroll: true,
  73. footerStatus: false
  74. };
  75. },
  76. onLoad: function(option) {
  77. if (uni.getStorageSync('FOOTER_BAR')) {
  78. this.footerStatus = true
  79. uni.hideTabBar()
  80. }
  81. this.type = option.type;
  82. this.titleInfo();
  83. this.name = option.name;
  84. // document.title = "精品推荐";
  85. uni.setNavigationBarTitle({
  86. title: option.name
  87. });
  88. this.getIndexGroomList();
  89. },
  90. onShow(){
  91. uni.removeStorageSync('form_type_cart');
  92. },
  93. methods: {
  94. titleInfo: function() {
  95. if (this.type === '1') {
  96. this.icon = 'icon-jingpintuijian';
  97. } else if (this.type === '2') {
  98. this.icon = 'icon-remen';
  99. } else if (this.type === '3') {
  100. this.icon = 'icon-xinpin';
  101. } else if (this.type === '4') {
  102. this.icon = 'icon-xinpin';
  103. }
  104. },
  105. goPages(item) {
  106. let url = item.link || '';
  107. goPage().then(res => {
  108. this.$util.JumpPath(url);
  109. });
  110. },
  111. getIndexGroomList() {
  112. if (!this.isScroll) return;
  113. let that = this;
  114. let type = this.type;
  115. getGroomList(type, {
  116. page: this.page,
  117. limit: this.limit
  118. })
  119. .then(res => {
  120. that.imgUrls = res.data.banner;
  121. that.goodsList = that.goodsList.concat(res.data.list);
  122. that.isScroll = res.data.list.length >= that.limit;
  123. that.page++;
  124. })
  125. .catch(function(res) {
  126. that.$util.Tips({
  127. title: res
  128. });
  129. });
  130. },
  131. onReachBottom() {
  132. this.getIndexGroomList();
  133. }
  134. }
  135. }
  136. </script>
  137. <style lang="scss">
  138. /deep/ .empty-box {
  139. background-color: #f5f5f5;
  140. }
  141. .swiper,
  142. swiper,
  143. swiper-item,
  144. .slide-image {
  145. width: 100%;
  146. height: 280rpx;
  147. }
  148. .quality-recommend {
  149. .wrapper {
  150. background: #fff;
  151. }
  152. .title {
  153. height: 120rpx;
  154. font-size: 32rpx;
  155. color: #282828;
  156. background-color: #f5f5f5;
  157. .name {
  158. margin: 0 20rpx;
  159. .iconfont {
  160. margin-right: 10rpx;
  161. }
  162. }
  163. .line {
  164. width: 230rpx;
  165. height: 2rpx;
  166. background-color: #e9e9e9;
  167. }
  168. }
  169. }
  170. .txt-bar {
  171. padding: 20rpx 0;
  172. text-align: center;
  173. font-size: 26rpx;
  174. color: #999;
  175. background-color: #f5f5f5;
  176. }
  177. </style>