video-item.tsx 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. import { defineComponent, PropType } from 'vue'
  2. import { Image } from 'vant'
  3. import styles from './video-item.module.less'
  4. import iconTeacher from '@common/images/icon_teacher.png'
  5. interface VideoItemProps {
  6. id?: number
  7. teacherId?: number
  8. lessonName: string
  9. userName: string
  10. avatar: string
  11. lessonCoverUrl: string
  12. lessonCount: number
  13. lessonPrice: number
  14. countStudent: number
  15. lessonSubjectName: string
  16. auditVersion: number
  17. }
  18. export default defineComponent({
  19. name: 'VideoItem',
  20. props: {
  21. item: Object as PropType<VideoItemProps>,
  22. onClick: {
  23. type: Function as PropType<(item: any) => void>,
  24. default: (item: any) => {}
  25. }
  26. },
  27. render() {
  28. const item: any = this.item
  29. return (
  30. <div
  31. class={styles.videoItem}
  32. onClick={() => {
  33. this.onClick(item)
  34. }}
  35. >
  36. <div style={{ position: 'relative' }}>
  37. <Image
  38. class={styles.viCover}
  39. fit="cover"
  40. src={item?.lessonCoverUrl}
  41. />
  42. <span class={styles.subjectName}>{item?.lessonSubjectName}</span>
  43. </div>
  44. <div class={styles.viSection}>
  45. <div class={[styles.viTitle, 'van-ellipsis']}>{item?.lessonName}</div>
  46. {/* <div class={styles.viUserInfo}>
  47. <Image
  48. src={item?.avatar || iconTeacher}
  49. class={styles.viUserLogo}
  50. />
  51. <span class={[styles.viUserName, 'van-hairline--right']}>
  52. {item?.userName ||
  53. item?.username ||
  54. `游客${item?.teacherId || ''}`}
  55. </span>
  56. </div> */}
  57. <div class={styles.viPrice}>
  58. <span class={styles.priceNum}>
  59. {item.payType === 'VIP' ? (
  60. <span style={{ color: '#C76E21' }}>会员</span>
  61. ) : (
  62. <>
  63. {item?.lessonPrice > 0 && (
  64. <>
  65. <i>¥</i>
  66. {item?.lessonPrice}
  67. </>
  68. )}
  69. {item?.lessonPrice <= 0 && item.auditVersion !== 0 && (
  70. <>
  71. <i>¥</i>0
  72. </>
  73. )}
  74. {item?.lessonPrice <= 0 && item.auditVersion === 0 && (
  75. <span style={{ color: '#20BEA0' }}>免费</span>
  76. )}
  77. </>
  78. )}
  79. </span>
  80. <span class={styles.label}>/{item?.lessonCount}课时</span>
  81. </div>
  82. <div class={styles.viUserNum}>{item?.countStudent}人已学习</div>
  83. </div>
  84. </div>
  85. )
  86. }
  87. })