index.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <template>
  2. <div class="quality-recommend" :style="colorStyle">
  3. <div class="slider-banner swiper">
  4. <view class="swiper">
  5. <swiper indicator-dots="true" :autoplay="autoplay" :circular="circular" :interval="interval"
  6. :duration="duration" 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" @click="goPages(item)"></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>
  19. {{ typeName[type]}}
  20. </div>
  21. <div class="line"></div>
  22. </div>
  23. <view class="wrapper">
  24. <GoodList :bastList="goodsList" :is-sort="false"></GoodList>
  25. <view class="txt-bar" v-if="goodsList.length > 0 && !isScroll">我是有底线的~</view>
  26. <emptyPage v-if="goodsList.length == 0 && !isScroll" title="暂无数据~"></emptyPage>
  27. </view>
  28. <!-- #ifndef MP -->
  29. <home></home>
  30. <!-- #endif -->
  31. <pageFooter v-if="footerStatus"></pageFooter>
  32. </div>
  33. </template>
  34. <script>
  35. import emptyPage from '@/components/emptyPage.vue';
  36. import GoodList from '@/components/goodList';
  37. import pageFooter from '@/components/pageFooter/index.vue';
  38. import {
  39. getGroomList
  40. } from '@/api/store';
  41. import {
  42. goPage
  43. } from '@/libs/order.js';
  44. import home from '@/components/home/index.vue'
  45. import colors from "@/mixins/color";
  46. export default {
  47. name: 'HotNewGoods',
  48. components: {
  49. GoodList,
  50. emptyPage,
  51. home,
  52. pageFooter
  53. },
  54. props: {},
  55. mixins: [colors],
  56. data: function() {
  57. return {
  58. imgUrls: [],
  59. goodsList: [],
  60. name: '',
  61. icon: '',
  62. type: 0,
  63. typeName: ['', '精品推荐', '热门榜单', '首发新品',
  64. '促销单品'
  65. ],
  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. methods: {
  91. titleInfo: function() {
  92. if (this.type === '1') {
  93. this.icon = 'icon-jingpintuijian';
  94. } else if (this.type === '2') {
  95. this.icon = 'icon-remen';
  96. } else if (this.type === '3') {
  97. this.icon = 'icon-xinpin';
  98. } else if (this.type === '4') {
  99. this.icon = 'icon-xinpin';
  100. }
  101. },
  102. goPages(item) {
  103. let url = item.link || '';
  104. goPage().then(res => {
  105. if (url.indexOf('http') != -1) {
  106. // #ifdef H5
  107. location.href = url;
  108. // #endif
  109. } else {
  110. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart',
  111. '/pages/user/index'
  112. ].indexOf(url) == -1) {
  113. uni.navigateTo({
  114. url: url
  115. });
  116. } else {
  117. uni.navigateTo({
  118. url: url
  119. });
  120. }
  121. }
  122. });
  123. },
  124. getIndexGroomList() {
  125. if (!this.isScroll) return;
  126. let that = this;
  127. let type = this.type;
  128. getGroomList(type, {
  129. page: this.page,
  130. limit: this.limit
  131. })
  132. .then(res => {
  133. that.imgUrls = res.data.banner;
  134. that.goodsList = that.goodsList.concat(res.data.list);
  135. that.isScroll = res.data.list.length >= that.limit;
  136. that.page++;
  137. })
  138. .catch(function(res) {
  139. that.$util.Tips({
  140. title: res
  141. });
  142. });
  143. },
  144. onReachBottom() {
  145. this.getIndexGroomList();
  146. }
  147. }
  148. }
  149. </script>
  150. <style lang="scss">
  151. /deep/ .empty-box {
  152. background-color: #f5f5f5;
  153. }
  154. .swiper,
  155. swiper,
  156. swiper-item,
  157. .slide-image {
  158. width: 100%;
  159. height: 280rpx;
  160. }
  161. .quality-recommend {
  162. .wrapper {
  163. background: #fff;
  164. }
  165. .title {
  166. height: 120rpx;
  167. font-size: 32rpx;
  168. color: #282828;
  169. background-color: #f5f5f5;
  170. .name {
  171. margin: 0 20rpx;
  172. .iconfont {
  173. margin-right: 10rpx;
  174. }
  175. }
  176. .line {
  177. width: 230rpx;
  178. height: 2rpx;
  179. background-color: #e9e9e9;
  180. }
  181. }
  182. }
  183. .txt-bar {
  184. padding: 20rpx 0;
  185. text-align: center;
  186. font-size: 26rpx;
  187. color: #666;
  188. background-color: #f5f5f5;
  189. }
  190. </style>