index.vue 4.1 KB

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