index.tsx 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import { defineComponent, PropType } from 'vue'
  2. import styles from './index.module.less'
  3. import { Cell, Icon, Image } from 'vant'
  4. import videoStop from '@common/images/icon_video_stop.png'
  5. import bars from '@common/svg/bars.svg'
  6. /**
  7. * @description: 课程视频列表项
  8. * @param {title} 视频标题
  9. * @param {imgUrl} 视频封面图
  10. * @param {content} 视频内容
  11. */
  12. interface IDetail {
  13. id?: number
  14. title: string
  15. content?: string
  16. imgUrl?: string
  17. videoUrl?: string
  18. index?: number
  19. }
  20. export default defineComponent({
  21. name: 'CourseVideoItem',
  22. props: {
  23. detail: {
  24. type: Object as PropType<IDetail>,
  25. required: true
  26. },
  27. border: {
  28. type: Boolean,
  29. default: false
  30. },
  31. onPlay: {
  32. type: Function as PropType<(detail: IDetail) => void>,
  33. default: () => {}
  34. },
  35. playId: {
  36. // 播放视屏编号
  37. type: Number,
  38. default: 0
  39. }
  40. },
  41. render() {
  42. return (
  43. <Cell
  44. class={styles.videoSection}
  45. border={this.border}
  46. onClick={() => this.onPlay(this.detail)}
  47. v-slots={{
  48. icon: () => (
  49. <div class={styles.videoImg}>
  50. <Image src={this.detail.imgUrl} fit="cover" />
  51. {this.detail.id === this.playId ? (
  52. <div class={styles.living}>
  53. <Image src={bars} class={styles.animation} />
  54. <span>播放中</span>
  55. </div>
  56. ) : (
  57. <Icon class={styles.videoStop} name={videoStop} size={26} />
  58. )}
  59. </div>
  60. ),
  61. title: () => (
  62. <div class={[styles.videoTitle, 'videoSmall']}>
  63. <p
  64. class={[
  65. styles.videoTitleText,
  66. 'van-ellipsis',
  67. this.detail.id === this.playId && styles.active
  68. ]}
  69. >
  70. {this.detail.title}
  71. </p>
  72. <p class={[styles.videoTitleContent, 'van-multi-ellipsis--l2']}>
  73. {this.detail.content}
  74. </p>
  75. </div>
  76. )
  77. }}
  78. ></Cell>
  79. )
  80. }
  81. })