index.tsx 2.6 KB

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