Records.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <div class="record">
  3. <van-sticky :offset-top="barHeight">
  4. <van-tabs v-model:active="status" line-width="28px" line-height="2px" shrink swipeable swipe-threshold="3">
  5. <van-tab :title="item.label" :name="item.value" v-for="(item, index) in tabs" :key="index"> </van-tab>
  6. </van-tabs>
  7. </van-sticky>
  8. <van-list v-model:loading="loading" :finished="finished" finished-text="" @load="getData">
  9. <room-info v-for="(item, index) in showList" :key="index" :info="item"></room-info>
  10. <van-empty
  11. v-if="!loading && showList.length === 0"
  12. description="当前没有战绩哦~"
  13. :image="require('../../assets/kong-pimg-zhanji.png')"
  14. />
  15. </van-list>
  16. </div>
  17. </template>
  18. <script>
  19. import list from '../../mixins/list.js';
  20. import room from '../../mixins/room.js';
  21. import RoomInfo from '../../components/RoomRecord.vue';
  22. export default {
  23. name: 'records',
  24. inject: ['barHeight', 'setKeeps', 'scrollWrapper', 'changeScroll'],
  25. data() {
  26. return {
  27. status: '',
  28. url: '/room/my',
  29. httpType: 'get',
  30. list: [],
  31. scrollTop: 0
  32. };
  33. },
  34. computed: {
  35. tabs() {
  36. return [{ label: '全部', value: '' }, ...this.statusOptions];
  37. },
  38. showList() {
  39. let list = [...this.list];
  40. if (this.status) {
  41. list = list.filter(item => {
  42. return item.status === this.status;
  43. });
  44. }
  45. return list;
  46. }
  47. },
  48. components: { RoomInfo },
  49. mixins: [list, room],
  50. activated() {
  51. this.$nextTick(() => {
  52. this.changeScroll(this.scrollTop || 0);
  53. });
  54. },
  55. beforeRouteLeave(to, from, next) {
  56. if (to.path === '/room') {
  57. this.scrollTop = this.scrollWrapper.scrollTop;
  58. this.setKeeps(['records']);
  59. } else {
  60. this.scrollTop = 0;
  61. this.setKeeps(['irecords'], false);
  62. }
  63. next();
  64. }
  65. };
  66. </script>
  67. <style lang="less" scoped>
  68. /deep/.van-tabs__nav {
  69. padding: 0 0 15px;
  70. }
  71. /deep/.van-tab {
  72. padding: 0 16px;
  73. }
  74. /deep/.van-tab + .van-tab {
  75. margin-left: 10px;
  76. }
  77. .record-info {
  78. .flex();
  79. align-items: flex-end;
  80. padding: 28px 12px 12px;
  81. background-color: @bg2;
  82. border-radius: 4px;
  83. .record-content {
  84. margin-left: 10px;
  85. .text1 {
  86. font-size: 14px;
  87. color: #ffffff;
  88. line-height: 24px;
  89. }
  90. .text2 {
  91. font-size: 12px;
  92. color: #ffffff;
  93. line-height: 17px;
  94. margin-top: 2;
  95. }
  96. .text3 {
  97. .flex();
  98. margin-top: 6px;
  99. img {
  100. width: 16px;
  101. height: 16px;
  102. }
  103. span {
  104. font-size: 12px;
  105. color: #6a6d83;
  106. line-height: 17px;
  107. margin-left: 6px;
  108. }
  109. }
  110. }
  111. }
  112. .van-list {
  113. padding: 16px;
  114. min-height: var(--app-height);
  115. .room + .room {
  116. margin-top: 16px;
  117. }
  118. }
  119. </style>