Creator.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <template>
  2. <div class="discover">
  3. <van-sticky ref="top" :offset-top="bar.value && bar.value.show ? 46 : 0">
  4. <div class="top">
  5. <div class="top-btn">
  6. <div class="btn" @click="$router.replace('/discover')">收藏探索</div>
  7. <div class="btn active">铸造者</div>
  8. </div>
  9. <div class="search" @click="$router.push('/creatorSearch')">
  10. <img src="@assets/svgs/search.svg" alt="" />
  11. </div>
  12. </div>
  13. <van-tabs
  14. v-model:active="sort"
  15. @change="
  16. page = 0;
  17. getList();
  18. "
  19. line-width="16"
  20. line-height="2"
  21. >
  22. <van-tab title="全部" name="id,desc"></van-tab>
  23. <van-tab title="最新" name="createdAt,desc"></van-tab>
  24. <van-tab title="人气" name="followers,desc"></van-tab>
  25. </van-tabs>
  26. </van-sticky>
  27. <van-list v-model:loading="loading" :finished="finished" finished-text="没有更多" @load="getList">
  28. <template v-for="(item, index) in miners" :key="index">
  29. <creator-info v-model:info="miners[index]"></creator-info>
  30. </template>
  31. </van-list>
  32. </div>
  33. </template>
  34. <script>
  35. import CreatorInfo from '../components/creator/CreatorInfo.vue';
  36. export default {
  37. components: { CreatorInfo },
  38. inject: ['bar'],
  39. data() {
  40. return {
  41. miners: [],
  42. stiky: null,
  43. sort: 'id,desc',
  44. loading: false,
  45. finished: false,
  46. page: 0,
  47. empty: false
  48. };
  49. },
  50. methods: {
  51. getList() {
  52. if (this.page === 0) {
  53. this.miners = [];
  54. }
  55. this.loading = true;
  56. this.finished = false;
  57. this.empty = false;
  58. this.$http
  59. .post(
  60. '/user/all',
  61. {
  62. page: this.page,
  63. query: { minter: true },
  64. size: 20,
  65. sort: this.sort
  66. },
  67. { body: 'json' }
  68. )
  69. .then(res => {
  70. this.miners = [...this.miners, ...res.content];
  71. this.empty = res.empty;
  72. this.loading = false;
  73. this.finished = res.last;
  74. if (!this.finished) {
  75. this.page = this.page + 1;
  76. }
  77. });
  78. }
  79. }
  80. };
  81. </script>
  82. <style lang="less" scoped>
  83. .top {
  84. display: flex;
  85. padding: 10px 16px;
  86. background-color: @bg;
  87. .top-btn {
  88. flex-grow: 1;
  89. .btn {
  90. font-size: 16px;
  91. line-height: 26px;
  92. display: inline-block;
  93. vertical-align: text-bottom;
  94. &.active {
  95. color: @prim;
  96. font-size: 20px;
  97. font-weight: bold;
  98. line-height: 30px;
  99. }
  100. }
  101. .btn + .btn {
  102. margin-left: 30px;
  103. }
  104. }
  105. }
  106. .discover {
  107. background-color: @bg3;
  108. padding-bottom: 100px;
  109. min-height: 100vh;
  110. }
  111. /deep/.van-tab {
  112. color: #fff;
  113. flex: 0;
  114. padding: 20px;
  115. flex-shrink: 0;
  116. min-width: 74px;
  117. &.van-tab--active {
  118. color: @prim;
  119. }
  120. }
  121. /deep/ .van-tabs__line {
  122. bottom: 20px;
  123. }
  124. </style>