home.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <view class="box-sizing-b w-full">
  3. <use-tabbar></use-tabbar>
  4. <!-- 头部组件 -->
  5. <use-header :search-tip="searchTip" :search-auto="searchAuto" :searchId="id" :source="1"
  6. @search="search"></use-header>
  7. <!-- 轮播区 -->
  8. <use-swiper v-if="fetch.ad && fetch.ad.focus && fetch.ad.focus.length > 0" :data="fetch.ad.focus"></use-swiper>
  9. <!-- 滚动区 -->
  10. <view class="move-area use-area margin-lr-sm" v-if="fetch.ad && fetch.ad.notice && fetch.ad.notice.length > 0">
  11. <u-notice-bar :text="fetch.ad.notice" direction="row" bgColor="#fff" color="#000"></u-notice-bar>
  12. </view>
  13. <!-- 分类区 -->
  14. <view class="category-area use-area margin-lr-sm dgrid"
  15. v-if="fetch.ad && fetch.ad.nav && fetch.ad.nav.length > 0">
  16. <view class="category-item dflex dflex-flow-c margin-bottom-sm" v-for="(item, index) in fetch.ad.nav"
  17. :key="index" @click="(e) => Dever.location(fetch.ad.nav[e].link)">
  18. <image class="margin-bottom-xs" lazy-load :src="item.info"></image>
  19. <text class="tac clamp">{{ item.title }}</text>
  20. </view>
  21. </view>
  22. <view class="tabs-wrapper" v-if="fetch.top && fetch.top.length > 0">
  23. <u-tabs :list="fetch.top" @click="loadTop" lineColor="#ff6b6b" activeColor="#ff6b6b" :activeStyle="{
  24. color: '#303133',
  25. fontWeight: 'bold',
  26. transform: 'scale(1.05)'
  27. }" :inactiveStyle="{
  28. color: '#606266',
  29. transform: 'scale(1)'
  30. }" scrollable></u-tabs>
  31. </view>
  32. <!-- 精选推荐 -->
  33. <use-info v-if="fetch.ad && fetch.ad.info && fetch.ad.info.length > 0 && fetch.ad.info[0]"
  34. :info="fetch.ad.info[0]"></use-info>
  35. <!-- 资源分类 -->
  36. <view v-if="fetch.cate && fetch.cate.length > 0" v-for="(item, index) in fetch.cate" :key="index">
  37. <view class="source-area use-area">
  38. <!-- 列表标题 -->
  39. <use-list-title :title="item.name" size="32" fwt="600" color="#333" :index="index"
  40. @goto="Dever.location('source/list?id=' + item.id + '&title=' + item.name)"></use-list-title>
  41. <use-goods-list :data="item.list"></use-goods-list>
  42. </view>
  43. <use-info v-if="fetch.ad && fetch.ad.info && fetch.ad.info.length > 0 && fetch.ad.info[index+1]"
  44. :info="fetch.ad.info[index+1]"></use-info>
  45. </view>
  46. <use-copyright :title="fetch.channel.name" :desc="fetch.channel.desc"
  47. v-if="fetch && fetch.channel"></use-copyright>
  48. <use-totop ref="usetop"></use-totop>
  49. <!--
  50. <view class="fixed-swiper">
  51. <view class="" @click="toYuyue">
  52. <image src="https://img20.360buyimg.com/jdcms/s480x480_jfs/t1/234533/3/36568/214409/67d7da40F3d017a82/842a9f77bc14485c.jpg" mode="widthFix" class="image"></image>
  53. </view>
  54. <view class="fixed-swiper-close" @click="closefixedSwiper()">
  55. <text class="gui-icons gui-block icon icon-">&#xe610;</text>
  56. </view>
  57. </view>
  58. -->
  59. </view>
  60. </template>
  61. <script>
  62. export default {
  63. data() {
  64. return {
  65. // 头部参数
  66. searchAuto: !0,
  67. searchTip: '请输入搜索关键字',
  68. id: 0,
  69. top_id: 0,
  70. fetch: {},
  71. };
  72. },
  73. onPageScroll(e) {
  74. this.$refs.usetop.change(e.scrollTop);
  75. },
  76. onPullDownRefresh() {
  77. this.loadData();
  78. },
  79. onLoad(options) {
  80. this.id = options.id;
  81. this.top_id = 0;
  82. },
  83. onShow() {
  84. this.loadData();
  85. },
  86. methods: {
  87. // 加载数据
  88. loadData() {
  89. this.DeverApi.get(this, 'source.home', {
  90. channel_id: this.id,
  91. top_id: this.top_id,
  92. });
  93. },
  94. loadTop(item) {
  95. this.top_id = item.id;
  96. this.loadData()
  97. },
  98. // 搜索回调函数
  99. search() {
  100. console.log('home search');
  101. },
  102. }
  103. };
  104. </script>
  105. <style lang="scss">
  106. /* 分类区 */
  107. .category-area {
  108. padding-top: 28rpx;
  109. padding-left: 28rpx;
  110. padding-right: 28rpx;
  111. gap: 9px;
  112. grid-template-columns: repeat(5, 1fr);
  113. .category-item {
  114. font-size: $font-sm + 2upx;
  115. color: $font-color-dark;
  116. }
  117. image {
  118. border-radius: 50%;
  119. width: 96rpx;
  120. height: 96rpx;
  121. }
  122. }
  123. .tabs-wrapper {
  124. margin-top: 28rpx;
  125. margin-bottom: 28rpx;
  126. }
  127. .fixed-swiper {
  128. position: fixed;
  129. top: 0;
  130. left: 0;
  131. bottom: 0;
  132. right: 0;
  133. background-color: rgba(0, 0, 0, 0.5);
  134. z-index: 9999;
  135. display: flex;
  136. align-items: center;
  137. justify-content: center;
  138. flex-direction: column;
  139. }
  140. .fixed-swiper-close {
  141. margin-top: 50rpx;
  142. color: #fff;
  143. font-size: 35rpx;
  144. border: 1px solid #fff;
  145. padding: 10rpx;
  146. border-radius: 100%;
  147. }
  148. </style>