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