active_list.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. <template>
  2. <view class="hot-list">
  3. <mescroll-body ref="mescrollRef" @init="mescrollInit" @down="downCallback" @up="upCallback">
  4. <view class="header">
  5. <ad-swipers v-if="type == 'hot'" :pid="12" height="340rpx">
  6. </ad-swipers>
  7. <ad-swipers v-if="type == 'new'" :pid="13" height="340rpx">
  8. </ad-swipers>
  9. </view>
  10. <view class="main">
  11. <view class="list-title flex row-center">
  12. <u-divider v-if="type == 'hot'" :color="colorConfig.normal" bg-color="transparent" :font-size="38">热销榜单</u-divider>
  13. <u-divider v-if="type == 'new'" :color="colorConfig.normal" bg-color="transparent" :font-size="38">新品推荐</u-divider>
  14. </view>
  15. <view class="hot">
  16. <goods-list v-if="type == 'hot'" :list="goodsList" type="hot"></goods-list>
  17. </view>
  18. <view class="news">
  19. <goods-list v-if="type == 'new'" :list="goodsList" type="double"></goods-list>
  20. </view>
  21. </view>
  22. </mescroll-body>
  23. </view>
  24. </template>
  25. <script>
  26. import {
  27. getGoodsList
  28. } from '@/api/store';
  29. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins";
  30. export default {
  31. mixins: [MescrollMixin],
  32. data() {
  33. return {
  34. upOption: {
  35. empty: {
  36. icon: "/static/images/goods_null.png",
  37. tip: "暂无商品~"
  38. }
  39. },
  40. goodsList: [],
  41. type: ''
  42. };
  43. },
  44. onLoad() {
  45. this.type = this.$Route.query.type
  46. switch(this.type) {
  47. case 'hot': uni.setNavigationBarTitle({
  48. title: '热销榜单'
  49. })
  50. break;
  51. case 'new': uni.setNavigationBarTitle({
  52. title: '新品推荐'
  53. })
  54. break;
  55. }
  56. },
  57. methods: {
  58. upCallback(page) {
  59. let pageNum = page.num;
  60. let pageSize = page.size;
  61. const params = {
  62. page_no: pageNum,
  63. page_size: pageSize,
  64. }
  65. switch(this.type) {
  66. case 'hot': params.sort_by_sales = 'desc'
  67. break;
  68. case 'new': params.sort_by_create = 'desc'
  69. break;
  70. }
  71. getGoodsList(params).then(res => {
  72. if (res.code == 1) {
  73. let curPageData = res.data.lists;
  74. let curPageLen = curPageData.length;
  75. let hasNext = !!res.data.more;
  76. if (page.num == 1) {
  77. this.goodsList = [];
  78. }
  79. this.goodsList = this.goodsList.concat(curPageData);
  80. this.mescroll.endSuccess(curPageLen, hasNext);
  81. }
  82. }).catch(err => {
  83. this.mescroll.endErr()
  84. })
  85. },
  86. }
  87. };
  88. </script>
  89. <style lang="scss">
  90. .hot-list {
  91. .main {
  92. .list-title {
  93. margin: 27rpx 0 30rpx;
  94. }
  95. .hot {
  96. padding: 0 30rpx;
  97. }
  98. }
  99. }
  100. </style>