index.tsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { Cell, CellGroup, Icon, Image, Tag } from "vant";
  2. import { defineComponent, PropType } from "vue";
  3. import styles from "./index.module.less";
  4. import iconUserNum from '@common/images/icon_user_num.png';
  5. /**
  6. * @description: 视频详情
  7. * @param {type} headUrl 头像
  8. * @param {type} username 姓名
  9. * @param {type} startTime 开始时间
  10. * @param {type} buyNum 购买用户数
  11. * @param {type} lessonPrice 价格
  12. * @param {type} lessonCoverUrl 视频封面
  13. * @param {type} lessonDesc 课程描述
  14. * @param {type} lessonNum 课程数
  15. * @param {type} lessonName 课程名称
  16. */
  17. interface UserType {
  18. headUrl: string;
  19. username: string;
  20. startTime?: string;
  21. buyNum?: number;
  22. lessonPrice: number;
  23. lessonNum?: number;
  24. lessonDesc?: string;
  25. lessonCoverUrl: string;
  26. lessonName: string;
  27. }
  28. export default defineComponent({
  29. name: "user-detail",
  30. props: {
  31. userInfo: {
  32. type: Object as PropType<UserType>,
  33. required: true
  34. },
  35. showType: {
  36. type: String as PropType<"BUY" | "TIME">,
  37. default: "BUY"
  38. }
  39. },
  40. render() {
  41. return (
  42. <div class={styles.userDetail}>
  43. <Image class={[styles.banner]} src={this.userInfo.lessonCoverUrl} fit="cover" />
  44. <CellGroup class={styles.userInfo}>
  45. <Cell title={this.userInfo.lessonName} titleClass={styles.userTitle} />
  46. <Cell v-slots={{
  47. icon: () => <Image class={styles.avatar} src={this.userInfo.headUrl} />,
  48. title: () => (<div class={styles.name}>{this.userInfo.username}
  49. {this.showType === "TIME" ? <Tag style={{ marginLeft: '8px' }} color="#FFF1DE" textColor="#FF9300">{this.userInfo.lessonNum}课时</Tag> : <div class={styles.buyNum}>{this.userInfo.buyNum}人已购买</div>}
  50. </div>),
  51. value: () => (
  52. this.showType === "TIME" ? <div class={styles.buyNumInfo}>
  53. <Icon name={iconUserNum} size={14} class={styles.iconBuy} /> 已购 {this.userInfo.buyNum} 人
  54. </div> : <div class={styles.info}>¥{this.userInfo.lessonPrice}/{this.userInfo.lessonNum}课时</div>
  55. ),
  56. }}></Cell>
  57. </CellGroup>
  58. </div>
  59. )
  60. }
  61. })