index.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. if (url.indexOf('http') != -1) {
  109. // #ifdef H5
  110. location.href = url
  111. // #endif
  112. // #ifdef MP || APP-PLUS
  113. uni.navigateTo({
  114. url: `/pages/annex/web_view/index?url=${url}`
  115. });
  116. // #endif
  117. } else {
  118. if (['/pages/goods_cate/goods_cate', '/pages/order_addcart/order_addcart',
  119. '/pages/user/index','/pages/index/index','/pages/store_cate/store_cate'
  120. ].indexOf(url) == -1) {
  121. uni.navigateTo({
  122. url: url
  123. });
  124. } else {
  125. uni.switchTab({
  126. url: url
  127. });
  128. }
  129. }
  130. });
  131. },
  132. getIndexGroomList() {
  133. if (!this.isScroll) return;
  134. let that = this;
  135. let type = this.type;
  136. getGroomList(type, {
  137. page: this.page,
  138. limit: this.limit
  139. })
  140. .then(res => {
  141. that.imgUrls = res.data.banner;
  142. that.goodsList = that.goodsList.concat(res.data.list);
  143. that.isScroll = res.data.list.length >= that.limit;
  144. that.page++;
  145. })
  146. .catch(function(res) {
  147. that.$util.Tips({
  148. title: res
  149. });
  150. });
  151. },
  152. onReachBottom() {
  153. this.getIndexGroomList();
  154. }
  155. }
  156. }
  157. </script>
  158. <style lang="scss">
  159. /deep/ .empty-box {
  160. background-color: #f5f5f5;
  161. }
  162. .swiper,
  163. swiper,
  164. swiper-item,
  165. .slide-image {
  166. width: 100%;
  167. height: 280rpx;
  168. }
  169. .quality-recommend {
  170. .wrapper {
  171. background: #fff;
  172. }
  173. .title {
  174. height: 120rpx;
  175. font-size: 32rpx;
  176. color: #282828;
  177. background-color: #f5f5f5;
  178. .name {
  179. margin: 0 20rpx;
  180. .iconfont {
  181. margin-right: 10rpx;
  182. }
  183. }
  184. .line {
  185. width: 230rpx;
  186. height: 2rpx;
  187. background-color: #e9e9e9;
  188. }
  189. }
  190. }
  191. .txt-bar {
  192. padding: 20rpx 0;
  193. text-align: center;
  194. font-size: 26rpx;
  195. color: #999;
  196. background-color: #f5f5f5;
  197. }
  198. </style>