courseDetail.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  1. <template>
  2. <div class="pb_content">
  3. <div class="pb_content_body" style="height: 100%">
  4. <div class="body_student">
  5. <div class="student_head">
  6. <div
  7. class="return"
  8. @click.stop="
  9. goTo(
  10. '/index?userid=' +
  11. userid +
  12. '&oid=' +
  13. oid +
  14. '&cid=' +
  15. classId +
  16. '&tType=' +
  17. tType
  18. )
  19. "
  20. >
  21. 返回
  22. <!-- <img src="../assets/icon/return.png" alt="" /> -->
  23. </div>
  24. <div class="box_course">
  25. <div class="wheel">
  26. <img
  27. :src="
  28. this.courseDetail.cover != null &&
  29. this.courseDetail.cover != ''
  30. ? JSON.parse(this.courseDetail.cover).length > 0
  31. ? JSON.parse(this.courseDetail.cover)[0].url
  32. : mr
  33. : mr
  34. "
  35. alt
  36. />
  37. </div>
  38. <div class="right_box">
  39. <div class="right_box_title">{{ courseDetail.title }}</div>
  40. <div class="people">
  41. <div class="man">
  42. <img src="../assets/people.png" alt />
  43. </div>
  44. <div class="person">
  45. {{ courseDetail.vcount != null ? courseDetail.vcount : 0 }}人
  46. </div>
  47. </div>
  48. <div class="cType">
  49. <div
  50. class="all_choose"
  51. v-for="(item, index) in courseType"
  52. :key="index"
  53. >
  54. <span
  55. style="
  56. {
  57. 'margin-left':index>0?'10px': '';
  58. }
  59. "
  60. >{{ item + ":" }}</span
  61. >
  62. <span
  63. class="type_children"
  64. v-for="(item2, index2) in courseTypeJson[item]"
  65. :key="index2"
  66. >{{ item2 }}</span
  67. >
  68. </div>
  69. </div>
  70. <div class="now_study" @click="dialogVisible = true">
  71. 立即学习
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. <div class="student_body">
  77. <div
  78. style="
  79. width: 20%;
  80. margin-right: 10px;
  81. background: #fff;
  82. padding-right: 10px;
  83. "
  84. >
  85. <div
  86. class="blue_box_one"
  87. v-for="(item, index) in chapInfo"
  88. :key="index"
  89. @click="addUserRate(index)"
  90. >
  91. <div>第{{ index + 1 }}阶段</div>
  92. <div :title="item.dyName">{{ item.dyName }}</div>
  93. </div>
  94. </div>
  95. <div style="width: 80%; background: #fff">
  96. <div class="choose_who">
  97. <div
  98. class="who_choose"
  99. :class="choose == 0 ? 'choose' : ''"
  100. @click="choose = 0"
  101. >
  102. 项目详情
  103. </div>
  104. <!-- <div
  105. class="who_choose"
  106. :class="choose == 1 ? 'choose' : ''"
  107. @click="choose = 1"
  108. >
  109. 项目学员
  110. </div> -->
  111. </div>
  112. <div class="right" v-if="choose == 0">
  113. <div class="nav">
  114. {{
  115. courseDetail.brief != null
  116. ? courseDetail.brief
  117. : "暂无课程简介"
  118. }}
  119. </div>
  120. </div>
  121. <!-- <div class="right_one" v-else>
  122. <div class="student" v-if="aStudentName.length > 0">
  123. <div v-for="(item, index) in aStudentName" :key="index">
  124. {{ item.name }}
  125. </div>
  126. </div>
  127. <div class="student" v-else>暂无课程学员</div>
  128. </div> -->
  129. </div>
  130. </div>
  131. <!-- <div
  132. style="
  133. text-align: center;
  134. padding: 30px 0 20px 0;
  135. box-sizing: border-box;
  136. "
  137. >
  138. 此处滚动加载..
  139. </div>-->
  140. <el-dialog
  141. title="阶段选择"
  142. :visible.sync="dialogVisible"
  143. :append-to-body="true"
  144. width="700px"
  145. :before-close="handleClose"
  146. class="dialog_change"
  147. >
  148. <div style="font-size: 20px">请选择阶段</div>
  149. <div
  150. style="
  151. padding: 20px 30px;
  152. display: flex;
  153. flex-direction: row;
  154. flex-wrap: wrap;
  155. "
  156. >
  157. <div
  158. class="blue_box"
  159. v-for="(item, index) in chapInfo"
  160. :key="index"
  161. @click="addUserRate(index)"
  162. >
  163. <div>第{{ index + 1 }}阶段</div>
  164. <div>{{ item.dyName }}</div>
  165. </div>
  166. </div>
  167. </el-dialog>
  168. </div>
  169. </div>
  170. </div>
  171. </template>
  172. <script>
  173. export default {
  174. data() {
  175. return {
  176. choose: 0,
  177. dialogVisible: false,
  178. id: this.$route.query.courseId,
  179. userid: this.$route.query.userid,
  180. oid: this.$route.query.oid,
  181. classId: this.$route.query.cid,
  182. tType: this.$route.query.tType,
  183. courseDetail: {},
  184. aStudentName: [],
  185. chapInfo: [],
  186. courseType: [],
  187. courseTypeJson: {},
  188. userinfo: [],
  189. mr: require("../assets/icon/wheel.png"),
  190. };
  191. },
  192. methods: {
  193. handleClose(done) {
  194. done();
  195. },
  196. goTo(path) {
  197. this.$router.push(path);
  198. },
  199. addUserRate(i) {
  200. // var suid = this.userid;
  201. // if (
  202. // JSON.parse(this.courseDetail.course_student).indexOf(suid) == -1 &&
  203. // JSON.parse(this.courseDetail.userid) != suid
  204. // ) {
  205. // this.$message.error("你没有该权限");
  206. // return;
  207. // }
  208. // var a =
  209. // this.courseDetail.course_student != ""
  210. // ? JSON.parse(this.courseDetail.course_student)
  211. // : "";
  212. // if (this.courseDetail.userid != suid) {
  213. // if (this.userinfo.type == 2) {
  214. // if (a != "") {
  215. // if (
  216. // JSON.parse(this.courseDetail.course_student).indexOf(suid) == -1
  217. // ) {
  218. // this.$message.error("你没有该权限");
  219. // return;
  220. // }
  221. // } else {
  222. // this.$message.error("暂无项目学员,请联系老师添加项目学员!");
  223. // return;
  224. // }
  225. // }
  226. // }
  227. let params = {
  228. uid: this.userid,
  229. cid: this.id,
  230. };
  231. this.ajax
  232. .get(this.$store.state.api + "addUserR", params)
  233. .then((res) => {
  234. console.log(res.data);
  235. this.updateVc();
  236. this.goTo(
  237. "/study?type=" +
  238. i +
  239. "&courseId=" +
  240. this.id +
  241. "&userid=" +
  242. this.userid +
  243. "&oid=" +
  244. this.oid +
  245. "&cid=" +
  246. this.classId +
  247. "&tType=" +
  248. this.tType
  249. );
  250. })
  251. .catch((err) => {
  252. console.error(err);
  253. });
  254. },
  255. updateVc() {
  256. let params = {
  257. cid: this.id,
  258. };
  259. this.ajax
  260. .get(this.$store.state.api + "updateVc", params)
  261. .then((res) => {
  262. console.log(res.data);
  263. })
  264. .catch((err) => {
  265. console.error(err);
  266. });
  267. },
  268. getCourseDetail() {
  269. const loading = this.$loading.service({
  270. background: "rgba(255, 255, 255, 0.7)",
  271. target: document.querySelector(".student_table"),
  272. });
  273. let params = {
  274. courseId: this.id,
  275. };
  276. this.ajax
  277. .get(this.$store.state.api + "selectCourseDetail", params)
  278. .then((res) => {
  279. loading.close();
  280. // this.total = res.data[0].length > 0 ? res.data[0][0].num : 0;
  281. this.courseDetail = res.data[0][0];
  282. var a = res.data[0];
  283. var b = res.data[1];
  284. for (var i = 0; i < b.length; i++) {
  285. // if (!this.id) {
  286. // this.courseType[b[i].id] = [];
  287. // }
  288. for (var j = 0; j < a.length; j++) {
  289. if (b[i].id == a[j].pid) {
  290. if (!this.courseTypeJson[b[i].name]) {
  291. this.courseType.push(b[i].name);
  292. this.courseTypeJson[b[i].name] = [];
  293. }
  294. this.courseTypeJson[b[i].name].push(a[j].name);
  295. }
  296. }
  297. }
  298. console.log(this.courseTypeJson.length);
  299. this.aStudentName = res.data[2];
  300. this.chapInfo = JSON.parse(this.courseDetail.chapters);
  301. })
  302. .catch((err) => {
  303. loading.close();
  304. console.error(err);
  305. });
  306. },
  307. getUser() {
  308. let params = { uid: this.userid };
  309. this.ajax
  310. .get(this.$store.state.api + "getUser", params)
  311. .then((res) => {
  312. this.userinfo = res.data[0][0];
  313. })
  314. .catch((err) => {
  315. console.error(err);
  316. });
  317. },
  318. // getSName() {
  319. // let params = {
  320. // uid: JSON.stringify(this.courseDetail.course_student),
  321. // };
  322. // this.ajax
  323. // .get(this.$store.state.api + "selectSName", params)
  324. // .then((res) => {
  325. // this.aStudentName = res.data[0];
  326. // })
  327. // .catch((err) => {
  328. // console.error(err);
  329. // });
  330. // },
  331. },
  332. created() {
  333. this.getCourseDetail();
  334. this.getUser();
  335. document.scrollingElement.scrollTop = 0;
  336. // this.getSName();
  337. },
  338. };
  339. </script>
  340. <style scoped>
  341. .body_student {
  342. margin: 10px auto;
  343. width: 98%;
  344. height: 100%;
  345. }
  346. .student_head {
  347. width: 100%;
  348. background: #fff;
  349. height: 30%;
  350. position: relative;
  351. }
  352. .wheel {
  353. width: 210px;
  354. max-height: 146px;
  355. }
  356. .man {
  357. width: 16px;
  358. height: 16px;
  359. }
  360. .wheel > img,
  361. .man > img {
  362. width: 100%;
  363. height: 100%;
  364. }
  365. .box_course {
  366. display: flex;
  367. padding: 25px 0 20px 60px;
  368. }
  369. .right_box {
  370. display: flex;
  371. flex-direction: column;
  372. margin-left: 30px;
  373. align-items: flex-start;
  374. }
  375. .right_box_title {
  376. font-size: 23px;
  377. }
  378. .people {
  379. display: flex;
  380. margin-top: 20px;
  381. }
  382. .person {
  383. margin-left: 10px;
  384. line-height: 18px;
  385. }
  386. .now_study {
  387. width: 150px;
  388. height: 35px;
  389. color: #fff;
  390. background: #4a9eed;
  391. text-align: center;
  392. line-height: 35px;
  393. border-radius: 5px;
  394. font-size: 13px;
  395. cursor: pointer;
  396. margin-top: 30px;
  397. }
  398. .choose_who {
  399. display: flex;
  400. margin: 15px 0 0 25px;
  401. }
  402. .who_choose {
  403. height: 28px;
  404. cursor: pointer;
  405. }
  406. .choose_who > div:nth-child(2) {
  407. margin-left: 35px;
  408. }
  409. .choose {
  410. border-bottom: 5px solid #4a9eed;
  411. color: #4a9eed;
  412. }
  413. .student_body {
  414. display: flex;
  415. }
  416. .student_body,
  417. .right {
  418. width: 100%;
  419. margin: 0 auto;
  420. margin-top: 10px;
  421. padding: 0 0 20px;
  422. min-height: 688px;
  423. }
  424. .nav {
  425. margin: auto 25px;
  426. width: 80%;
  427. padding-top: 5px;
  428. text-indent: 25px;
  429. }
  430. .pic {
  431. width: 100%;
  432. display: flex;
  433. flex-direction: row;
  434. flex-wrap: wrap;
  435. height: 100%;
  436. justify-content: space-evenly;
  437. }
  438. .Img {
  439. /*width: 30%; */
  440. width: 300px;
  441. margin: 20px 50px;
  442. margin: 20px 10px;
  443. border: 1px solid #dbdbdb;
  444. border-radius: 5px;
  445. overflow: hidden;
  446. }
  447. .Img > img {
  448. width: 100%;
  449. height: 100%;
  450. }
  451. .student_body_one,
  452. .right_one {
  453. width: 100%;
  454. margin: 0 auto;
  455. background: #fff;
  456. margin-top: 10px;
  457. min-height: 688px;
  458. }
  459. .student {
  460. width: 85%;
  461. display: flex;
  462. flex-direction: row;
  463. flex-wrap: wrap;
  464. justify-content: flex-start;
  465. margin: auto 10px;
  466. }
  467. .student > div {
  468. width: 12%;
  469. height: 35px;
  470. background: #e3759a;
  471. text-align: center;
  472. border: 1px solid #e3759a;
  473. border-radius: 5px;
  474. color: #fff;
  475. line-height: 35px;
  476. margin: 10px;
  477. }
  478. .dialog_change >>> .el-dialog {
  479. border-radius: 5px;
  480. }
  481. .dialog_change >>> .el-dialog__header {
  482. background: #303030;
  483. height: 36px;
  484. line-height: 36px;
  485. padding-left: 10px;
  486. padding: 0px 10px 0px;
  487. }
  488. .dialog_change >>> .el-dialog__headerbtn {
  489. top: 10px !important;
  490. right: 10px !important;
  491. }
  492. .dialog_change >>> .el-dialog__title {
  493. color: #fff;
  494. font-size: 14px;
  495. line-height: 5px;
  496. }
  497. .dialog_change >>> .el-dialog__body {
  498. background: #f5f5f5;
  499. }
  500. .blue_box {
  501. align-items: center;
  502. display: flex;
  503. flex-direction: column;
  504. justify-content: center;
  505. }
  506. .blue_box,
  507. .blue_box_one {
  508. width: 30%;
  509. height: 100px;
  510. text-align: center;
  511. color: #fff;
  512. background-image: linear-gradient(90deg, #477cd7, #65b9fc);
  513. border-radius: 7px;
  514. margin: 10px;
  515. cursor: pointer;
  516. }
  517. .blue_box_one {
  518. width: 95% !important;
  519. height: 45px !important;
  520. display: flex;
  521. flex-direction: row;
  522. justify-content: flex-start;
  523. align-items: center;
  524. background-image: linear-gradient(90deg, #477cd7, #65b9fc);
  525. }
  526. .blue_box > div:nth-child(1),
  527. .blue_box_one > div:nth-child(1) {
  528. /* line-height: 65px; */
  529. }
  530. .blue_box_one > div:nth-child(1) {
  531. margin: 0 5px;
  532. width: 40%;
  533. line-height: 30px !important;
  534. border-radius: 4px;
  535. background: #4e7ac6;
  536. }
  537. .blue_box > div:nth-child(2) {
  538. /* line-height: 0px; */
  539. margin-top: 10px;
  540. }
  541. .blue_box_one > div:nth-child(1) {
  542. line-height: 65px;
  543. margin: 0 5px 0 10px;
  544. width: 30%;
  545. min-width: 70px;
  546. }
  547. .blue_box_one > div:nth-child(2) {
  548. white-space: nowrap;
  549. text-overflow: ellipsis;
  550. overflow: hidden;
  551. word-break: break-all;
  552. width: 70%;
  553. text-align: left;
  554. max-width: calc(100% - 85px);
  555. margin-right: 10px;
  556. }
  557. .return {
  558. background: rgb(238, 238, 238);
  559. width: 58px;
  560. height: 30px;
  561. color: rgb(22, 22, 22);
  562. text-align: center;
  563. line-height: 32px;
  564. margin-right: 20px;
  565. cursor: pointer;
  566. border-radius: 5px;
  567. position: absolute;
  568. right: 0;
  569. top: 24px;
  570. }
  571. .return > img {
  572. width: 100%;
  573. height: 100%;
  574. }
  575. .cType {
  576. display: flex;
  577. flex-direction: row;
  578. justify-content: center;
  579. align-items: center;
  580. margin-top: 20px;
  581. }
  582. .cType > div > span {
  583. font-size: 18px;
  584. }
  585. .type_children + .type_children {
  586. margin-left: 10px;
  587. }
  588. .all_choose {
  589. margin-right: 10px;
  590. max-width: 180px;
  591. white-space: nowrap;
  592. overflow: hidden;
  593. text-overflow: ellipsis;
  594. }
  595. </style>