live-item.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import { defineComponent, PropType } from 'vue'
  2. import { Image, CellGroup, Cell, Icon } from 'vant'
  3. import styles from './live-item.module.less'
  4. import dayjs from 'dayjs'
  5. import iconSuccess from '@common/images/icon_success.png'
  6. import iconTeacher from '@common/images/icon_teacher.png'
  7. interface IProps {
  8. backgroundPic: string
  9. courseGroupId: number
  10. courseGroupName: string
  11. courseNum: string
  12. courseStartTime: number
  13. coursePrice: number
  14. teacherName: string
  15. teacherId: number
  16. avatar?: string
  17. studentCount: number
  18. existBuy: number
  19. subjectName: string
  20. }
  21. export default defineComponent({
  22. name: 'liveItem',
  23. props: {
  24. onClick: {
  25. type: Function,
  26. default: (item?: any) => {}
  27. },
  28. liveInfo: {
  29. type: Object as PropType<IProps>,
  30. default: {}
  31. }
  32. },
  33. render() {
  34. return (
  35. <Cell
  36. center
  37. border={false}
  38. class={styles.liveItem}
  39. onClick={() => this.onClick(this.liveInfo)}
  40. v-slots={{
  41. icon: () => (
  42. <div style={{ position: 'relative' }}>
  43. <Image
  44. class={styles.liCover}
  45. fit="cover"
  46. src={this.liveInfo.backgroundPic}
  47. />
  48. <span class={styles.subjectName}>
  49. {this.liveInfo.subjectName}
  50. </span>
  51. </div>
  52. ),
  53. title: () => (
  54. <div>
  55. <div class={[styles.liTitle, 'van-ellipsis']}>
  56. {this.liveInfo.courseGroupName}
  57. </div>
  58. <div class={styles.liUserInfo}>
  59. <p class={styles.liteachername}>
  60. {/* 老师: */}
  61. <Image
  62. src={this.liveInfo.avatar || iconTeacher}
  63. class={styles.liteacherIcon}
  64. />
  65. {this.liveInfo.teacherName ||
  66. `游客${this.liveInfo.teacherId}`}
  67. </p>
  68. <p>
  69. 开课时间:
  70. {dayjs(this.liveInfo.courseStartTime).format(
  71. 'MM月DD日 HH:mm'
  72. )}
  73. </p>
  74. </div>
  75. <div class={styles.liPrice}>
  76. <p>
  77. {this.liveInfo.coursePrice > 0 && (
  78. <span class={styles.price}>
  79. <i>¥</i>
  80. {this.liveInfo.coursePrice}
  81. </span>
  82. )}
  83. <span class={styles.classNum}>
  84. {this.liveInfo.courseNum}课时
  85. </span>
  86. </p>
  87. {this.liveInfo.existBuy === 1 && (
  88. <span class={styles.buyNum}>
  89. {/* <Icon name={iconSuccess} size="15" /> */}
  90. 学习
  91. </span>
  92. )}
  93. {/* : (
  94. <span class={styles.num}>
  95. {this.liveInfo.studentCount}人学习
  96. </span>
  97. ) */}
  98. </div>
  99. </div>
  100. )
  101. }}
  102. />
  103. )
  104. }
  105. })