points.tsx 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. import { PropType, defineComponent, reactive, watch, onMounted } from 'vue';
  2. import styles from './point.module.less';
  3. import iconMulv from '../image/icon-mulv.svg';
  4. // import iconZhibo from '../image/icon-load.gif';
  5. // import iconImage from '../image/icon-image.svg';
  6. // import iconImageActive from '../image/icon-image-active.svg';
  7. // import iconVideo from '../image/icon-video.svg';
  8. // import iconVideoActive from '../image/icon-video-active.svg';
  9. // import iconSong from '../image/icon-song.svg';
  10. // import iconSongActive from '../image/icon-song-active.svg';
  11. import chapterDown from '../image/chapter-down-arrow.svg';
  12. import chapterDefault from '../image/chapter-default-arrow.svg';
  13. // import chapterDefault2 from '../image/chapter-default-arrow2.svg';
  14. // import moreIcon from '../image/zy_toggle_icon.png';
  15. // import titleIcon from '../image/zy_title_icon.png';
  16. import songIcon from '../image/song_icon.png';
  17. import audioIcon from '../image/zy_audio_icon.png';
  18. import vedioIcon from '../image/zy_vedio_icon.png';
  19. import pptIcon from '../image/zy_ppt_icon.png';
  20. import imgIcon from '../image/zy_img_icon.png';
  21. import otherIcon from '../image/zy_more_icon.png';
  22. import iconPlayDefault from '../image/icon-play-default.png';
  23. import iconSingDefault from '../image/icon-sing-default.png';
  24. import { Collapse, CollapseItem } from 'vant';
  25. export default defineComponent({
  26. name: 'points',
  27. props: {
  28. kjId: {
  29. // 课件id
  30. type: String,
  31. default: ''
  32. },
  33. zsdId: {
  34. // 知识点id
  35. type: String,
  36. default: ''
  37. },
  38. currentCourse: {
  39. // 当前的课件
  40. type: Object,
  41. default: {}
  42. },
  43. popShow: {
  44. type: Boolean,
  45. default: false
  46. },
  47. itemActive: {
  48. type: String,
  49. default: ''
  50. },
  51. itemName: {
  52. // 章节名称
  53. type: String,
  54. default: ''
  55. }
  56. },
  57. emits: ['handleSelect'],
  58. setup(props, { emit }) {
  59. // const route = useRoute();
  60. // 类型(VIDEO,IMG,SONG,PPT,MUSIC,LISTEN:听音,RHYTHM:节奏,THEORY:乐理知识,MUSIC_WIKI:名曲鉴赏 INSTRUMENT:乐器 MUSICIAN:音乐家),可用值:VIDEO,MUSIC,IMG,SONG,PPT,LISTEN,RHYTHM,THEORY,MUSIC_WIKI,INSTRUMENT,MUSICIAN
  61. // const types: { [_: string]: string } = {
  62. // SONG: '音频',
  63. // VIDEO: '视频',
  64. // IMG: '图片',
  65. // MUSIC: '乐谱',
  66. // PPT: 'PPT',
  67. // LISTEN: '听音',
  68. // RHYTHM: '节奏',
  69. // THEORY: '乐理',
  70. // MUSIC_WIKI: '名曲',
  71. // INSTRUMENT: '乐器',
  72. // MUSICIAN: '音乐家'
  73. // };
  74. const imgTypes: { [_: string]: string } = {
  75. SONG: audioIcon,
  76. VIDEO: vedioIcon,
  77. IMG: imgIcon,
  78. MUSIC: songIcon,
  79. PPT: pptIcon,
  80. LISTEN: otherIcon,
  81. RHYTHM: otherIcon,
  82. THEORY: otherIcon,
  83. MUSIC_WIKI: otherIcon,
  84. INSTRUMENT: otherIcon,
  85. MUSICIAN: otherIcon
  86. };
  87. // 获取对应图片
  88. // const getImage = (item: any) => {
  89. // if (item.type === 'VIDEO') {
  90. // return props.itemActive == item.id ? iconVideoActive : iconVideo;
  91. // } else if (['IMAGE', 'IMG'].includes(item.type)) {
  92. // return props.itemActive == item.id ? iconImageActive : iconImage;
  93. // } else if (item.type === 'SONG') {
  94. // return props.itemActive == item.id ? iconSongActive : iconSong;
  95. // } else {
  96. // return props.itemActive == item.id ? iconVideoActive : iconVideo;
  97. // }
  98. // };
  99. const pointData = reactive({
  100. kjId: props.kjId, // 当前选中的课件id
  101. zsdId: props.zsdId, // 当前选中的知识点id
  102. currentCourse: props.currentCourse as any // 当前课件
  103. });
  104. watch(
  105. () => props.popShow,
  106. () => {
  107. pointData.currentCourse = props.currentCourse;
  108. pointData.kjId = props.kjId;
  109. pointData.zsdId = props.zsdId;
  110. }
  111. );
  112. return () => (
  113. <div class={styles.container}>
  114. <div class={styles.pointHead}>
  115. <img src={iconMulv} />
  116. {props.itemName}
  117. </div>
  118. <div class={styles.content}>
  119. <Collapse
  120. class={styles.collapse}
  121. modelValue={pointData.zsdId}
  122. onUpdate:modelValue={(val: any) => {
  123. pointData.zsdId = val;
  124. }}
  125. border={false}
  126. accordion>
  127. {pointData.currentCourse?.knowledgeList?.map((know: any) => (
  128. <CollapseItem
  129. center
  130. class={[
  131. styles.collapseItem,
  132. styles.collapseKnow,
  133. pointData.zsdId === know.id ? styles.activeItem2 : ''
  134. ]}
  135. border={false}
  136. isLink={false}
  137. title={know.name}
  138. titleClass={'van-ellipsis'}
  139. titleStyle={{ width: '80%' }}
  140. key={know.id}
  141. name={know.id}>
  142. {{
  143. default: () =>
  144. know.materialInfo.map((material: any, index: number) => {
  145. return (
  146. <div
  147. key={material.id}
  148. class={[
  149. styles.matItem,
  150. props.itemActive == material.id
  151. ? styles.itemActive
  152. : ''
  153. ]}
  154. onClick={() => {
  155. emit('handleSelect', {
  156. itemActive: material.id,
  157. zsdId: know.id,
  158. kjId: pointData.currentCourse
  159. ?.coursewareDetailKnowledgeId
  160. });
  161. }}>
  162. {material.paymentType === 'VIP' && (
  163. <span
  164. class={[
  165. styles.iconPayment,
  166. styles[material.paymentType]
  167. ]}>
  168. VIP
  169. </span>
  170. )}
  171. <div class={styles.cover}>
  172. <img src={material.url} />
  173. <div class={styles.audioPlayTypeSection}>
  174. {material.audioPlayTypesArray.includes(
  175. 'SING'
  176. ) && (
  177. <img
  178. src={iconSingDefault}
  179. class={styles.iconPlay}
  180. />
  181. )}
  182. {material.audioPlayTypesArray.includes(
  183. 'PLAY'
  184. ) && (
  185. <img
  186. src={iconPlayDefault}
  187. class={styles.iconPlay}
  188. />
  189. )}
  190. </div>
  191. </div>
  192. <div class={styles.title}>
  193. <img
  194. class={styles.typeImg}
  195. src={imgTypes[material.type]}
  196. />
  197. <div class={styles.tName}>{material.name}</div>
  198. </div>
  199. </div>
  200. );
  201. }),
  202. icon: () => (
  203. <img
  204. class={styles.arrow}
  205. src={
  206. pointData.zsdId === know.id
  207. ? chapterDown
  208. : chapterDefault
  209. }
  210. />
  211. )
  212. }}
  213. </CollapseItem>
  214. ))}
  215. </Collapse>
  216. </div>
  217. </div>
  218. );
  219. }
  220. });