todayclass-box.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <template>
  2. <!-- 今日课程 -->
  3. <!-- 内容 -->
  4. <view>
  5. <!-- 课程列表 -->
  6. <view style="margin-bottom: 20rpx;">
  7. <view class="detail-image" v-if="state === 'none'" :style="{backgroundImage:`url(${image.none})`}"></view>
  8. <view class="detail-image" v-if="state === ''" :style="{backgroundImage:`url(${image.class})`}"></view>
  9. <view class="class-block" v-for="(classInfo,classIndex) in homeClassList" :key="classIndex"
  10. :style="{backgroundColor: classIndex === 1 ? '#FFF' : ''}">
  11. <view class="block-title" :style="{color: classIndex === 1 ? '#3c9cff' : ''}">{{classInfo.name}}</view>
  12. <view class="block-tag-box">
  13. <view class="block-tag">{{classInfo.teacher}}</view>
  14. </view>
  15. <view class="block-subtitle" v-if="classIndex === 0 && state != 'none'">上节</view>
  16. <view class="block-subtitle" style="color: #3c9cff;" v-if="classIndex === 1 && state != 'none'">当前
  17. </view>
  18. <view class="block-subtitle" v-if="classIndex === 2 && state != 'none'">下节</view>
  19. <view class="block-subtitle" :style="{color: classIndex === 1 ? '#3c9cff' : ''}">{{classInfo.time}}
  20. </view>
  21. <u-tag text="查看回放" plain icon="hourglass" v-if="classIndex === 0 && state != 'none'"></u-tag>
  22. <u-tag text="查看直播" type="error" icon="play-right" v-if="classIndex === 1"></u-tag>
  23. <u-tag text="暂未开始" plain icon="pushpin" type="warning" v-if="classIndex === 2"></u-tag>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {
  30. mapState
  31. } from 'vuex'
  32. export default {
  33. name: "todayclass-box",
  34. computed: {
  35. ...mapState('m_children', ['classList']),
  36. },
  37. props: {
  38. classCurrent: {
  39. type: Number,
  40. default () {
  41. return 2
  42. }
  43. },
  44. },
  45. data() {
  46. return {
  47. //展示数据
  48. homeClassList: {},
  49. //是否展示
  50. state: '',
  51. image: {
  52. none:'https://image.meiye.art/pic_1631411820764Vm5iw82gnV2lVKWRokFmU',
  53. class: 'https://image.meiye.art/pic_1631411821366fqhkuMI110LbOlAIdv1SV',
  54. }
  55. };
  56. },
  57. watch: {
  58. classCurrent() {
  59. this.getHomeClassList()
  60. }
  61. },
  62. methods: {
  63. //获取首页课程数据
  64. getHomeClassList() {
  65. console.log(this.classCurrent);
  66. //不在任何一个时间段内
  67. if (this.classCurrent === -1) {
  68. this.state = 'none'
  69. this.homeClassList = [{
  70. name: '休息时间',
  71. teacher: '孩子自由安排',
  72. time: '更多课程点击课程列表查看'
  73. }]
  74. }
  75. //三节完整数据
  76. if (this.classCurrent >= 2 && this.classCurrent <= 6) {
  77. this.state = ''
  78. this.homeClassList = this.classList.slice(this.classCurrent - 2, this.classCurrent + 1)
  79. }
  80. //数据不足三节
  81. if (this.classCurrent === 1) {
  82. this.state = ''
  83. const arr = [{
  84. name: '早读',
  85. teacher: '王老师',
  86. time: '08:00-08:40'
  87. }]
  88. arr.push(this.classList[0])
  89. arr.push(this.classList[1])
  90. this.homeClassList = arr
  91. }
  92. }
  93. },
  94. created() {
  95. this.getHomeClassList()
  96. }
  97. }
  98. </script>
  99. <style lang="scss">
  100. @import '@/pages/common/blockmsg.scss';
  101. .detail-image{
  102. margin-top: -80rpx;
  103. width: 100%;
  104. height: 450rpx;
  105. background-size: 100%;
  106. background-repeat: no-repeat;
  107. }
  108. </style>