index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678
  1. <template>
  2. <div class="pb_content">
  3. <div class="pb_content_body">
  4. <div class="student_head">
  5. <!-- <img src="../assets/banner.png" alt="" /> -->
  6. <el-carousel trigger="click" style="width: 100%; height: 300px">
  7. <el-carousel-item v-for="item in bannerList" :key="item.id">
  8. <!-- <h3 class="small">{{ item }}</h3> -->
  9. <img
  10. class="imgS"
  11. :src="item.poster"
  12. alt=""
  13. @click.stop="
  14. goTo(
  15. '/courseDetail?courseId=' +
  16. item.url +
  17. '&userid=' +
  18. userid +
  19. '&oid=' +
  20. oid +
  21. '&tType=' +
  22. tType
  23. )
  24. "
  25. />
  26. </el-carousel-item>
  27. </el-carousel>
  28. </div>
  29. <div class="reBox">
  30. <div class="reTop">
  31. <div>课程</div>
  32. <div>
  33. <div class="search" @click="selectAll">
  34. <img src="../assets/icon/search.png" alt="" />
  35. </div>
  36. <input
  37. class="sInput"
  38. type="text"
  39. placeholder="请输入关键字"
  40. v-model="sCourse"
  41. />
  42. </div>
  43. </div>
  44. <div class="choose">
  45. <div
  46. class="all_choose"
  47. v-for="(item, index) in CourseType[0]"
  48. :key="index"
  49. >
  50. <span>{{ item.name }}:</span>
  51. <div
  52. class="cName"
  53. @click="getCourse(item.name, '', item.id, 1)"
  54. :class="typeE.indexOf(item.id) != -1 ? 'isCType' : ''"
  55. >
  56. 全部
  57. </div>
  58. <div
  59. v-for="item1 in CourseTypeJson[item.id]"
  60. :key="item1.id"
  61. :label="item1.id"
  62. @click="getCourse(item.name, item.id, item1.id, 2)"
  63. >
  64. <div
  65. class="cName"
  66. :class="
  67. typea == item1.id || typeb == item1.id || typed == item1.id
  68. ? 'isCType'
  69. : ''
  70. "
  71. >
  72. {{ item1.name }}
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. </div>
  78. <div class="body_student">
  79. <!-- <div class="top">
  80. <div :class="{ active: 0 == zoneListId }" @click="selectAll()">
  81. 所有课程
  82. </div>
  83. <div
  84. :class="{ active: item.id == zoneListId }"
  85. v-for="(item, index) in zoneList"
  86. :key="index"
  87. @click="checkZone(item.id)"
  88. >
  89. {{ item.name }}
  90. </div>
  91. </div> -->
  92. <div>
  93. <div class="main_box">
  94. <div
  95. class="box_course"
  96. v-for="(item, index) in zoneClass"
  97. :key="index"
  98. >
  99. <div class="wheel">
  100. <img
  101. :src="
  102. item.cover
  103. ? JSON.parse(item.cover)[0].url
  104. : require('../assets/wheel.png')
  105. "
  106. alt=""
  107. />
  108. </div>
  109. <div class="middle_white">
  110. <div class="textOverflow">{{ item.title }}</div>
  111. <div class="nameAndLength">
  112. <el-tooltip
  113. class="typeN"
  114. effect="light"
  115. :content="item.typename"
  116. placement="top"
  117. >
  118. <div>{{ item.typename }}</div>
  119. </el-tooltip>
  120. <div style="padding-right: 10px;min-width: 55px;">
  121. {{ JSON.parse(item.chapters).length }}阶段
  122. </div>
  123. </div>
  124. <div class="people">
  125. <div class="man">
  126. <img src="../assets/people.png" alt="" />
  127. </div>
  128. <div>
  129. {{
  130. item.pNum != null && item.pNum != "" ? item.pNum : "0"
  131. }}人学习
  132. </div>
  133. </div>
  134. </div>
  135. <div
  136. class="now_study"
  137. @click="
  138. goTo(
  139. '/courseDetail?courseId=' +
  140. item.courseId +
  141. '&userid=' +
  142. userid +
  143. '&oid=' +
  144. oid +
  145. '&cid=' +
  146. classId +
  147. '&tType=' +
  148. tType
  149. )
  150. "
  151. >
  152. 立即学习
  153. </div>
  154. </div>
  155. <div class="course_empty" v-if="zoneClass.length == 0">
  156. 暂无课程
  157. </div>
  158. </div>
  159. </div>
  160. <div
  161. class="student_page"
  162. style="margin: 15px 0 0"
  163. v-if="zoneClass.length > 0"
  164. >
  165. <el-pagination
  166. background
  167. layout="prev, pager, next"
  168. :page-size="10"
  169. :total="total"
  170. v-if="page && zoneListId != 0"
  171. @current-change="handleCurrentChange"
  172. >
  173. </el-pagination>
  174. <el-pagination
  175. background
  176. layout="prev, pager, next"
  177. :page-size="10"
  178. :total="total"
  179. v-if="page && zoneListId == 0"
  180. @current-change="handleCurrentChange1"
  181. >
  182. </el-pagination>
  183. </div>
  184. </div>
  185. </div>
  186. </div>
  187. </template>
  188. <script>
  189. export default {
  190. data() {
  191. return {
  192. zoneList: [],
  193. zoneClass: [],
  194. page: 1,
  195. total: 0,
  196. isListAjax: false,
  197. zoneListId: "",
  198. bannerList: [],
  199. userid: this.$route.query.userid,
  200. oid: this.$route.query.oid,
  201. classId: this.$route.query.cid,
  202. tType: this.$route.query.tType,
  203. CourseType: [],
  204. CourseTypeJson: {},
  205. courseTypeId: {},
  206. sCourse: "",
  207. isCType: "",
  208. typea: "",
  209. typeb: "",
  210. typed: "",
  211. typeE: [],
  212. };
  213. },
  214. methods: {
  215. goTo(path) {
  216. this.$router.push(path);
  217. },
  218. // getZone() {
  219. // this.ajax
  220. // .get(this.$store.state.api + "getZone", "")
  221. // .then((res) => {
  222. // this.zoneList = res.data[0];
  223. // // this.zoneListId = this.zoneList[0].id;
  224. // // this.getZoneClass(this.zoneList[0].id);
  225. // this.selectAll();
  226. // })
  227. // .catch((err) => {
  228. // console.error(err);
  229. // });
  230. // },
  231. //获取专区下的课程
  232. getZoneClass(zid) {
  233. this.isListAjax = true;
  234. const loading = this.openLoading(document.querySelector(".main_box"));
  235. let params = {
  236. bid: zid,
  237. oid: this.oid,
  238. page: this.page,
  239. };
  240. this.ajax
  241. .get(this.$store.state.api + "getZoneClassStudent", params)
  242. .then((res) => {
  243. loading.close();
  244. this.isListAjax = false;
  245. this.zoneClass = res.data[0];
  246. this.total = res.data[0].length ? res.data[0][0].num : 0;
  247. })
  248. .catch((err) => {
  249. console.error(err);
  250. });
  251. },
  252. getCourse(typeName, ftypeId, typeid, type) {
  253. if (typeName == "年级") {
  254. if (type == 1) {
  255. if (this.typeE.indexOf(typeid) != -1) {
  256. this.typeE.splice(this.typeE.indexOf(typeid), 1);
  257. } else {
  258. this.typeE.push(typeid);
  259. if(this.typea != ""){
  260. this.typea = "";
  261. }
  262. }
  263. } else {
  264. if (this.typea == typeid) {
  265. this.typea = "";
  266. } else {
  267. this.typea = typeid;
  268. if (this.typeE.indexOf(ftypeId) != -1) {
  269. this.typeE.splice(this.typeE.indexOf(ftypeId), 1);
  270. }
  271. }
  272. }
  273. } else if (typeName == "专栏") {
  274. if (type == 1) {
  275. if (this.typeE.indexOf(typeid) != -1) {
  276. this.typeE.splice(this.typeE.indexOf(typeid), 1);
  277. } else {
  278. this.typeE.push(typeid);
  279. if(this.typeb != ""){
  280. this.typeb = "";
  281. }
  282. }
  283. } else {
  284. if (this.typeb == typeid) {
  285. this.typeb = "";
  286. } else {
  287. this.typeb = typeid;
  288. if (this.typeE.indexOf(ftypeId) != -1) {
  289. this.typeE.splice(this.typeE.indexOf(ftypeId), 1);
  290. }
  291. }
  292. }
  293. } else if (typeName == "学科") {
  294. if (type == 1) {
  295. if (this.typeE.indexOf(typeid) != -1) {
  296. this.typeE.splice(this.typeE.indexOf(typeid), 1);
  297. } else {
  298. this.typeE.push(typeid);
  299. if(this.typed != ""){
  300. this.typed = "";
  301. }
  302. }
  303. } else {
  304. if (this.typed == typeid) {
  305. this.typed = "";
  306. } else {
  307. this.typed = typeid;
  308. if (this.typeE.indexOf(ftypeId) != -1) {
  309. this.typeE.splice(this.typeE.indexOf(ftypeId), 1);
  310. }
  311. }
  312. }
  313. }
  314. this.selectAll();
  315. },
  316. selectAll() {
  317. this.zoneListId = 0;
  318. this.isListAjax = true;
  319. const loading = this.openLoading(document.querySelector(".main_box"));
  320. let params = {
  321. uid: this.userid,
  322. oid: this.oid,
  323. typea: this.typea != undefined ? this.typea : "",
  324. typeb: this.typeb != undefined ? this.typeb : "",
  325. typec: "",
  326. typed: this.typed != undefined ? this.typed : "",
  327. typeE: this.typeE.join(","),
  328. cu: "",
  329. cn: this.sCourse,
  330. classid: this.classId,
  331. page: this.page,
  332. };
  333. this.ajax
  334. .get(this.$store.state.api + "selectTypeCourse", params)
  335. .then((res) => {
  336. loading.close();
  337. this.isListAjax = false;
  338. this.zoneClass = res.data[0];
  339. this.total = res.data[0].length ? res.data[0][0].num : 0;
  340. })
  341. .catch((err) => {
  342. console.error(err);
  343. });
  344. },
  345. checkZone(id) {
  346. this.page = 1;
  347. this.zoneListId = id;
  348. this.getZoneClass(id);
  349. },
  350. handleCurrentChange(val) {
  351. this.page = val;
  352. this.getZoneClass(this.zoneListId);
  353. },
  354. handleCurrentChange1(val) {
  355. this.page = val;
  356. this.selectAll();
  357. },
  358. //获取banner
  359. getBanner() {
  360. this.ajax
  361. .get(this.$store.state.api + "getBanner", "")
  362. .then((res) => {
  363. this.bannerList = res.data[0];
  364. console.log(this.bannerList);
  365. })
  366. .catch((err) => {
  367. console.error(err);
  368. });
  369. },
  370. selectType() {
  371. this.ajax
  372. .get(this.$store.state.api + "selectType")
  373. .then((res) => {
  374. this.CourseType = res.data;
  375. for (var i = 0; i < res.data[0].length; i++) {
  376. if (!this.cid) {
  377. this.courseTypeId[res.data[0][i].id] = "";
  378. }
  379. for (var j = 0; j < res.data[1].length; j++) {
  380. if (res.data[0][i].id == res.data[1][j].pid) {
  381. if (!this.CourseTypeJson[res.data[0][i].id]) {
  382. this.CourseTypeJson[res.data[0][i].id] = [];
  383. }
  384. this.CourseTypeJson[res.data[0][i].id].push(res.data[1][j]);
  385. }
  386. }
  387. }
  388. })
  389. .catch((err) => {
  390. console.error(err);
  391. });
  392. },
  393. },
  394. created() {
  395. this.selectType();
  396. this.selectAll();
  397. this.getBanner();
  398. document.scrollingElement.scrollTop = 0;
  399. },
  400. };
  401. </script>
  402. <style scoped>
  403. .student_head .imgS {
  404. width: 100%;
  405. height: 100%;
  406. cursor: pointer;
  407. }
  408. .top {
  409. padding: 20px 30px 20px 1%;
  410. box-sizing: border-box;
  411. display: flex;
  412. align-items: center;
  413. }
  414. .top div {
  415. cursor: pointer;
  416. box-sizing: border-box;
  417. height: 35px;
  418. line-height: 35px;
  419. margin: 0 10px 0 0;
  420. padding-bottom: 5px;
  421. width: 80px;
  422. text-align: center;
  423. }
  424. .top .active {
  425. border-bottom: 3px solid #0e71e6;
  426. }
  427. .isactive {
  428. border-bottom: 3px solid #0e71e6;
  429. }
  430. .box_fk {
  431. width: 8px;
  432. height: 21px;
  433. background: #0e71e6;
  434. margin-right: 5px;
  435. }
  436. .wheel {
  437. width: 100%;
  438. height: 140px;
  439. }
  440. .man {
  441. width: 16px;
  442. height: 16px;
  443. }
  444. .wheel > img,
  445. .man > img {
  446. width: 100%;
  447. height: 100%;
  448. object-fit: cover;
  449. }
  450. .box_course {
  451. display: flex;
  452. flex-direction: column;
  453. flex-wrap: nowrap;
  454. margin: 0px 1% 20px;
  455. width: 16%;
  456. /*border: 1px solid #cecece; */
  457. border-radius: 10px;
  458. overflow: hidden;
  459. box-shadow: 0px 1px 3px 0px rgb(0 0 0 / 20%), 0px 1px 1px 0px rgb(0 0 0 / 14%),
  460. 0px 2px 1px -1px rgb(0 0 0 / 12%);
  461. justify-content: space-between;
  462. }
  463. .middle_white {
  464. font-size: 14px;
  465. margin: 5px 0 5px 10px;
  466. }
  467. .people {
  468. display: flex;
  469. align-items: center;
  470. }
  471. .people > div:nth-child(2) {
  472. margin-left: 10px;
  473. }
  474. .now_study {
  475. width: 100%;
  476. height: 40px;
  477. color: #fff;
  478. background: #4a9eed;
  479. text-align: center;
  480. line-height: 40px;
  481. font-size: 13px;
  482. cursor: pointer;
  483. }
  484. .now_study:hover {
  485. background: #205cc6;
  486. }
  487. .main_box {
  488. width: 100%;
  489. display: flex;
  490. flex-direction: row;
  491. flex-wrap: wrap;
  492. justify-content: flex-start;
  493. margin: 0 auto;
  494. }
  495. .right_bottom_flex {
  496. width: 219px;
  497. height: 144px;
  498. margin: auto 0;
  499. }
  500. .right_bottom_flex > img {
  501. width: 100%;
  502. height: 100%;
  503. }
  504. .body_student {
  505. margin: 10px auto;
  506. width: 92%;
  507. height: 100%;
  508. }
  509. .student_head {
  510. width: 100%;
  511. height: 30%;
  512. }
  513. .textOverflow {
  514. padding: 0 5px 0 0px;
  515. width: 95%;
  516. overflow: hidden;
  517. white-space: nowrap;
  518. text-overflow: ellipsis;
  519. font-weight: bold;
  520. font-size: 16px;
  521. }
  522. .student_page {
  523. margin-top: 10px;
  524. }
  525. .course_empty {
  526. width: 100%;
  527. height: 200px;
  528. display: flex;
  529. align-items: center;
  530. justify-content: center;
  531. }
  532. .choose > div:nth-child(3) > span {
  533. letter-spacing: 0 !important;
  534. }
  535. .choose {
  536. display: flex;
  537. flex-direction: column;
  538. flex-wrap: nowrap;
  539. height: 100%;
  540. justify-content: space-evenly;
  541. align-items: flex-start;
  542. padding: 10px 0;
  543. }
  544. .all_choose {
  545. display: flex;
  546. flex-direction: row;
  547. align-items: baseline;
  548. margin: 10px 0;
  549. width: 100%;
  550. }
  551. .all_choose > span {
  552. min-width: 80px;
  553. display: block;
  554. letter-spacing: 14px;
  555. }
  556. .all_choose > span:nth-child(1) {
  557. font-weight: bold;
  558. }
  559. .all_choose >>> .el-checkbox-group {
  560. display: flex;
  561. flex-direction: row;
  562. width: 820px;
  563. flex-wrap: wrap;
  564. align-content: center;
  565. justify-content: flex-start;
  566. align-items: center;
  567. margin-top: 3px;
  568. }
  569. .all_choose > .el-checkbox-group >>> .el-checkbox {
  570. margin-bottom: 10px;
  571. display: flex;
  572. flex-direction: row;
  573. align-items: center;
  574. }
  575. .all_choose > .el-checkbox-group > .el-checkbox >>> .el-checkbox__label {
  576. min-width: 80px;
  577. overflow: hidden;
  578. width: 80px;
  579. text-overflow: ellipsis;
  580. white-space: nowrap;
  581. }
  582. .all_choose > .el-checkbox-group > .el-checkbox >>> .el-checkbox__label:hover {
  583. width: auto;
  584. }
  585. .cName {
  586. cursor: pointer;
  587. margin: 0 10px;
  588. color: #c3c1c3;
  589. }
  590. .reBox {
  591. position: relative;
  592. top: -25px;
  593. z-index: 999;
  594. left: 5%;
  595. background: #fff;
  596. width: 90%;
  597. border-radius: 5px;
  598. padding-left: 20px;
  599. min-width: 1050px;
  600. }
  601. .reTop {
  602. padding: 20px 0 0 0;
  603. border-bottom: 1px solid #eee;
  604. width: 98%;
  605. display: flex;
  606. flex-direction: row;
  607. flex-wrap: nowrap;
  608. align-items: center;
  609. justify-content: space-between;
  610. }
  611. .reTop > div:nth-child(1) {
  612. font-weight: bold;
  613. width: 40px;
  614. border-bottom: 1px solid #205cc6;
  615. padding-bottom: 20px;
  616. color: #205cc6;
  617. font-size: 20px;
  618. }
  619. .reTop > div:nth-child(2) {
  620. display: flex;
  621. flex-direction: row;
  622. align-items: center;
  623. border: 1px solid #ccced3;
  624. width: 300px;
  625. border-radius: 8px;
  626. padding: 5px 0;
  627. margin-bottom: 10px;
  628. }
  629. .search {
  630. width: 20px;
  631. padding: 0 5px;
  632. }
  633. .search > img {
  634. width: 100%;
  635. height: 100%;
  636. }
  637. .sInput {
  638. border: none;
  639. width: 85%;
  640. }
  641. .sInput:focus-visible {
  642. outline: none;
  643. }
  644. .nameAndLength {
  645. display: flex;
  646. flex-direction: row;
  647. flex-wrap: nowrap;
  648. align-items: center;
  649. justify-content: space-between;
  650. margin: 5px 0;
  651. }
  652. .typeN {
  653. width: 200px;
  654. white-space: nowrap;
  655. overflow: hidden;
  656. text-overflow: ellipsis;
  657. }
  658. .isCType {
  659. color: #6282c2;
  660. }
  661. </style>