points.tsx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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 { Icon, Collapse, CollapseItem } from 'vant';
  25. import { useRoute } from 'vue-router';
  26. export default defineComponent({
  27. name: 'points',
  28. props: {
  29. allList: {
  30. type: Array as any,
  31. default: () => []
  32. },
  33. kjId: {
  34. // 课件id
  35. type: String,
  36. default: ''
  37. },
  38. zsdId: {
  39. // 知识点id
  40. type: String,
  41. default: ''
  42. },
  43. currentCourse: {
  44. // 当前的课件
  45. type: Object,
  46. default: {}
  47. },
  48. popShow: {
  49. type: Boolean,
  50. default: false
  51. },
  52. data: {
  53. type: Array as PropType<any[]>,
  54. default: () => []
  55. },
  56. itemActive: {
  57. type: String,
  58. default: ''
  59. },
  60. itemName: {
  61. // 章节名称
  62. type: String,
  63. default: ''
  64. }
  65. },
  66. emits: ['handleSelect', 'courseSelect'],
  67. setup(props, { emit }) {
  68. const route = useRoute();
  69. // 类型(VIDEO,IMG,SONG,PPT,MUSIC,LISTEN:听音,RHYTHM:节奏,THEORY:乐理知识,MUSIC_WIKI:名曲鉴赏 INSTRUMENT:乐器 MUSICIAN:音乐家),可用值:VIDEO,MUSIC,IMG,SONG,PPT,LISTEN,RHYTHM,THEORY,MUSIC_WIKI,INSTRUMENT,MUSICIAN
  70. const types: { [_: string]: string } = {
  71. SONG: '音频',
  72. VIDEO: '视频',
  73. IMG: '图片',
  74. MUSIC: '乐谱',
  75. PPT: 'PPT',
  76. LISTEN: '听音',
  77. RHYTHM: '节奏',
  78. THEORY: '乐理',
  79. MUSIC_WIKI: '名曲',
  80. INSTRUMENT: '乐器',
  81. MUSICIAN: '音乐家'
  82. };
  83. const imgTypes: { [_: string]: string } = {
  84. SONG: audioIcon,
  85. VIDEO: vedioIcon,
  86. IMG: imgIcon,
  87. MUSIC: songIcon,
  88. PPT: pptIcon,
  89. LISTEN: otherIcon,
  90. RHYTHM: otherIcon,
  91. THEORY: otherIcon,
  92. MUSIC_WIKI: otherIcon,
  93. INSTRUMENT: otherIcon,
  94. MUSICIAN: otherIcon
  95. };
  96. // 获取对应图片
  97. const getImage = (item: any) => {
  98. if (item.type === 'VIDEO') {
  99. return props.itemActive == item.id ? iconVideoActive : iconVideo;
  100. } else if (['IMAGE', 'IMG'].includes(item.type)) {
  101. return props.itemActive == item.id ? iconImageActive : iconImage;
  102. } else if (item.type === 'SONG') {
  103. return props.itemActive == item.id ? iconSongActive : iconSong;
  104. } else {
  105. return props.itemActive == item.id ? iconVideoActive : iconVideo;
  106. }
  107. };
  108. const pointData = reactive({
  109. allList: props.allList, // 章节下的所有课件
  110. kjId: props.kjId, // 当前选中的课件id
  111. zsdId: props.zsdId, // 当前选中的知识点id
  112. currentCourse: props.currentCourse as any // 当前课件
  113. });
  114. watch(
  115. () => props.allList,
  116. () => {
  117. pointData.kjId = props.kjId;
  118. pointData.zsdId = props.zsdId;
  119. }
  120. );
  121. watch(
  122. () => props.popShow,
  123. () => {
  124. console.log('刷新123', props.allList, props.currentCourse);
  125. pointData.currentCourse = props.currentCourse;
  126. pointData.kjId = props.kjId;
  127. pointData.zsdId = props.zsdId;
  128. pointData.allList = props.allList;
  129. }
  130. );
  131. return () => (
  132. <div class={styles.container}>
  133. <div class={styles.pointHead}>
  134. <img src={iconMulv} />
  135. {props.itemName}
  136. </div>
  137. <div class={styles.kjColumn}>
  138. <div class={styles.kjLeft}>
  139. <img src={titleIcon} />
  140. <span>{pointData.currentCourse?.name}</span>
  141. </div>
  142. {pointData.allList?.length > 1 && (
  143. <img
  144. class={styles.kjRight}
  145. src={moreIcon}
  146. onClick={() => {
  147. console.log(pointData.allList);
  148. emit('courseSelect');
  149. }}
  150. />
  151. )}
  152. </div>
  153. <div class={styles.content}>
  154. <Collapse
  155. class={styles.collapse}
  156. modelValue={pointData.zsdId}
  157. onUpdate:modelValue={(val: any) => {
  158. pointData.zsdId = val;
  159. }}
  160. border={false}
  161. accordion>
  162. {pointData.currentCourse?.knowledgeList?.map((know: any) => (
  163. <CollapseItem
  164. center
  165. class={[
  166. styles.collapseItem,
  167. styles.collapseKnow,
  168. pointData.zsdId === know.id ? styles.activeItem2 : ''
  169. ]}
  170. border={false}
  171. isLink={false}
  172. title={know.name}
  173. titleClass={'van-ellipsis'}
  174. titleStyle={{ width: '80%' }}
  175. name={know.id}>
  176. {{
  177. default: () => (
  178. <>
  179. {know.materialInfo.map((material: any, index: number) => {
  180. return (
  181. <div
  182. class={[
  183. styles.matItem,
  184. props.itemActive == material.id
  185. ? styles.itemActive
  186. : ''
  187. ]}
  188. onClick={() => {
  189. console.log(pointData.allList);
  190. emit('handleSelect', {
  191. itemActive: material.id,
  192. zsdId: know.id,
  193. kjId: pointData.currentCourse?.id
  194. });
  195. }}>
  196. {material.paymentType === 'VIP' && (
  197. <span
  198. class={[
  199. styles.iconPayment,
  200. styles[material.paymentType]
  201. ]}>
  202. VIP
  203. </span>
  204. )}
  205. <div class={styles.cover}>
  206. <img src={material.url} />
  207. <div class={styles.audioPlayTypeSection}>
  208. {material.audioPlayTypesArray.includes(
  209. 'PLAY'
  210. ) && (
  211. <img
  212. src={iconPlayDefault}
  213. class={styles.iconPlay}
  214. />
  215. )}
  216. {material.audioPlayTypesArray.includes(
  217. 'SING'
  218. ) && (
  219. <img
  220. src={iconSingDefault}
  221. class={styles.iconPlay}
  222. />
  223. )}
  224. </div>
  225. </div>
  226. <div class={styles.title}>
  227. {/* <div class={styles.tag}>{types[material.type]}</div> */}
  228. <img
  229. class={styles.typeImg}
  230. src={imgTypes[material.type]}
  231. />
  232. <div class={styles.tName}>{material.name}</div>
  233. </div>
  234. </div>
  235. );
  236. })}
  237. </>
  238. ),
  239. icon: () => (
  240. <img
  241. class={styles.arrow}
  242. src={
  243. pointData.zsdId === know.id
  244. ? chapterDown
  245. : chapterDefault
  246. }
  247. />
  248. )
  249. }}
  250. </CollapseItem>
  251. ))}
  252. </Collapse>
  253. {/* {props.allList.length &&
  254. <Collapse
  255. class={styles.collapse}
  256. modelValue={pointData.kjId}
  257. onUpdate:modelValue={(val: any) => {
  258. pointData.kjId = val;
  259. }}
  260. border={false}
  261. accordion>
  262. {props.allList.map((item: any) => (
  263. <CollapseItem
  264. class={[
  265. styles.collapseItem,
  266. pointData.kjId === item.id ? styles.activeItem : ''
  267. ]}
  268. border={false}
  269. isLink={false}
  270. title={item.name}
  271. titleStyle={{ width: '80%' }}
  272. name={item.id}>
  273. {{
  274. default: () => (
  275. <>
  276. <Collapse
  277. class={styles.collapse}
  278. modelValue={pointData.zsdId}
  279. onUpdate:modelValue={(val: any) => {
  280. pointData.zsdId = val;
  281. }}
  282. border={false}
  283. accordion>
  284. {item.knowledgeList.map((know: any) => (
  285. <CollapseItem
  286. center
  287. class={[
  288. styles.collapseItem,
  289. styles.collapseKnow,
  290. pointData.zsdId === know.id ? styles.activeItem2 : ''
  291. ]}
  292. border={false}
  293. isLink={false}
  294. title={know.name}
  295. titleClass={'van-ellipsis'}
  296. titleStyle={{ width: '80%' }}
  297. name={know.id}>
  298. {{
  299. default: () => (
  300. <>
  301. {know.materialInfo.map((material: any, index: number) => {
  302. return (
  303. <div
  304. class={[
  305. styles.matItem,
  306. props.itemActive == material.id ? styles.itemActive : ''
  307. ]}
  308. onClick={() => {
  309. console.log(pointData.allList)
  310. emit('handleSelect', {
  311. itemActive: material.id,
  312. zsdId: know.id,
  313. kjId: item.id
  314. });
  315. }}>
  316. <div class={styles.cover}>
  317. <img src={material.url} />
  318. </div>
  319. <div class={styles.title}>
  320. <div class={styles.tag}>{types[material.type]}</div>
  321. <div class={styles.tName}>{material.name}</div>
  322. </div>
  323. </div>
  324. );
  325. })}
  326. </>
  327. ),
  328. icon: () => (
  329. <img
  330. class={styles.arrow}
  331. src={
  332. pointData.zsdId === know.id
  333. ? chapterDown
  334. : chapterDefault2
  335. }
  336. />
  337. )
  338. }}
  339. </CollapseItem>
  340. ))}
  341. </Collapse>
  342. </>
  343. ),
  344. icon: () => (
  345. <img
  346. class={[styles.arrow, styles.firstArrow]}
  347. src={
  348. pointData.kjId === item.id
  349. ? chapterDown
  350. : chapterDefault
  351. }
  352. />
  353. )
  354. }}
  355. </CollapseItem>
  356. ))}
  357. </Collapse>
  358. } */}
  359. {/* {props.data.map((item, index: number) => {
  360. return (
  361. <div
  362. class={[
  363. styles.item,
  364. props.itemActive == item.id ? styles.itemActive : ''
  365. ]}
  366. onClick={() => {
  367. emit('handleSelect', {
  368. itemActive: item.id
  369. });
  370. }}>
  371. <div class={styles.cover}>
  372. <img src={item.url} />
  373. </div>
  374. <div class={styles.title}>
  375. <div class={styles.tag}>{types[item.type]}</div>
  376. <div>{item.name}</div>
  377. </div>
  378. </div>
  379. );
  380. })} */}
  381. </div>
  382. </div>
  383. );
  384. }
  385. });