CourseTree.vue 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407
  1. <template>
  2. <div class="course_tree">
  3. <div v-for="(courseItem, courseIndex) in treeList" :key="courseIndex">
  4. <div v-if="courseItem.courseList" class="teacherList_name">
  5. <div
  6. v-for="tea in courseItem.courseList"
  7. :key="tea.courseId"
  8. class="names"
  9. :class="{ nactive: tea.courseId == courseItem.courseId }"
  10. @click="activeFunc(tea.courseId, courseIndex)"
  11. >
  12. {{ tea.aliasName }}
  13. </div>
  14. </div>
  15. <div
  16. class="item__title"
  17. @click="getMenuList(courseItem)"
  18. v-if="treeList.length != 1"
  19. >
  20. <i
  21. :class="{
  22. 'el-icon-caret-right': !courseItem.showList,
  23. 'el-icon-caret-bottom': courseItem.showList,
  24. }"
  25. ></i>
  26. {{ courseItem.courseName }}
  27. </div>
  28. <div
  29. v-if="courseItem.showList"
  30. :style="{ paddingLeft: treeList.length != 1 ? '12px' : '0' }"
  31. >
  32. <div class="item" v-for="(menu, index) in courseItem.list" :key="index">
  33. <template v-if="menu.type == 1">
  34. <div class="item__title" @click="openModule(menu)">
  35. <i
  36. :class="{
  37. 'el-icon-caret-right': !menu.showList,
  38. 'el-icon-caret-bottom': menu.showList,
  39. }"
  40. ></i>
  41. {{ menu.menuName }}
  42. </div>
  43. <div class="item__content">
  44. <div class="bank-chapter" v-if="menu.showList">
  45. <div
  46. class="bank-chapter__item"
  47. v-for="chapter in menu.list"
  48. :key="chapter.id"
  49. >
  50. <div
  51. v-if="chapter.type == 1"
  52. class="bank-chapter__item__text"
  53. @click="openChapter(chapter)"
  54. >
  55. <i
  56. :class="{
  57. 'el-icon-caret-right': !chapter.showList,
  58. 'el-icon-caret-bottom': chapter.showList,
  59. }"
  60. ></i
  61. >{{ chapter.name }}
  62. </div>
  63. <div
  64. class="bank-section"
  65. v-if="chapter.showList && chapter.type == 1"
  66. >
  67. <div
  68. class="bank-section__item"
  69. :class="{
  70. active: isActive(section),
  71. }"
  72. v-for="(section, sectionIndex) in chapter.list"
  73. :key="sectionIndex"
  74. @click="getResource(section, 1, courseIndex)"
  75. >
  76. <template v-if="section.type != 2">
  77. <template>
  78. <div
  79. class="note note--blue"
  80. v-if="section.sectionType == 1"
  81. >
  82. 视频
  83. </div>
  84. <div class="note" v-if="section.sectionType == 2">
  85. 直播
  86. </div>
  87. <div
  88. class="note note--yellow"
  89. v-if="section.sectionType == 3"
  90. >
  91. 回放
  92. </div>
  93. <div class="bank-section__item__text">
  94. {{ section.name }}
  95. <div
  96. style="font-size: 12px"
  97. v-if="section.liveStartTime > nowTime"
  98. >
  99. <span>{{
  100. $tools.timestampToTime(
  101. section.liveStartTime,
  102. (isDay = false)
  103. )
  104. }}</span
  105. >-
  106. <span>{{
  107. $tools.timestampToTime(
  108. section.liveEndTime,
  109. (isDay = false)
  110. )
  111. }}</span>
  112. </div>
  113. </div>
  114. </template>
  115. <div class="lear-state" v-if="isActive(section)">
  116. <img src="../../assets/learing.gif" alt="" />
  117. </div>
  118. <template v-if="section.durationTime > 0">
  119. <div class="during">
  120. {{ $tools.secondToDate(section.durationTime) }}
  121. </div>
  122. </template>
  123. <template>
  124. <div class="btn" v-if="section.rebuild > 0">
  125. 待重修
  126. </div>
  127. <template v-else>
  128. <div
  129. class="btn btn--green"
  130. v-if="section.learning == 1"
  131. >
  132. 已学完
  133. </div>
  134. </template>
  135. </template>
  136. <template
  137. v-if="
  138. section.liveStartTime && section.sectionType == 2
  139. "
  140. >
  141. <div
  142. class="live-btn live-btn--blue"
  143. v-if="section.liveStartTime > nowTime"
  144. >
  145. 待开播
  146. </div>
  147. <div
  148. class="live-btn live-btn--yellow"
  149. v-if="
  150. section.liveStartTime <= nowTime &&
  151. section.liveEndTime > nowTime
  152. "
  153. >
  154. 直播中
  155. </div>
  156. <div
  157. class="live-btn"
  158. v-if="section.liveEndTime < nowTime"
  159. >
  160. 已结束
  161. </div>
  162. </template>
  163. <template
  164. v-if="checkSection(section.sectionId, 'sectionExam')"
  165. >
  166. <div
  167. class="exercises"
  168. @click.stop="
  169. handelPracticeOrRxam(
  170. section,
  171. 2,
  172. courseItem.courseId
  173. )
  174. "
  175. >
  176. 习题
  177. <i class="el-icon-arrow-right icons"></i>
  178. </div>
  179. </template>
  180. </template>
  181. <template v-if="section.type == 2">
  182. <template>
  183. <div class="test-btn" v-if="section.doType == 1">
  184. 练习
  185. </div>
  186. <div class="test-btn" v-if="section.doType != 1">
  187. 考试
  188. </div>
  189. </template>
  190. <div class="bank-section__item__text">
  191. {{ section.name }}
  192. </div>
  193. <template>
  194. <div class="btn" v-if="section.rebuild > 0">
  195. 待重修
  196. </div>
  197. <template v-else>
  198. <div
  199. class="btn btn--green"
  200. v-if="section.learning == 1"
  201. >
  202. 合格
  203. </div>
  204. <div
  205. class="btn btn--red"
  206. v-if="section.learning == 0"
  207. >
  208. 不及格(需重考)
  209. </div>
  210. <div
  211. class="btn btn--green"
  212. v-if="section.rebuild > 0"
  213. >
  214. 待重测
  215. </div>
  216. </template>
  217. </template>
  218. </template>
  219. </div>
  220. </div>
  221. <div
  222. v-if="chapter.type == 2"
  223. class="bank-section__item"
  224. @click="getResource(chapter, 3, courseIndex)"
  225. >
  226. <template>
  227. <template>
  228. <div class="test-btn" v-if="chapter.doType == 1">
  229. 练习
  230. </div>
  231. <div class="test-btn" v-if="chapter.doType != 1">
  232. 考试
  233. </div>
  234. </template>
  235. <div class="bank-section__item__text">
  236. {{ chapter.name }}
  237. </div>
  238. <template>
  239. <div
  240. class="btn btn--green"
  241. v-if="chapter.learning == 1"
  242. >
  243. 合格
  244. </div>
  245. <div class="btn btn--red" v-if="chapter.learning == 0">
  246. 不及格(需重考)
  247. </div>
  248. </template>
  249. </template>
  250. </div>
  251. </div>
  252. </div>
  253. </div>
  254. </template>
  255. <template v-if="menu.type == 2">
  256. <div class="item__content">
  257. <div class="bank-chapter">
  258. <div class="bank-chapter__item">
  259. <div
  260. class="bank-chapter__item__text"
  261. @click="openChapter(menu)"
  262. >
  263. <i
  264. :class="{
  265. 'el-icon-caret-right': !menu.showList,
  266. 'el-icon-caret-bottom': menu.showList,
  267. }"
  268. ></i
  269. >{{ menu.menuName }}
  270. </div>
  271. <div class="bank-section" v-if="menu.showList">
  272. <div
  273. class="bank-section__item"
  274. :class="{
  275. active: isActive(section),
  276. }"
  277. v-for="(section, sectionIndex) in menu.list"
  278. :key="sectionIndex"
  279. @click="getResource(section, 1, courseIndex)"
  280. >
  281. <template v-if="section.type != 2">
  282. <template>
  283. <div
  284. class="note note--blue"
  285. v-if="section.sectionType == 1"
  286. >
  287. 视频
  288. </div>
  289. <div class="note" v-if="section.sectionType == 2">
  290. 直播
  291. </div>
  292. <div
  293. class="note note--yellow"
  294. v-if="section.sectionType == 3"
  295. >
  296. 回放
  297. </div>
  298. </template>
  299. <div class="bank-section__item__text">
  300. {{ section.name }}
  301. <div
  302. style="font-size: 12px"
  303. v-if="section.liveStartTime > nowTime"
  304. >
  305. <span>{{
  306. $tools.timestampToTime(
  307. section.liveStartTime,
  308. (isDay = false)
  309. )
  310. }}</span
  311. >-
  312. <span>{{
  313. $tools.timestampToTime(
  314. section.liveEndTime,
  315. (isDay = false)
  316. )
  317. }}</span>
  318. </div>
  319. </div>
  320. <div class="lear-state" v-if="isActive(section)">
  321. <img src="../../assets/learing.gif" alt="" />
  322. </div>
  323. <template v-if="section.durationTime > 0">
  324. <div class="during">
  325. {{ $tools.secondToDate(section.durationTime) }}
  326. </div>
  327. </template>
  328. <template>
  329. <div class="btn" v-if="section.rebuild > 0">
  330. 待重修
  331. </div>
  332. <template v-else>
  333. <div
  334. class="btn btn--green"
  335. v-if="section.learning == 1"
  336. >
  337. 已学完
  338. </div>
  339. </template>
  340. </template>
  341. <template
  342. v-if="
  343. section.liveStartTime && section.sectionType == 2
  344. "
  345. >
  346. <div
  347. class="live-btn live-btn--blue"
  348. v-if="section.liveStartTime > nowTime"
  349. >
  350. 待开播
  351. </div>
  352. <div
  353. class="live-btn live-btn--yellow"
  354. v-if="
  355. section.liveStartTime <= nowTime &&
  356. section.liveEndTime > nowTime
  357. "
  358. >
  359. 直播中
  360. </div>
  361. <div
  362. class="live-btn"
  363. v-if="section.liveEndTime < nowTime"
  364. >
  365. 已结束
  366. </div>
  367. </template>
  368. <template
  369. v-if="checkSection(section.sectionId, 'sectionExam')"
  370. >
  371. <div
  372. class="exercises"
  373. @click.stop="
  374. handelPracticeOrRxam(
  375. section,
  376. 2,
  377. courseItem.courseId
  378. )
  379. "
  380. >
  381. 习题
  382. <i class="el-icon-arrow-right icons"></i>
  383. </div>
  384. </template>
  385. </template>
  386. <template v-if="section.type == 2">
  387. <template>
  388. <div class="test-btn" v-if="section.doType == 1">
  389. 练习
  390. </div>
  391. <div class="test-btn" v-if="section.doType != 1">
  392. 考试
  393. </div>
  394. </template>
  395. <div class="bank-section__item__text">
  396. {{ section.name }}
  397. </div>
  398. <template>
  399. <div class="btn" v-if="section.rebuild > 0">
  400. 待重修
  401. </div>
  402. <template v-else>
  403. <div
  404. class="btn btn--green"
  405. v-if="section.learning == 1"
  406. >
  407. 合格
  408. </div>
  409. <div
  410. class="btn btn--red"
  411. v-if="section.learning == 0"
  412. >
  413. 不及格(需重考)
  414. </div>
  415. <div
  416. class="btn btn--green"
  417. v-if="section.rebuild > 0"
  418. >
  419. 待重测
  420. </div>
  421. </template>
  422. </template>
  423. </template>
  424. </div>
  425. </div>
  426. </div>
  427. </div>
  428. </div>
  429. </template>
  430. <template v-if="menu.type == 3">
  431. <div class="item__content">
  432. <div class="bank-section">
  433. <div
  434. class="bank-section__item"
  435. :class="{
  436. active: isActive(menu),
  437. }"
  438. @click="getResource(menu, 1, courseIndex)"
  439. >
  440. <template>
  441. <div class="note note--blue" v-if="menu.sectionType == 1">
  442. 视频
  443. </div>
  444. <div class="note" v-if="menu.sectionType == 2">直播</div>
  445. <div class="note note--yellow" v-if="menu.sectionType == 3">
  446. 回放
  447. </div>
  448. <div class="bank-section__item__text">
  449. {{ menu.name }}
  450. <div
  451. style="font-size: 12px"
  452. v-if="menu.liveStartTime > nowTime"
  453. >
  454. <span>{{
  455. $tools.timestampToTime(
  456. menu.liveStartTime,
  457. (isDay = false)
  458. )
  459. }}</span
  460. >-
  461. <span>{{
  462. $tools.timestampToTime(
  463. menu.liveEndTime,
  464. (isDay = false)
  465. )
  466. }}</span>
  467. </div>
  468. </div>
  469. </template>
  470. <div class="lear-state" v-if="isActive(menu)">
  471. <img src="../../assets/learing.gif" alt="" />
  472. </div>
  473. <template v-if="menu.durationTime > 0">
  474. <div class="during">
  475. {{ $tools.secondToDate(menu.durationTime) }}
  476. </div>
  477. </template>
  478. <template>
  479. <div class="btn" v-if="menu.rebuild > 0">待重修</div>
  480. <template v-else>
  481. <div class="btn btn--green" v-if="menu.learning == 1">
  482. 已学完
  483. </div>
  484. </template>
  485. </template>
  486. <template v-if="menu.liveStartTime && menu.sectionType == 2">
  487. <div
  488. class="live-btn live-btn--blue"
  489. v-if="menu.liveStartTime > nowTime"
  490. >
  491. 待开播
  492. </div>
  493. <div
  494. class="live-btn live-btn--yellow"
  495. v-if="
  496. menu.liveStartTime <= nowTime &&
  497. menu.liveEndTime > nowTime
  498. "
  499. >
  500. 直播中
  501. </div>
  502. <div class="live-btn" v-if="menu.liveEndTime < nowTime">
  503. 已结束
  504. </div>
  505. </template>
  506. <template v-if="checkSection(menu.menuId, 'sectionExamList')">
  507. <div
  508. class="exercises"
  509. @click.stop="
  510. handelPracticeOrRxam(menu, 3, courseItem.courseId)
  511. "
  512. >
  513. 习题
  514. <i class="el-icon-arrow-right icons"></i>
  515. </div>
  516. </template>
  517. </div>
  518. </div>
  519. </div>
  520. </template>
  521. </div>
  522. </div>
  523. </div>
  524. <el-dialog
  525. title="温馨提示"
  526. width="380px"
  527. center
  528. class="tip-dialog"
  529. :visible.sync="dialogPalyVisible"
  530. :close-on-click-modal="false"
  531. :close-on-press-escape="false"
  532. :show-close="false"
  533. >
  534. <template v-if="!isLastVideo">
  535. <p>当前视频已学完,继续学习下一个视频?</p>
  536. <div class="btn1">
  537. <el-button type="info" plain round @click="dialogPalyVisible = false"
  538. >取 消</el-button
  539. >
  540. <el-button type="primary" @click="comfirm" round>确定</el-button>
  541. </div>
  542. </template>
  543. <template v-else>
  544. <p>
  545. 当前是最后一个视频并已学习完,请检查所有章节的视频是否已学习完成。
  546. </p>
  547. <div class="btn2">
  548. <el-button type="primary" round @click="dialogPalyVisible = false"
  549. >确定</el-button
  550. >
  551. </div>
  552. </template>
  553. </el-dialog>
  554. </div>
  555. </template>
  556. <script>
  557. export default {
  558. props: {
  559. courseList: {
  560. type: Array,
  561. default: () => {
  562. return [];
  563. },
  564. },
  565. goodsLearningOrder: {
  566. type: Number,
  567. },
  568. sectionMaxNum: {
  569. type: Number,
  570. },
  571. sectionItem: {
  572. type: Object,
  573. default: () => {
  574. return {};
  575. },
  576. },
  577. rebuild: {
  578. type: Number,
  579. default: 0,
  580. },
  581. },
  582. data() {
  583. return {
  584. teaIndex: 0,
  585. nowTime: 0,
  586. treeList: [],
  587. sectionExam: [],
  588. sectionExamList: [],
  589. dialogPalyVisible: false,
  590. allSectionList: [],
  591. };
  592. },
  593. created() {
  594. this.init();
  595. },
  596. methods: {
  597. async init() {
  598. this.nowTime = Number(new Date().getTime() / 1000).toFixed(0);
  599. await this.getAllSectionList();
  600. this.treeList = await this.getDoubleTeacherList();
  601. let sectionItem = await this.backNextItem(
  602. this.treeList.find((e) => e.courseId == this.activeCourseId),
  603. 0,
  604. false
  605. );
  606. if (this.query.sectionType == 1 && !!this.query.rebuild == this.rebuild) {
  607. this.toPlay(sectionItem);
  608. }
  609. },
  610. activeFunc(courseId, index) {
  611. let { courseId: nowCourseId, courseList } = this.treeList[index];
  612. if (courseId == nowCourseId) {
  613. return;
  614. }
  615. let course = this.courseList.find((e) => e.courseId == courseId);
  616. if (course) {
  617. course.courseList = courseList;
  618. course.list = [];
  619. course.showList = false;
  620. }
  621. this.treeList.splice(index, 1, JSON.parse(JSON.stringify(course)));
  622. this.getMenuList(this.treeList[index]);
  623. },
  624. getMenuList(course, isFresh = false) {
  625. let { showList, courseId, list } = course;
  626. if (!isFresh) {
  627. course.showList = !showList;
  628. if (list.length) return;
  629. }
  630. this.$request
  631. .reSectionExamList({
  632. chapterId: 0,
  633. courseId,
  634. gradeId: this.gradeId,
  635. })
  636. .then((res) => {
  637. this.sectionExamList = res.data;
  638. });
  639. return this.$request
  640. .reMenuList({ courseId, gradeId: this.gradeId })
  641. .then((res) => {
  642. for (let i = 0; i < res.rows.length; i++) {
  643. let item = res.rows[i];
  644. item.id = item.menuId;
  645. item.name = item.menuName;
  646. item.menuType = item.type;
  647. item.showList = false;
  648. item.list = [];
  649. item.parent = course;
  650. }
  651. course.list = res.rows;
  652. return Promise.resolve(res.rows);
  653. });
  654. },
  655. openModule(module, isFresh = false) {
  656. console.log("openModule");
  657. let { list, isRebuild, id, courseId, showList } = module;
  658. if (!isFresh) {
  659. module.showList = !showList;
  660. if (list.length) return;
  661. }
  662. return this.$request
  663. .reChapterList({
  664. moduleId: id,
  665. gradeId: this.gradeId,
  666. courseId: courseId,
  667. rebuild: isRebuild ? 1 : undefined,
  668. })
  669. .then((res) => {
  670. for (let i = 0; i < res.data.length; i++) {
  671. let item = res.data[i];
  672. item.id = item.chapterId;
  673. item.showList = false;
  674. item.list = [];
  675. item.parent = module;
  676. isRebuild ? (item.isRebuild = 1) : (item.menuType = 2);
  677. }
  678. module.list = res.data;
  679. return Promise.resolve(res.data);
  680. });
  681. },
  682. openChapter(chapter, isFresh = false) {
  683. let {
  684. chapterId,
  685. menuId,
  686. list,
  687. moduleId,
  688. id,
  689. isRebuild,
  690. courseId,
  691. showList,
  692. } = chapter;
  693. if (!isFresh) {
  694. chapter.showList = !showList;
  695. if (list.length) return;
  696. }
  697. this.$request
  698. .reSectionExamList({
  699. chapterId: chapterId || menuId,
  700. courseId,
  701. gradeId: this.gradeId,
  702. })
  703. .then((res) => {
  704. this.sectionExam = [...this.sectionExam, ...res.data];
  705. });
  706. return this.$request
  707. .reSectionList({
  708. chapterId: id,
  709. gradeId: this.gradeId,
  710. courseId,
  711. rebuild: isRebuild ? 1 : undefined,
  712. moduleId: moduleId || 0,
  713. })
  714. .then((res) => {
  715. chapter.canLearn = res.data
  716. .filter((item) => item.type != 2)
  717. .every((item) => item.learning == 1);
  718. res.data.forEach((section) => {
  719. section.parent = chapter;
  720. section.courseId = courseId;
  721. });
  722. chapter.list = res.data;
  723. return Promise.resolve(chapter.list);
  724. });
  725. },
  726. getAllSectionList() {
  727. return this.$request
  728. .getAllSectionList({
  729. gradeId: this.gradeId,
  730. goodsId: this.goodsId,
  731. rebuild: this.rebuild,
  732. })
  733. .then((res) => {
  734. let { skipPort } = this.query;
  735. if (skipPort) {
  736. let { moduleId, chapterId, sectionId } = res.data[0];
  737. const query = JSON.parse(JSON.stringify(this.$route.query));
  738. query.moduleId = moduleId;
  739. query.chapterId = chapterId;
  740. query.sectionId = sectionId;
  741. query.skipPort = undefined;
  742. this.$router.push({ path: this.$route.path, query });
  743. }
  744. this.allSectionList = res.data;
  745. return Promise.resolve(res.data);
  746. });
  747. },
  748. /**
  749. * 判断是否是当前播放的节
  750. */
  751. isActive(section) {
  752. let moduleId = section.moduleId || 0;
  753. let chapterId = section.chapterId || 0;
  754. let sectionId = section.sectionId || section.menuId;
  755. let moduleId1 = this.sectionItem.moduleId || 0;
  756. let chapterId1 = this.sectionItem.chapterId || 0;
  757. let sectionId1 = this.sectionItem.sectionId || this.sectionItem.menuId;
  758. return (
  759. moduleId == moduleId1 &&
  760. chapterId == chapterId1 &&
  761. sectionId == sectionId1
  762. );
  763. },
  764. comfirm() {
  765. this.dialogPalyVisible = false;
  766. this.playNextVideo();
  767. },
  768. // 自动播放下一个视频
  769. async playNextVideo(sectionItem = this.sectionItem) {
  770. let { menuId, parent, courseId, projectId } = sectionItem;
  771. let list = (
  772. menuId
  773. ? this.treeList.find((e) => e.courseId == courseId).list
  774. : projectId
  775. ? this.treeList
  776. : parent.list
  777. ).filter((e) => !e.doType);
  778. let index = list.findIndex((e) => e.id == sectionItem.id);
  779. let nextItem = {};
  780. if (list.length - 1 > index) {
  781. nextItem = list[index + 1];
  782. this.toPlay(
  783. await this.backNextItem(nextItem, projectId ? 0 : nextItem.menuType)
  784. );
  785. } else {
  786. this.playNextVideo(parent);
  787. }
  788. },
  789. // 获取模块/章/节
  790. async backNextItem(nextItem, type, isNext = true) {
  791. if (type == undefined || type == 3) return nextItem;
  792. let key = ["getMenuList", "openModule", "openChapter"][type];
  793. let list = nextItem.list.length
  794. ? nextItem.list
  795. : await this[key](nextItem);
  796. if (isNext) {
  797. nextItem = type == 2 ? list.find((e) => e.type == 1) : list[0];
  798. } else {
  799. // 初始化 获取播放位置
  800. let { moduleId, chapterId, sectionId } = this.query;
  801. nextItem = list.find((e) => {
  802. if (moduleId * 1 && type == 0) {
  803. return e.menuId == moduleId;
  804. }
  805. if (chapterId * 1 && type < 2) {
  806. return e[moduleId * 1 ? "chapterId" : "menuId"] == chapterId;
  807. }
  808. return (
  809. e[moduleId * 1 || chapterId * 1 ? "sectionId" : "id"] == sectionId
  810. );
  811. });
  812. }
  813. return this.backNextItem(nextItem, nextItem.menuType, isNext);
  814. },
  815. async getResource(section, type, courseIndex) {
  816. if (
  817. section.type != 2 &&
  818. this.isActive(section) &&
  819. section.sectionType != 3
  820. ) {
  821. return;
  822. }
  823. if (!(await this.orderTopTobottom(section, type, courseIndex))) {
  824. this.clickLock = false;
  825. this.$message({
  826. type: "warning",
  827. message:
  828. section.type == 2
  829. ? "请学完视频课程再进行练习和测试"
  830. : "请按顺序学习视频课程",
  831. });
  832. return false;
  833. }
  834. //视频 回放
  835. if (section.sectionType == 1 || section.sectionType == 3) {
  836. if (!section.recordingUrl) {
  837. this.$message({
  838. type: "warning",
  839. message: `暂无播放地址数据`,
  840. });
  841. return false;
  842. }
  843. }
  844. // 直播
  845. if (section.sectionType == 2) {
  846. if (!section.liveUrl) {
  847. this.$message({
  848. type: "warning",
  849. message: `暂无直播地址数据`,
  850. });
  851. return false;
  852. }
  853. let data = await this.studyRecordGetChannelBasicInfo(section.liveUrl);
  854. if (data.watchStatus == "end" || data.watchStatus == "playback") {
  855. this.$message({
  856. type: "warning",
  857. message: `直播已结束`,
  858. });
  859. return false;
  860. }
  861. if (data.watchStatus == "waiting") {
  862. this.$message({
  863. type: "warning",
  864. message: `直播未开始`,
  865. });
  866. return false;
  867. }
  868. }
  869. // 学习次数
  870. if (!(await this.exceedLearnNum(section))) {
  871. return false;
  872. }
  873. section.type == 2
  874. ? this.toCourseExam(section, type, courseIndex)
  875. : this.toPlay(section);
  876. },
  877. async toCourseExam(section, type, courseIndex) {
  878. //试卷
  879. // 学习次数
  880. let num =
  881. this.goodsLearningOrder != 2 || section.rebuild
  882. ? await this.bankRecordDoNum(section.typeId)
  883. : section.doNum;
  884. if (
  885. (section.answerNum - num > 0 && section.answerNum > 0) ||
  886. section.answerNum == 0
  887. ) {
  888. this.$router.push({
  889. path: "/course-exam/" + this.goodsId,
  890. query: {
  891. courseId: this.treeList[courseIndex].courseId,
  892. gradeId: this.gradeId,
  893. moduleId: section.moduleId || 0,
  894. sectionId: section.sectionId || 0,
  895. examId: section.typeId,
  896. learning: section.learning,
  897. type: type,
  898. chapterId: section.chapterId || 0,
  899. orderGoodsId: this.orderGoodsId,
  900. },
  901. });
  902. } else {
  903. this.$message({
  904. type: "warning",
  905. message: "该试卷只能答题" + section.answerNum + "次",
  906. });
  907. return;
  908. }
  909. },
  910. // 节卷不需要控制
  911. handelPracticeOrRxam(section, type, courseId) {
  912. if (type == 3) {
  913. //节卷
  914. let data = this.sectionExamList.filter(
  915. (x) => x.sectionId == section.menuId
  916. );
  917. if (data && data.length > 0) {
  918. section = data[0];
  919. }
  920. } else if (type == 2) {
  921. //节卷
  922. let data = this.sectionExam.filter(
  923. (x) => x.sectionId == section.sectionId
  924. );
  925. if (data && data.length > 0) {
  926. section = data[0];
  927. }
  928. }
  929. this.$router.push({
  930. path: "/course-exam/" + this.goodsId,
  931. query: {
  932. courseId,
  933. gradeId: this.gradeId,
  934. moduleId: section.moduleId || 0,
  935. sectionId: section.sectionId || 0,
  936. examId: section.typeId,
  937. learning: section.learning,
  938. type: type,
  939. chapterId: section.chapterId || 0,
  940. orderGoodsId: this.orderGoodsId,
  941. },
  942. });
  943. },
  944. async exceedLearnNum(section) {
  945. let learnNum = await this.goodsTodayStudySectionNum();
  946. let hasLearn = await this.gradeCheckGoodsStudy(
  947. section.type == 2 ? section.typeId : section
  948. );
  949. if (this.sectionMaxNum > 0) {
  950. if (learnNum >= this.sectionMaxNum && !hasLearn) {
  951. this.$message({
  952. type: "warning",
  953. message: `每天最多学习${this.sectionMaxNum}节`,
  954. });
  955. return false;
  956. }
  957. }
  958. return true;
  959. },
  960. goodsTodayStudySectionNum() {
  961. return new Promise((resolve) => {
  962. this.$request
  963. .goodsTodayStudySectionNum({
  964. goodsId: this.goodsId,
  965. gradeId: this.gradeId,
  966. })
  967. .then((res) => {
  968. resolve(res.data);
  969. });
  970. });
  971. },
  972. gradeCheckGoodsStudy(option) {
  973. return new Promise((resolve) => {
  974. this.$request
  975. .gradeCheckGoodsStudy({
  976. goodsId: this.goodsId,
  977. gradeId: this.gradeId,
  978. moduleId: option.moduleId || 0,
  979. chapterId: option.chapterId || 0,
  980. sectionId: option.sectionId || option.menuId,
  981. })
  982. .then((res) => {
  983. resolve(res.data);
  984. });
  985. });
  986. },
  987. bankRecordDoNum(section) {
  988. return new Promise((resolve) => {
  989. this.$request
  990. .bankRecordDoNum({
  991. goodsId: this.goodsId,
  992. gradeId: this.gradeId,
  993. chapterId: section.chapterId,
  994. courseId: this.courseId,
  995. moduleId: 0,
  996. examId: section.typeId,
  997. })
  998. .then((res) => {
  999. resolve(res.data);
  1000. });
  1001. });
  1002. },
  1003. toPlay(section) {
  1004. console.log(section, 777);
  1005. this.$emit("getResource", section, this.rebuild);
  1006. },
  1007. //获取商品双师资模板
  1008. getDoubleTeacherList() {
  1009. let rows = JSON.parse(JSON.stringify(this.courseList));
  1010. rows.forEach((e) => {
  1011. e.list = [];
  1012. e.showList = false;
  1013. e.id = e.courseId;
  1014. });
  1015. return this.$request
  1016. .courseTeacherList({
  1017. goodsId: this.$route.params.goodsId,
  1018. })
  1019. .then(({ data }) => {
  1020. data.forEach((ele) => {
  1021. rows.forEach((e, i) => {
  1022. let actvieIndex = ele.courseIds.indexOf(this.activeCourseId);
  1023. let index = ele.courseIds.indexOf(e.courseId);
  1024. if (actvieIndex != -1 && index != -1) {
  1025. if (e.courseId == this.activeCourseId) {
  1026. e.courseList = ele.courseList;
  1027. } else {
  1028. delete rows[i];
  1029. }
  1030. } else {
  1031. if (index == 0) {
  1032. e.courseList = ele.courseList;
  1033. }
  1034. if (index > 0) {
  1035. delete rows[i];
  1036. }
  1037. }
  1038. });
  1039. });
  1040. return Promise.resolve(rows.filter((e) => e));
  1041. });
  1042. },
  1043. async orderTopTobottom(section, type, courseIndex) {
  1044. let { rebuild, moduleId, chapterId } = section;
  1045. if (this.goodsLearningOrder != 2 || rebuild) {
  1046. return true;
  1047. }
  1048. if (this.treeList.length > 1 && courseIndex > 0) {
  1049. let isAllLear = this.treeList
  1050. .filter((e, i) => i < courseIndex)
  1051. .every((ele) => ele.stuAllNum == ele.secAllNum);
  1052. if (!isAllLear) return false;
  1053. }
  1054. let list = await this.studyRecordMenuAllList(
  1055. this.treeList[courseIndex].courseId
  1056. );
  1057. type = type == 1 && section.type == 2 ? 2 : type;
  1058. if (type == 1) {
  1059. let index = list.findIndex(
  1060. (e) =>
  1061. e.moduleId == moduleId &&
  1062. e.chapterId == chapterId &&
  1063. e.id == section.sectionId
  1064. );
  1065. list = list.slice(0, index);
  1066. } else if (type != 3) {
  1067. list = list.filter(
  1068. (e) => e.moduleId == moduleId && e.chapterId == chapterId
  1069. );
  1070. }
  1071. return list.every((item) => item.studyStatus == 1);
  1072. },
  1073. studyRecordMenuAllList(courseId) {
  1074. return new Promise((resolve) => {
  1075. this.$request
  1076. .studyRecordMenuAllList({
  1077. courseId,
  1078. gradeId: this.gradeId,
  1079. goodsId: this.goodsId,
  1080. })
  1081. .then((res) => {
  1082. resolve(res.data);
  1083. });
  1084. });
  1085. },
  1086. //校验节是否有试卷
  1087. checkSection(sectionId, key) {
  1088. let _data = this[key];
  1089. if (_data.length == 0) {
  1090. return false;
  1091. }
  1092. return _data.some((section) => section.sectionId == sectionId);
  1093. },
  1094. // 刷新数据
  1095. refreshList() {
  1096. let { parent, menuId } = this.sectionItem;
  1097. if (menuId) {
  1098. this.getMenuList(playCourse, true);
  1099. } else {
  1100. this.openChapter(parent, true);
  1101. }
  1102. },
  1103. studyRecordGetChannelBasicInfo(channelId) {
  1104. return new Promise((resolve) => {
  1105. this.$request
  1106. .studyRecordGetChannelBasicInfo({
  1107. channelId,
  1108. })
  1109. .then((res) => {
  1110. resolve(res.data);
  1111. })
  1112. .catch((err) => {});
  1113. });
  1114. },
  1115. },
  1116. computed: {
  1117. query() {
  1118. return this.$route.query;
  1119. },
  1120. gradeId() {
  1121. return this.query.gradeId;
  1122. },
  1123. activeCourseId() {
  1124. let courseId = this.query.courseId;
  1125. if (!courseId&&this.treeList.length) {
  1126. courseId = this.treeList[0].courseId;
  1127. }
  1128. return courseId;
  1129. },
  1130. goodsId() {
  1131. return this.$route.params.goodsId;
  1132. },
  1133. playCourseId() {
  1134. return this.sectionItem.courseId;
  1135. },
  1136. playCourse() {
  1137. return this.treeList.find((e) => e.courseId == this.playCourseId);
  1138. },
  1139. isLastVideo() {
  1140. try {
  1141. let { sectionId, chapterId, courseId } = this.sectionItem;
  1142. let lastVideo = this.allSectionList.slice(-1)[0];
  1143. return (
  1144. sectionId == lastVideo.sectionId &&
  1145. chapterId == lastVideo.chapterId &&
  1146. courseId == lastVideo.courseId
  1147. );
  1148. } catch (error) {
  1149. return false;
  1150. }
  1151. },
  1152. orderGoodsId() {
  1153. return this.query.orderGoodsId;
  1154. },
  1155. },
  1156. };
  1157. </script>
  1158. <style scoped lang="scss">
  1159. .course_tree {
  1160. height: 380px;
  1161. overflow-y: scroll;
  1162. &::-webkit-scrollbar {
  1163. display: none;
  1164. }
  1165. .item {
  1166. &__title {
  1167. padding-left: 12px;
  1168. height: 40px;
  1169. line-height: 40px;
  1170. cursor: pointer;
  1171. font-size: 14px;
  1172. font-family: Microsoft YaHei;
  1173. font-weight: bold;
  1174. color: #fff;
  1175. .el-icon-caret-right,
  1176. .el-icon-caret-bottom {
  1177. color: #999;
  1178. }
  1179. }
  1180. &__content {
  1181. .bank-chapter {
  1182. &__item {
  1183. color: #fff;
  1184. font-size: 14px;
  1185. &__text {
  1186. padding: 8px 8px 8px 24px;
  1187. cursor: pointer;
  1188. flex: 1;
  1189. .el-icon-caret-right,
  1190. .el-icon-caret-bottom {
  1191. color: #999;
  1192. }
  1193. }
  1194. }
  1195. }
  1196. .bank-section {
  1197. &__item {
  1198. user-select: none;
  1199. color: #fff;
  1200. font-size: 14px;
  1201. display: flex;
  1202. align-items: center;
  1203. .lear-state {
  1204. height: 20px;
  1205. padding-right: 8px;
  1206. img {
  1207. width: 20px;
  1208. height: 20px;
  1209. // margin-right: 4px;
  1210. }
  1211. }
  1212. &.active {
  1213. background: #132b4d;
  1214. font-size: 14px;
  1215. font-family: Microsoft YaHei;
  1216. font-weight: bold;
  1217. color: #3f8dfd;
  1218. }
  1219. &__text {
  1220. flex: 1;
  1221. padding: 8px 8px 8px 12px;
  1222. height: 40px;
  1223. display: flex;
  1224. flex-direction: column;
  1225. justify-content: center;
  1226. cursor: pointer;
  1227. .el-icon-caret-right,
  1228. .el-icon-caret-bottom {
  1229. color: #999;
  1230. }
  1231. }
  1232. .test-btn {
  1233. margin-left: 10px;
  1234. width: 32px;
  1235. height: 20px;
  1236. background: #007aff;
  1237. border-radius: 4px;
  1238. line-height: 18px;
  1239. color: #fff;
  1240. text-align: center;
  1241. }
  1242. .note {
  1243. margin-left: 10px;
  1244. width: 32px;
  1245. height: 20px;
  1246. border: 1px solid #ff3b30;
  1247. border-radius: 4px;
  1248. line-height: 18px;
  1249. color: #ff3b30;
  1250. text-align: center;
  1251. &--yellow {
  1252. border-color: #ff9500;
  1253. color: #ff9500;
  1254. }
  1255. &--blue {
  1256. border-color: #3f8dfd;
  1257. color: #3f8dfd;
  1258. }
  1259. }
  1260. .during {
  1261. color: #999;
  1262. margin-right: 10px;
  1263. }
  1264. .btn {
  1265. margin-right: 12px;
  1266. padding: 0 2px;
  1267. height: 20px;
  1268. border: 1px solid #ff3b30;
  1269. background: #ff3b30;
  1270. border-radius: 4px;
  1271. line-height: 18px;
  1272. color: #fff;
  1273. text-align: center;
  1274. &--green {
  1275. border: 1px solid #34c759;
  1276. background: #34c759;
  1277. }
  1278. }
  1279. .live-btn {
  1280. margin-left: 20px;
  1281. width: 60px;
  1282. height: 20px;
  1283. border-radius: 4px;
  1284. background: #eeeeee;
  1285. line-height: 18px;
  1286. color: #666666;
  1287. text-align: center;
  1288. &--yellow {
  1289. background: #fff7eb;
  1290. color: #ff9500;
  1291. }
  1292. &--blue {
  1293. border-color: #ebf4ff;
  1294. color: #007aff;
  1295. }
  1296. }
  1297. .exercises {
  1298. cursor: pointer;
  1299. font-size: 14px;
  1300. color: #498afe;
  1301. }
  1302. }
  1303. }
  1304. }
  1305. }
  1306. .teacherList_name {
  1307. display: flex;
  1308. margin-left: 20px;
  1309. margin-top: 10px;
  1310. .names {
  1311. font-size: 13px;
  1312. color: #383838;
  1313. margin-right: 8px;
  1314. cursor: pointer;
  1315. background: #818181;
  1316. border-radius: 4px;
  1317. padding: 3px 6px;
  1318. &.nactive {
  1319. background: #cccccc;
  1320. }
  1321. }
  1322. }
  1323. .tip-dialog {
  1324. /deep/ {
  1325. .el-dialog__body {
  1326. padding: 6px 40px 44px;
  1327. }
  1328. .el-dialog__header {
  1329. padding-top: 36px;
  1330. }
  1331. .el-dialog__title {
  1332. font-weight: bold;
  1333. color: #222222;
  1334. }
  1335. }
  1336. p {
  1337. color: #666666;
  1338. font-size: 16px;
  1339. text-align: center;
  1340. }
  1341. .btn1 {
  1342. display: flex;
  1343. justify-content: space-between;
  1344. margin-top: 50px;
  1345. .el-button {
  1346. width: 140px;
  1347. }
  1348. }
  1349. .btn2 {
  1350. width: 200px;
  1351. margin: 32px auto 0;
  1352. .el-button {
  1353. width: 200px;
  1354. }
  1355. }
  1356. }
  1357. }
  1358. </style>