result-tabs.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. <template>
  2. <view class="result-tabs">
  3. <view class="tabs-header">
  4. <uv-tabs :list="tabs" :current="current" @click="onTabClick"></uv-tabs>
  5. </view>
  6. <view class="tabs-content">
  7. <index-title-wrap title="历年录取" id="lnlq">
  8. <enroll-table :headers="enrollHistoryHeaders" :data="result.histories"/>
  9. </index-title-wrap>
  10. <index-title-wrap v-if="false" title="历年补录" class="mt-30" id="lnbl">
  11. <enroll-table :headers="clearingHistoryHeaders" :data="result.clearings"/>
  12. </index-title-wrap>
  13. <index-title-wrap title="院校开设" class="mt-30" id="yxks">
  14. <college-grouped-major/>
  15. </index-title-wrap>
  16. <index-title-wrap title="招生简章" class="mt-30" id="zsjz">
  17. <college-detail-brochure-cell v-for="item in enrollRuleBrochures" :item="item"
  18. :detail="detail" class="-mx-20"/>
  19. </index-title-wrap>
  20. <index-title-wrap title="相关推荐" class="mt-30" id="xgtj">
  21. <college-recommend v-if="major.code" :detail="detail" :major="major"/>
  22. </index-title-wrap>
  23. </view>
  24. </view>
  25. </template>
  26. <script>
  27. import MxConst from "@/common/MxConst";
  28. import IndexTitleWrap from "@/pages/index/components/index-title-wrap.vue";
  29. import EnrollTable from './enroll-table.vue';
  30. import CollegeDetailBrochureCell from "@/pages/college-library/components/college-detail-brochureCell.vue";
  31. import CollegeGroupedMajor from "@/pages/ie/entry-single-result/components/college-grouped-major.vue";
  32. import CollegeRecommend from "@/pages/ie/entry-single-result/components/college-recommend.vue";
  33. import InjectAISingleDataMixin from "@/pages/ie/entry-single-result/components/InjectAISingleDataMixin";
  34. export default {
  35. mixins: [InjectAISingleDataMixin],
  36. props: {
  37. scrollTop: {
  38. type: Number,
  39. default: 0
  40. }
  41. },
  42. components: {
  43. CollegeRecommend,
  44. CollegeGroupedMajor,
  45. CollegeDetailBrochureCell,
  46. IndexTitleWrap,
  47. EnrollTable
  48. },
  49. data() {
  50. return {
  51. tabs: [{name: '录取', id: 'lnlq'},
  52. {name: '院校开设', id: 'yxks'},
  53. {name: '招生简章', id: 'zsjz'},
  54. {name: '推荐', id: 'xgtj'}],
  55. current: 0,
  56. layout: [],
  57. enrollHistoryHeaders: [{label: '年份', prop: 'year'},
  58. {label: '人数', prop: 'enroll'},
  59. {label: '录取分数', prop: 'score'}],
  60. clearingHistoryHeaders: [{label: '年份', prop: 'year'},
  61. {label: '补录人数', prop: 'realNum'},
  62. {label: '录取分数', prop: 'score'}]
  63. };
  64. },
  65. computed: {
  66. enrollRuleBrochures() {
  67. return this.detail.enrollBrochures?.filter(eb => eb.type == MxConst.enum.brochureType.enrollRule) || []
  68. }
  69. },
  70. watch: {
  71. scrollTop(val) {
  72. for (let i = 0; i < this.layout.length; i++) {
  73. const h = val + 88;
  74. if (h > this.layout[i]) {
  75. if (this.layout[i + 1] && h < this.layout[i + 1]) {
  76. this.current = i; // TODO: 点击tab后定位不准?因为有的tab没有内容,导致希望的高度没有达到
  77. break;
  78. }
  79. }
  80. }
  81. },
  82. detail() {
  83. this.initLayout();
  84. }
  85. },
  86. mounted() {
  87. this.initLayout();
  88. },
  89. methods: {
  90. onTabClick(item) {
  91. const dom = document.getElementById(item.id);
  92. this.$nextTick(() => {
  93. uni.pageScrollTo({
  94. scrollTop: dom.offsetTop - 90,
  95. duration: 0
  96. });
  97. });
  98. },
  99. initLayout() {
  100. this.$nextTick(() => {
  101. this.layout = this.tabs.map(item => {
  102. return document.getElementById(item.id).offsetTop;
  103. });
  104. });
  105. }
  106. }
  107. };
  108. </script>
  109. <style lang="scss" scoped>
  110. .result-tabs {
  111. background-color: white;
  112. ::v-deep .uv-tabs__wrapper__nav__item {
  113. flex: 1;
  114. }
  115. ::v-deep .uv-tabs__wrapper__nav__item__text {
  116. white-space: nowrap;
  117. }
  118. .tabs-header {
  119. position: sticky;
  120. top: 44px;
  121. z-index: 90;
  122. background-color: white;
  123. }
  124. .tabs-content {
  125. padding: 10rpx 30rpx 30rpx;
  126. margin-top: 20rpx;
  127. }
  128. }
  129. </style>