list.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view>
  3. <use-tabbar></use-tabbar>
  4. <view class="padding-area">
  5. <!-- 轮播区 -->
  6. <use-swiper v-if="fetch.ad && fetch.ad.focus && fetch.ad.focus.length > 0"
  7. :data="fetch.ad.focus"></use-swiper>
  8. <!-- 列表区 -->
  9. <view>
  10. <!-- 筛选区 -->
  11. <view class="navbar pos-f w-full dflex bg-main">
  12. <view class="nav-item dflex-c flex1 pos-r h-full" :class="{active: data.order == 0}"
  13. @click="order(0)">
  14. 综合排序
  15. </view>
  16. <view class="nav-item dflex-c flex1 pos-r h-full" :class="{active: data.order == 1}"
  17. @click="order(1)">
  18. 销量优先
  19. </view>
  20. <view class="nav-item dflex-c flex1 pos-r h-full" :class="{active: data.order >= 3}"
  21. @click="order(3)">
  22. <text>价格</text>
  23. <view class="">
  24. <view class="iconfont iconjiantou02 ft-dark dflex-c" :class="{active: data.order == 3}">
  25. </view>
  26. <view class="iconfont iconjiantou ft-dark dflex-c" :class="{active: data.order == 4}">
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="tabs-wrapper" v-if="fetch.child && fetch.child.length > 0">
  32. <u-tabs :list="fetch.child" @click="loadChild" lineColor="#ff6b6b" activeColor="#ff6b6b" :activeStyle="{
  33. color: '#303133',
  34. fontWeight: 'bold',
  35. transform: 'scale(1.05)'
  36. }" :inactiveStyle="{
  37. color: '#606266',
  38. transform: 'scale(1)'
  39. }" scrollable></u-tabs>
  40. </view>
  41. <!-- 商品列表区 -->
  42. <view class="source-area use-area"
  43. v-if="fetch.list && fetch.list.length > 0">
  44. <use-goods-list :data="fetch.list"></use-goods-list>
  45. </view>
  46. <view v-else class="empty-record">
  47. <u-empty mode="data"></u-empty>
  48. </view>
  49. </view>
  50. <use-copyright :title="fetch.channel.name" :desc="fetch.channel.desc"
  51. v-if="fetch && fetch.channel"></use-copyright>
  52. </view>
  53. <use-totop ref="usetop"></use-totop>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. fetch: {},
  61. // 请求数据
  62. data: {
  63. id: 0,
  64. order: 0,
  65. search: '',
  66. show: 1,
  67. },
  68. type: 1,
  69. source: 1,
  70. };
  71. },
  72. onPageScroll(e) {
  73. this.$refs.usetop.change(e.scrollTop);
  74. },
  75. //下拉刷新
  76. onPullDownRefresh() {
  77. this.loadData(1);
  78. },
  79. //加载更多
  80. onReachBottom() {
  81. this.loadData(2);
  82. },
  83. onLoad(options) {
  84. var title = '资源列表';
  85. if (options) {
  86. if (!options.id) {
  87. return this.Dever.goHome();
  88. }
  89. this.data['id'] = options.id;
  90. if (options.title) {
  91. title = options.title;
  92. }
  93. if (options.search) {
  94. this.data['search'] = options.search;
  95. }
  96. if (options.type) {
  97. this.type = options.type;
  98. }
  99. if (options.source) {
  100. this.data['source'] = options.source;
  101. }
  102. }
  103. uni.setNavigationBarTitle({
  104. title: title
  105. })
  106. this.data['show'] = 1;
  107. this.loadData(1);
  108. },
  109. methods: {
  110. loadData(page) {
  111. if (this.type == 2) {
  112. this.data['channel_id'] = this.data['id']
  113. this.DeverApi.page([page, 'list'], this, 'source.searchData', this.data);
  114. } else {
  115. this.DeverApi.page([page, 'list'], this, 'source.cate', this.data);
  116. }
  117. },
  118. loadChild(item) {
  119. this.data['id'] = item.id;
  120. this.data['show'] = 2;
  121. this.loadData(1)
  122. },
  123. order(value) {
  124. if (value == 3 && this.data.order == 3) {
  125. value = 4;
  126. }
  127. this.data.order = value;
  128. this.loadData(1);
  129. },
  130. },
  131. }
  132. </script>
  133. <style lang="scss">
  134. .padding-area {
  135. margin-top: 120rpx;
  136. }
  137. .navbar {
  138. position: fixed;
  139. top: calc(var(--status-bar-height) + 88rpx);
  140. left: 0;
  141. height: 100rpx;
  142. box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, .06);
  143. z-index: 10;
  144. background: #f5f5f5;
  145. .nav-item {
  146. color: $font-color-dark;
  147. font-size: 30rpx;
  148. &.active {
  149. font-size: 16px;
  150. font-weight: 700;
  151. &:after {
  152. content: '';
  153. position: absolute;
  154. left: 50%;
  155. bottom: 0;
  156. transform: translateX(-50%);
  157. width: 120rpx;
  158. height: 0;
  159. border-bottom: 4rpx solid $base-color;
  160. }
  161. }
  162. }
  163. .iconfont {
  164. width: 30rpx;
  165. height: 14rpx;
  166. font-size: 20rpx;
  167. line-height: 1;
  168. margin-left: 4rpx;
  169. }
  170. }
  171. .empty-record {
  172. text-align: center;
  173. padding: 60rpx 0;
  174. .empty-icon {
  175. width: 160rpx;
  176. height: 160rpx;
  177. margin-bottom: 20rpx;
  178. opacity: 0.6;
  179. }
  180. .empty-text {
  181. font-size: 28rpx;
  182. color: #999;
  183. }
  184. }
  185. .tabs-wrapper {
  186. margin: 22rpx;
  187. padding: 12rpx 0;
  188. background-color: #fff;
  189. border-radius: 20rpx;
  190. box-shadow: 0 6rpx 16rpx rgba(0, 0, 0, 0.08);
  191. overflow: hidden;
  192. }
  193. </style>