todayclass-box.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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'">{{first}}</view>
  16. <view class="block-subtitle" style="color: #3c9cff;" v-if="classIndex === 1 && state != 'none'">
  17. {{second}}
  18. </view>
  19. <view class="block-subtitle" v-if="classIndex === 2 && state != 'none'">{{third}}</view>
  20. <view class="block-subtitle" :style="{color: classIndex === 1 ? '#3c9cff' : ''}" @click="navClass">
  21. {{classInfo.time}}
  22. </view>
  23. <u-tag :text="before" :type="beforeType" plain icon="hourglass"
  24. v-if="classIndex === 0 && state != 'none'" @click="navVideoBefore">
  25. </u-tag>
  26. <u-tag :text="now" type="success" icon="play-right" v-if="classIndex === 1" @click="navVideoNow">
  27. </u-tag>
  28. <u-tag :text="after" type="error" :color="afterColor" :borderColor="afterColor" plain icon="pushpin"
  29. v-if="classIndex === 2"></u-tag>
  30. </view>
  31. </view>
  32. </view>
  33. </template>
  34. <script>
  35. import {
  36. mapState
  37. } from 'vuex'
  38. export default {
  39. name: "todayclass-box",
  40. computed: {
  41. ...mapState('m_children', ['classList']),
  42. },
  43. props: {
  44. classCurrent: {
  45. type: Number,
  46. default () {
  47. return -1
  48. }
  49. },
  50. },
  51. data() {
  52. return {
  53. //展示数据
  54. homeClassList: {},
  55. //是否展示
  56. state: '',
  57. image: {
  58. none: 'https://image.meiye.art/pic_1631411820764Vm5iw82gnV2lVKWRokFmU',
  59. class: 'https://image.meiye.art/pic_1631411821366fqhkuMI110LbOlAIdv1SV',
  60. },
  61. first: '上节',
  62. second: '当前',
  63. third: '下节',
  64. before: '查看回放',
  65. now: '查看直播',
  66. after: '暂未开始',
  67. beforeType: 'warning'
  68. };
  69. },
  70. watch: {
  71. classCurrent() {
  72. this.getHomeClassList()
  73. }
  74. },
  75. methods: {
  76. //获取首页课程数据
  77. getHomeClassList() {
  78. //不在任何一个时间段内
  79. if (this.classCurrent === -1) {
  80. this.state = 'none'
  81. this.homeClassList = [{
  82. name: '休息时间',
  83. teacher: '孩子自由安排',
  84. time: '点击查看课程列表'
  85. }]
  86. }
  87. //三节完整数据
  88. if (this.classCurrent >= 2 && this.classCurrent <= this.classList.length) {
  89. this.state = ''
  90. this.third = '下节'
  91. this.after = '暂未开始'
  92. this.before = '查看回放'
  93. this.first = '上节'
  94. this.homeClassList = this.classList.slice(this.classCurrent - 2, this.classCurrent + 1)
  95. if (this.classCurrent === this.classList.length) {
  96. const arr = {
  97. name: '放学',
  98. teacher: '完成今日课程',
  99. time: '17:20'
  100. }
  101. this.third = '时间:'
  102. this.after = '巩固已学'
  103. this.homeClassList.push(arr)
  104. }
  105. }
  106. //数据不足三节
  107. if (this.classCurrent === 1) {
  108. this.state = ''
  109. const arr = [{
  110. name: '上学',
  111. teacher: '开始今日课程',
  112. time: '8:30'
  113. }]
  114. this.before = '上学打卡'
  115. this.first = '时间:'
  116. this.beforeType = 'info'
  117. arr.push(this.classList[0])
  118. arr.push(this.classList[1])
  119. this.homeClassList = arr
  120. }
  121. },
  122. navClass() {
  123. uni.navigateTo({
  124. url: '/subpkg/classmsg/classmsg'
  125. })
  126. },
  127. navVideoBefore() {
  128. if (this.before === '查看回放') {
  129. uni.navigateTo({
  130. url: '/subpkg/classvideo/classvideo'
  131. })
  132. }
  133. },
  134. navVideoNow() {
  135. uni.navigateTo({
  136. url: '/subpkg/classvideo/classvideo'
  137. })
  138. },
  139. },
  140. created() {
  141. this.getHomeClassList()
  142. }
  143. }
  144. </script>
  145. <style lang="scss">
  146. @import '@/pages/common/blockmsg.scss';
  147. .detail-image {
  148. margin-top: -80rpx;
  149. width: 100%;
  150. height: 450rpx;
  151. background-size: 100%;
  152. background-repeat: no-repeat;
  153. }
  154. </style>