index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618
  1. <template>
  2. <div class="play-record">
  3. <div class="play-record__header clearfix">
  4. 播放记录
  5. <!-- <a class="clear-btn">清空记录</a> -->
  6. </div>
  7. <div class="play-record__body">
  8. <div class="date-item" v-for="(v, k) in recordList" :key="k">
  9. <div class="date-item__header">{{ k }}</div>
  10. <div class="date-item__body">
  11. <div class="list">
  12. <div
  13. class="course-item"
  14. v-for="(sectionItem, sectionIndex) in v.list"
  15. :key="'section' + sectionIndex"
  16. >
  17. <div class="course-item__header">{{ sectionItem.goodsName }}</div>
  18. <div class="course-item__body">
  19. <div class="img" @click="goCourse(sectionItem)">
  20. <img
  21. :src="$tools.splitImgHost(sectionItem.coverUrl, true)"
  22. alt=""
  23. />
  24. </div>
  25. <div class="text">
  26. <div class="title">
  27. {{ sectionItem.sectionName }}
  28. <!-- <div class="note">60学时</div> -->
  29. </div>
  30. <div
  31. class="progress"
  32. v-if="
  33. sectionItem.sectionType != 2 && sectionItem.goodsType != 6
  34. "
  35. >
  36. 学习进度
  37. <el-progress
  38. class="progress-line"
  39. :text-inside="true"
  40. :stroke-width="16"
  41. :percentage="
  42. toFixed(
  43. (sectionItem.videoCurrentTime /
  44. sectionItem.durationTime) *
  45. 100
  46. )
  47. "
  48. ></el-progress>
  49. </div>
  50. </div>
  51. <!-- <div class="btns-wrap">
  52. <div class="btns">
  53. <div class="btn btn--warm">删除记录</div>
  54. </div>
  55. </div> -->
  56. </div>
  57. </div>
  58. </div>
  59. </div>
  60. </div>
  61. </div>
  62. <div class="play-record__footer">
  63. <div class="pagination">
  64. <el-pagination
  65. @current-change="currentChange"
  66. background
  67. layout="prev, pager, next"
  68. :total="total"
  69. :pager-count="5"
  70. :page-size="params.pageSize"
  71. >
  72. </el-pagination>
  73. </div>
  74. </div>
  75. <RebuildModal
  76. ref="rebuildModal"
  77. @rebuildSubmit="rebuildSubmit($event)"
  78. ></RebuildModal>
  79. </div>
  80. </template>
  81. <script>
  82. import RebuildModal from "@/components/rebuildModal";
  83. export default {
  84. name: "MyCourse",
  85. components: {
  86. RebuildModal,
  87. },
  88. data() {
  89. return {
  90. activeName: "1",
  91. recordList: {},
  92. total: 0,
  93. rebuildItems: [],
  94. rebuildItem: {},
  95. params: {
  96. pageNum: 1,
  97. pageSize: 10,
  98. },
  99. sysTime: 0,
  100. };
  101. },
  102. mounted() {
  103. this.studRrecordListUserRecord();
  104. },
  105. methods: {
  106. toFixed(num) {
  107. console.log(num);
  108. if (num) {
  109. let str = String(num).indexOf(".");
  110. if (str != -1) {
  111. return +num.toFixed(2);
  112. } else {
  113. return num;
  114. }
  115. } else {
  116. return 0;
  117. }
  118. },
  119. rebuildSubmit() {
  120. this.$router.push({
  121. path: `/my-course-detail/${item.goodsId}`,
  122. query: {
  123. gradeId: item.gradeId,
  124. orderGoodsId: item.orderGoodsId,
  125. rebuild: 1,
  126. },
  127. });
  128. },
  129. currentChange(e) {
  130. this.params.pageNum = e;
  131. this.studRrecordListUserRecord();
  132. },
  133. studRrecordListUserRecord() {
  134. this.$request.studRrecordListUserRecord(this.params).then((res) => {
  135. let dateObj = {};
  136. res.rows.forEach((row) => {
  137. if (!dateObj[row.date]) {
  138. dateObj[row.date] = { title: row.goodsName, list: [] };
  139. dateObj[row.date].list.push(row);
  140. } else {
  141. dateObj[row.date].list.push(row);
  142. }
  143. });
  144. // for (let k in dateObj) {
  145. // dateObj[k].list.sort((a, b) => {
  146. // return a.createTime - b.createTime;
  147. // });
  148. // }
  149. console.log(dateObj, "dateObj");
  150. this.recordList = dateObj;
  151. this.total = res.total;
  152. });
  153. },
  154. async goCourse(sectionItem) {
  155. this.sysTime = this.$tools.timest();
  156. this.$request
  157. .orderInfo({
  158. orderGoodsId: sectionItem.orderGoodsId,
  159. })
  160. .then(async (res) => {
  161. let item = res.data;
  162. // if (item.interfacePushId > 0 && item.officialStatus != 1) {
  163. // this.$message({
  164. // type: "warning",
  165. // message:
  166. // "机构正在为您报名中,请耐心等待,有疑问请联系020-87085982!",
  167. // });
  168. // return;
  169. // }
  170. if (
  171. this.sysTime <= item.serviceStartTime ||
  172. this.sysTime >= item.serviceEndTime
  173. ) {
  174. this.$message({
  175. type: "warning",
  176. message: "不在学习服务期,不能进入学习",
  177. });
  178. return;
  179. }
  180. if (
  181. (item.classStartTime && this.sysTime <= item.classStartTime) ||
  182. (item.classEndTime && this.sysTime >= item.classEndTime)
  183. ) {
  184. this.$message({
  185. type: "warning",
  186. message: "不在班级有效期,不能进入学习",
  187. });
  188. return;
  189. }
  190. if (item.learningStatus == 2) {
  191. this.$message({
  192. type: "warning",
  193. message: "开放学习时间待定,不能进入学习",
  194. });
  195. return;
  196. }
  197. if (item.classStatus == 0) {
  198. this.$message({
  199. type: "warning",
  200. message: "尚未开班,不能进入学习",
  201. });
  202. return;
  203. }
  204. if (
  205. item.learningStatus == 3 &&
  206. this.sysTime < item.learningTimeStart
  207. ) {
  208. this.$message({
  209. type: "warning",
  210. message: "不在开放学习时间,不能进入学习",
  211. });
  212. return;
  213. }
  214. let rebuildStatus = await this.courseGoodsRebuildStatus(
  215. item.goodsId,
  216. item.gradeId
  217. );
  218. if (rebuildStatus == 0) {
  219. if (rebuildStatus == 0) {
  220. this.$refs.rebuildModal.showModal(item);
  221. return;
  222. }
  223. }
  224. // if (item.educationName == "继续教育") {
  225. this.$request
  226. .lockLockStatus({
  227. action: "jxjy",
  228. })
  229. .then((res) => {
  230. //有其他端在操作,不能学习
  231. this.$message({
  232. type: "warning",
  233. message: res.msg,
  234. });
  235. })
  236. .catch((err) => {
  237. //可以学习
  238. this.$request
  239. .courseCourseList({
  240. pageNum: 1,
  241. pageSize: 1,
  242. goodsId: item.goodsId,
  243. gradeId: item.gradeId,
  244. })
  245. .then((res) => {
  246. if (res.rows.length) {
  247. this.go("/my-course-detail/" + sectionItem.goodsId, {
  248. gradeId: sectionItem.gradeId,
  249. orderGoodsId: sectionItem.orderGoodsId,
  250. courseId: sectionItem.courseId,
  251. });
  252. } else {
  253. this.$message({
  254. type: "warning",
  255. message: "课程内暂无可以学习的科目",
  256. });
  257. }
  258. });
  259. });
  260. // } else {
  261. // this.$request
  262. // .courseCourseList({
  263. // pageNum: 1,
  264. // pageSize: 1,
  265. // goodsId: item.goodsId,
  266. // gradeId: item.gradeId,
  267. // })
  268. // .then((res) => {
  269. // if (res.rows.length) {
  270. // this.go("/my-course-detail/" + sectionItem.goodsId, {
  271. // gradeId: sectionItem.gradeId,
  272. // orderGoodsId: sectionItem.orderGoodsId,
  273. // courseId: sectionItem.courseId,
  274. // });
  275. // } else {
  276. // this.$message({
  277. // type: "warning",
  278. // message: "课程内暂无可以学习的科目",
  279. // });
  280. // }
  281. // });
  282. // }
  283. });
  284. },
  285. go(path, query) {
  286. this.$router.push({
  287. path,
  288. query,
  289. });
  290. },
  291. /**
  292. * @param {Object} goodsId 商品id
  293. * 查询商品重修状态
  294. */
  295. courseGoodsRebuildStatus(goodsId, gradeId) {
  296. return new Promise((resolve) => {
  297. this.$request
  298. .courseGoodsRebuildStatus({
  299. goodsId: goodsId,
  300. gradeId: gradeId,
  301. })
  302. .then((res) => {
  303. resolve(res.data);
  304. });
  305. });
  306. },
  307. },
  308. };
  309. </script>
  310. <!-- Add "scoped" attribute to limit CSS to this component only -->
  311. <style scoped lang="scss">
  312. .play-record {
  313. &__header {
  314. height: 56px;
  315. line-height: 56px;
  316. .clear-btn {
  317. margin-top: 12px;
  318. float: right;
  319. display: block;
  320. width: 122px;
  321. height: 32px;
  322. background: #eeeeee;
  323. border-radius: 16px;
  324. text-align: center;
  325. line-height: 32px;
  326. color: #3f8dfd;
  327. }
  328. }
  329. &__body {
  330. .date-item {
  331. margin-top: 24px;
  332. border-top: 1px solid #eee;
  333. &:nth-of-type(1) {
  334. margin: 0;
  335. }
  336. &__header {
  337. padding-left: 15px;
  338. height: 40px;
  339. line-height: 40px;
  340. }
  341. &__body {
  342. .list {
  343. .course-item {
  344. margin-top: 20px;
  345. background: #fafbfc;
  346. border-radius: 8px;
  347. overflow: hidden;
  348. &:nth-of-type(1) {
  349. margin: 0;
  350. }
  351. &__header {
  352. height: 40px;
  353. border-bottom: 1px solid #eee;
  354. padding: 0 18px;
  355. line-height: 40px;
  356. font-size: 16px;
  357. font-family: Microsoft YaHei;
  358. font-weight: bold;
  359. color: #333333;
  360. }
  361. &__body {
  362. .img {
  363. cursor: pointer;
  364. float: left;
  365. width: 160px;
  366. height: 90px;
  367. img {
  368. max-width: 100%;
  369. max-height: 100%;
  370. }
  371. }
  372. .text {
  373. float: left;
  374. margin-left: 12px;
  375. .title {
  376. margin-top: 10px;
  377. font-size: 16px;
  378. font-family: Microsoft YaHei;
  379. font-weight: 400;
  380. color: #333333;
  381. .note {
  382. display: inline-block;
  383. vertical-align: middle;
  384. border: 1px solid #333333;
  385. border-radius: 4px;
  386. font-size: 12px;
  387. font-family: Microsoft YaHei;
  388. font-weight: 400;
  389. color: #333333;
  390. padding: 2px 5px;
  391. margin-left: 12px;
  392. }
  393. }
  394. .progress {
  395. margin-top: 30px;
  396. font-size: 14px;
  397. font-family: Microsoft YaHei;
  398. font-weight: 400;
  399. color: #333333;
  400. &-line {
  401. width: 200px;
  402. display: inline-block;
  403. }
  404. }
  405. }
  406. .btns-wrap {
  407. display: table;
  408. float: right;
  409. height: 90px;
  410. width: 130px;
  411. .btns {
  412. display: table-cell;
  413. vertical-align: middle;
  414. text-align: center;
  415. .btn {
  416. cursor: pointer;
  417. margin: 2px 0;
  418. width: 122px;
  419. height: 32px;
  420. background: #3f8dfd;
  421. border-radius: 16px;
  422. display: inline-block;
  423. text-align: center;
  424. line-height: 32px;
  425. color: #fff;
  426. &--warm {
  427. background: #ff3b30;
  428. }
  429. }
  430. }
  431. }
  432. }
  433. }
  434. }
  435. }
  436. }
  437. }
  438. &__footer {
  439. .pagination {
  440. padding: 30px 0;
  441. text-align: center;
  442. }
  443. }
  444. .rebuild {
  445. /deep/ .el-dialog__header {
  446. display: none;
  447. }
  448. /deep/ .el-dialog__body {
  449. padding: 0;
  450. overflow: unset;
  451. }
  452. &__close {
  453. cursor: pointer;
  454. position: absolute;
  455. right: 0;
  456. top: -28px;
  457. width: 24px;
  458. height: 24px;
  459. line-height: 24px;
  460. text-align: center;
  461. color: #eee;
  462. border: 1px solid #eee;
  463. border-radius: 50%;
  464. }
  465. &__header {
  466. height: 40px;
  467. border-bottom: 1px solid #eee;
  468. line-height: 40px;
  469. font-size: 16px;
  470. font-family: Microsoft YaHei;
  471. font-weight: bold;
  472. color: #333333;
  473. padding-left: 24px;
  474. }
  475. &__body {
  476. height: 400px;
  477. padding: 0 24px;
  478. .content {
  479. height: 100%;
  480. overflow-y: auto;
  481. &__header {
  482. padding: 16px 0;
  483. border-bottom: 1px solid #eee;
  484. .title {
  485. font-size: 16px;
  486. font-family: Microsoft YaHei;
  487. font-weight: bold;
  488. color: #ff3b30;
  489. line-height: 24px;
  490. }
  491. .desc {
  492. margin-top: 10px;
  493. font-size: 16px;
  494. font-family: Microsoft YaHei;
  495. font-weight: 400;
  496. color: #ff3b30;
  497. line-height: 24px;
  498. }
  499. }
  500. &__body {
  501. .list {
  502. &__item {
  503. padding: 16px 0;
  504. border-bottom: 1px solid #eee;
  505. .title {
  506. font-size: 14px;
  507. font-family: Microsoft YaHei;
  508. font-weight: 400;
  509. color: #333333;
  510. .note {
  511. display: inline-block;
  512. text-align: center;
  513. line-height: 18px;
  514. width: 32px;
  515. height: 20px;
  516. border: 1px solid #3f8dfd;
  517. border-radius: 4px;
  518. color: #3f8dfd;
  519. font-size: 12px;
  520. &--yellow {
  521. border: 1px solid #ff9500;
  522. color: #ff9500;
  523. }
  524. }
  525. }
  526. .desc {
  527. margin-top: 10px;
  528. font-size: 14px;
  529. font-family: Microsoft YaHei;
  530. font-weight: 400;
  531. color: #333333;
  532. .note {
  533. color: #ff3b30;
  534. line-height: 20px;
  535. }
  536. .img {
  537. width: 100px;
  538. height: 100px;
  539. display: inline-block;
  540. text-align: center;
  541. img {
  542. max-width: 100%;
  543. max-height: 100%;
  544. }
  545. }
  546. }
  547. }
  548. }
  549. }
  550. }
  551. }
  552. &__footer {
  553. height: 90px;
  554. border-top: 1px solid #eee;
  555. text-align: center;
  556. .confirm {
  557. width: 200px;
  558. height: 40px;
  559. padding: 0;
  560. border-radius: 20px;
  561. text-align: center;
  562. line-height: 40px;
  563. color: #fff;
  564. margin: 24px auto;
  565. }
  566. }
  567. }
  568. }
  569. </style>