schedule-steps.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <index-title-wrap title="考试日程">
  3. <view class="bg-white p-40 mx-card">
  4. <uv-steps :current="currentStep" direction="column" dot>
  5. <uv-steps-item v-for="(s,idx) in currentPage" :key="idx" v-bind="s">
  6. <template #desc>
  7. <uv-text prefix-icon="clock" :type="idx==currentStep?'main':'tips'"
  8. :size="idx==currentStep?15:13" :text="s.time"/>
  9. <uv-text v-if="s.desc" type="tips" size="12" margin="5px 0 0 0" :text="s.desc"/>
  10. </template>
  11. </uv-steps-item>
  12. </uv-steps>
  13. </view>
  14. <view v-if="schedules.length>minSize" class="fx-row fx-cen-cen" style="margin-top: -22px">
  15. <view class="icon36 rd18-only bg-white shadow fx-col fx-cen-cen border-white half-circle rel"
  16. @click="togglePage">
  17. <text class="f10 f-999" style="visibility: hidden; margin-top: -5px">{{
  18. isOpen ? '收起' : '展开'
  19. }}
  20. </text>
  21. <uv-icon size="12" :name="isOpen?'arrow-up':'arrow-down'" color="#999"/>
  22. </view>
  23. </view>
  24. </index-title-wrap>
  25. </template>
  26. <script>
  27. import IndexTitleWrap from "@/pages/index/components/index-title-wrap.vue";
  28. import {getMainCourseDate} from "@/api/webApi/career-news";
  29. export default {
  30. name: "schedule-steps",
  31. components: {IndexTitleWrap},
  32. computed: {
  33. currentStep() {
  34. let step = -1
  35. const now = this.$uv.timeFormat()
  36. for (let i = 0; i < this.schedules.length; i++) {
  37. const schedule = this.schedules[i]
  38. if (now >= schedule.fireTime) step = i
  39. else break
  40. }
  41. return step
  42. },
  43. currentPage() {
  44. return this.schedules.slice(0, this.currentSize)
  45. },
  46. isOpen() {
  47. return this.schedules.length <= this.currentSize
  48. }
  49. },
  50. data() {
  51. return {
  52. minSize: 3,
  53. currentSize: 3,
  54. schedules: []
  55. }
  56. },
  57. mounted() {
  58. this.loadData()
  59. },
  60. methods: {
  61. async loadData() {
  62. const res = await getMainCourseDate()
  63. this.schedules = res.rows
  64. },
  65. togglePage() {
  66. this.currentSize = this.currentSize != this.schedules.length ? this.schedules.length : this.minSize
  67. }
  68. }
  69. }
  70. </script>
  71. <style scoped>
  72. .half-circle:before {
  73. content: ' ';
  74. position: absolute;
  75. z-index: 5;
  76. width: 50px; /*larger than circle area*/
  77. height: 20px;
  78. top: 0;
  79. background-color: white;
  80. }
  81. </style>