top.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  1. <template>
  2. <div id="top">
  3. <div class="n_box">
  4. <div class="left">
  5. <div class="tab_main">
  6. <header>
  7. <div :class="active == 1 ? 'active_tab' : ''">课程导航</div>
  8. <!-- <div :class="active == 2 ? 'active_tab' : ''">报考指导</div> -->
  9. </header>
  10. <div class="content_tab scroll_style">
  11. <div
  12. class="tab_li"
  13. v-for="(item, index) in typeList"
  14. :key="index"
  15. @mouseenter="handleMouseEnter(index)"
  16. >
  17. <div class="tops">
  18. <span>{{ item.educationName }}</span>
  19. <i class="el-icon-arrow-right"></i>
  20. </div>
  21. <ul>
  22. <li
  23. v-for="(items, indexs) in item.businessList"
  24. :key="indexs"
  25. v-show="indexs < 4"
  26. >
  27. {{ items.aliasName }}
  28. </li>
  29. <div style="clear:both;"></div>
  30. </ul>
  31. <div class="ri_p">
  32. <h4>{{ typeList[eduIndex].educationName }}</h4>
  33. <div class="fgx"></div>
  34. <ul class="scroll_style">
  35. <li
  36. v-for="(it, ix) in typeList[eduIndex].businessList"
  37. :key="ix"
  38. @click="goCourse(it)"
  39. >
  40. {{ it.aliasName }}
  41. </li>
  42. <div style="clear:both;"></div>
  43. </ul>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="swiper">
  49. <swiper
  50. v-if="swiperOptions.bannerList.length > 0"
  51. :options="swiperOptions"
  52. >
  53. <swiper-slide
  54. v-for="(item, index) in swiperOptions.bannerList"
  55. v-bind:key="index"
  56. @click.native="swiperJump(item)"
  57. >
  58. <img
  59. :src="$tools.splitImgHost(item.adverUrl, true, 880)"
  60. alt=""
  61. />
  62. </swiper-slide>
  63. <div class="swiper-pagination" slot="pagination"></div>
  64. </swiper>
  65. </div>
  66. </div>
  67. <div class="login">
  68. <template v-if="!userInfo">
  69. <h2 class="title">账号登录注册</h2>
  70. <p class="value">获取海量优质课程</p>
  71. <img class="ggImg" src="@/assets/new1/专属好课推荐.png" alt="" />
  72. <div class="btn" @click="$refs.login.openBox()">登录/注册</div>
  73. </template>
  74. <template v-else>
  75. <header class="header_user">
  76. <div>
  77. <img :src="$tools.splitImgHost(userInfo.avatar)" alt="" />
  78. <span>{{ userInfo.realname }}</span>
  79. </div>
  80. <div>
  81. <span
  82. @click="go('/person-center/my-info')"
  83. style="cursor: pointer;"
  84. >个人中心</span
  85. >
  86. <i class="el-icon-arrow-right"></i>
  87. </div>
  88. </header>
  89. <div class="header_li">
  90. <div
  91. @click="go('/person-center/my-course')"
  92. style="cursor: pointer;"
  93. >
  94. <img src="@/assets/kc.png" alt="" />
  95. <p>课程</p>
  96. </div>
  97. <div @click="go('/person-center/my-bank')" style="cursor: pointer;">
  98. <img src="@/assets/tk.png" alt="" />
  99. <p>题库</p>
  100. </div>
  101. <div
  102. @click="go('/person-center/my-order')"
  103. style="cursor: pointer;"
  104. >
  105. <img src="@/assets/dd.png" alt="" />
  106. <p>订单</p>
  107. </div>
  108. </div>
  109. <div class="fgx" style="width: 100%;opacity: 0.5;"></div>
  110. <div class="f_box" v-if="recordList.goodsId">
  111. <div class="btnsy">上次播放</div>
  112. <div class="title" @click="goLast">{{ recordList.goodsName }}</div>
  113. <div class="remark">
  114. <span
  115. >已学{{
  116. toFixed(
  117. (recordList.videoCurrentTime / recordList.durationTime) *
  118. 100
  119. )
  120. }}%</span
  121. >
  122. <span>{{ recordList.date }}</span>
  123. </div>
  124. </div>
  125. </template>
  126. </div>
  127. </div>
  128. <login ref="login"></login>
  129. </div>
  130. </template>
  131. <script>
  132. import login from "@/components/login";
  133. import { swiper, swiperSlide } from "vue-awesome-swiper";
  134. import "swiper/swiper-bundle.css";
  135. import { mapGetters } from "vuex";
  136. export default {
  137. components: {
  138. swiper,
  139. swiperSlide,
  140. login
  141. },
  142. data() {
  143. return {
  144. recordList: {},
  145. active: 1,
  146. eduIndex: 0,
  147. typeList: [],
  148. swiperOptions: {
  149. bannerList: [],
  150. loop: true,
  151. observer: true,
  152. observeParents: true,
  153. speed: 300,
  154. autoplayDisableOnInteraction: false,
  155. autoplayStopOnLast: false,
  156. autoplay: {
  157. delay: 1000,
  158. disableOnInteraction: false
  159. },
  160. // 显示分页
  161. pagination: {
  162. el: ".swiper-pagination",
  163. clickable: true //允许分页点击跳转
  164. },
  165. // 设置点击箭头
  166. navigation: {
  167. nextEl: ".swiper-button-next",
  168. prevEl: ".swiper-button-prev"
  169. }
  170. } //轮播
  171. };
  172. },
  173. computed: {
  174. ...mapGetters(["userInfo"]),
  175. toFixed: function() {
  176. return function(num) {
  177. if (num) {
  178. let str = String(num).indexOf(".");
  179. if (str != -1) {
  180. return +num.toFixed(2);
  181. } else {
  182. return num;
  183. }
  184. } else {
  185. return 0;
  186. }
  187. };
  188. }
  189. },
  190. watch: {
  191. userInfo: {
  192. handler() {
  193. if ((newVal, oldVal)) {
  194. this.getRecord();
  195. }
  196. }
  197. }
  198. },
  199. mounted() {
  200. this.advertisingList();
  201. this.educationTypeList();
  202. if (this.userInfo) {
  203. this.getRecord();
  204. }
  205. },
  206. methods: {
  207. /**
  208. * 播放记录
  209. */
  210. getRecord() {
  211. this.$request
  212. .studRrecordListUserRecord({
  213. pageNum: 1,
  214. pageSize: 1
  215. })
  216. .then(res => {
  217. if (res.rows.length) {
  218. this.recordList = res.rows[0];
  219. }
  220. });
  221. },
  222. go(path, query) {
  223. this.$router.push({
  224. path,
  225. query
  226. });
  227. },
  228. goLast() {
  229. if (this.recordList.goodsType == 6) {
  230. this.go("/my-live-detail/" + this.recordList.goodsId, {
  231. gradeId: this.recordList.gradeId,
  232. orderGoodsId: this.recordList.orderGoodsId,
  233. courseId: this.recordList.courseId
  234. });
  235. } else if (this.recordList.goodsType == 1) {
  236. this.$router.push({
  237. path: `/my-course-detail/${this.recordList.goodsId}`,
  238. query: {
  239. gradeId: this.recordList.gradeId,
  240. orderGoodsId: this.recordList.orderGoodsId,
  241. courseId: this.recordList.courseId,
  242. chapterId: this.recordList.chapterId,
  243. moduleId: this.recordList.moduleId,
  244. sectionId: this.recordList.sectionId,
  245. recordingUrl: this.recordList.recordingUrl,
  246. liveUrl: this.recordList.liveUrl,
  247. sectionType: this.recordList.sectionType,
  248. liveStartTime: this.recordList.liveStartTime,
  249. liveEndTime: this.recordList.liveEndTime
  250. }
  251. });
  252. }
  253. },
  254. handleMouseEnter(index) {
  255. this.eduIndex = index;
  256. },
  257. handleMouseLeave(item) {
  258. console.log(item, "leave");
  259. },
  260. goCourse(item) {
  261. // if (item.topicId) {
  262. // this.$router.push({
  263. // path: "/goodsTopic",
  264. // query: {
  265. // topicId: item.topicId
  266. // }
  267. // });
  268. // return;
  269. // }
  270. this.$router.push({
  271. path: "/course-list",
  272. query: {
  273. educationId: item.educationId ? item.educationId : item.id || "",
  274. projectId: item.projectId || "",
  275. businessId: item.educationId ? item.id : ""
  276. }
  277. });
  278. },
  279. educationTypeList() {
  280. this.$request.educationTypeList().then(res => {
  281. this.typeList = res.rows || [];
  282. this.typeList.forEach(async (item, index) => {
  283. const A = await this.$request.businessList({ educationId: item.id });
  284. item.businessList = A.rows.filter(items => items.aliasName);
  285. });
  286. });
  287. },
  288. swiperJump(swiper) {
  289. if (swiper.jumpType == 1) {
  290. //无跳转
  291. return;
  292. } else if (swiper.jumpType == 2) {
  293. //url
  294. window.open(swiper.jumpUrl, "_blank");
  295. } else if (swiper.jumpType == 3) {
  296. //内部接口
  297. this.$router.push({
  298. path: swiper.jumpUrl
  299. });
  300. }
  301. },
  302. advertisingList() {
  303. this.$request
  304. .advertisinghomeLocationList({
  305. platform: 2, //1小程序2PC网站
  306. status: 1,
  307. locationKey: "home-banner" //首页轮播KEY
  308. })
  309. .then(res => {
  310. /**
  311. * 如果存在-调用轮播图列表
  312. */
  313. if (res.data.length) {
  314. this.$request
  315. .advertisingList({ locationId: res.data[0].locationId })
  316. .then(result => {
  317. this.swiperOptions.autoplay.delay =
  318. res.data[0].intervalTime * 1000;
  319. this.swiperOptions.bannerList = result.rows;
  320. });
  321. }
  322. });
  323. }
  324. }
  325. };
  326. </script>
  327. <style lang="scss" scoped>
  328. .scroll_style {
  329. &::-webkit-scrollbar {
  330. width: 5px;
  331. height: 9px;
  332. }
  333. /*定义滚动条轨道 内阴影+圆角*/
  334. &::-webkit-scrollbar-track {
  335. background-color: inherit;
  336. border: none;
  337. /* margin: 6px; */
  338. border-radius: 10px;
  339. /* -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
  340. background-color: #F5F5F5; */
  341. }
  342. /*定义滑块 内阴影+圆角*/
  343. &::-webkit-scrollbar-thumb {
  344. border-radius: 10px;
  345. position: relative;
  346. right: 2px;
  347. /*-webkit-box-shadow: inset 0 0 6px rgba(0,0,0,.3);*/
  348. background-color: #c6c6cd;
  349. width: 6px;
  350. }
  351. }
  352. #top {
  353. height: 600px;
  354. background: url("../../assets/new1/banner.png");
  355. position: relative;
  356. .n_box {
  357. position: absolute;
  358. width: 1200px;
  359. height: 400px;
  360. top: 126px;
  361. left: 50%;
  362. transform: translateX(-50%);
  363. display: flex;
  364. align-items: center;
  365. & > .left {
  366. flex: 1;
  367. background-color: #fff;
  368. border-radius: 4px;
  369. overflow: hidden;
  370. height: 100%;
  371. position: relative;
  372. .tab_main {
  373. backdrop-filter: blur(10px);
  374. width: 300px;
  375. height: 400px;
  376. z-index: 10;
  377. position: absolute;
  378. top: 0;
  379. left: 0;
  380. background-color: rgba(0, 0, 0, 0.85);
  381. & > header {
  382. display: flex;
  383. align-items: center;
  384. height: 50px;
  385. color: #fff;
  386. user-select: none;
  387. & > div {
  388. font-size: 16px;
  389. flex: 1;
  390. text-align: center;
  391. height: 48px;
  392. line-height: 48px;
  393. cursor: pointer;
  394. font-weight: 400;
  395. border-bottom: 2px solid #eeeeee50;
  396. &:hover {
  397. border-color: rgb(0, 122, 255);
  398. font-weight: bold;
  399. }
  400. // border-bottom: 2px solid #eee;
  401. }
  402. & > .active_tab {
  403. border-color: rgb(0, 122, 255);
  404. font-weight: bold;
  405. }
  406. }
  407. & > .content_tab {
  408. height: 350px;
  409. overflow: auto;
  410. & > .tab_li {
  411. padding: 16px 0px;
  412. margin: 0px 20px;
  413. color: #fff;
  414. border-bottom: 1px solid rgb(86, 89, 92);
  415. &:hover {
  416. color: #007aff !important;
  417. }
  418. & > .ri_p {
  419. visibility: hidden;
  420. position: absolute;
  421. background-color: #fff;
  422. top: 0px;
  423. left: 300px;
  424. width: 580px;
  425. height: 400px;
  426. transition: all 0.3s;
  427. opacity: 0;
  428. padding: 15px 30px 0px;
  429. display: flex;
  430. flex-direction: column;
  431. h4 {
  432. font-weight: bold;
  433. color: #007aff;
  434. font-size: 16px;
  435. }
  436. ul {
  437. overflow: auto;
  438. > li {
  439. user-select: none;
  440. cursor: pointer;
  441. float: left;
  442. margin: 0px 20px 20px 0px;
  443. color: #007aff;
  444. &:hover {
  445. font-weight: bold;
  446. }
  447. }
  448. }
  449. }
  450. &:hover .ri_p {
  451. visibility: visible;
  452. opacity: 1;
  453. }
  454. &:last-child {
  455. border-bottom: none;
  456. }
  457. & > .tops {
  458. user-select: none;
  459. display: flex;
  460. align-items: center;
  461. justify-content: space-between;
  462. margin-bottom: 14px;
  463. font-weight: bold;
  464. }
  465. & > ul {
  466. & > li {
  467. margin: 0px 10px 6px 0px;
  468. float: left;
  469. user-select: none;
  470. }
  471. }
  472. }
  473. }
  474. }
  475. }
  476. & > .login {
  477. margin-left: 20px;
  478. border-radius: 4px;
  479. overflow: hidden;
  480. background-color: rgba(0, 0, 0, 0.5);
  481. backdrop-filter: blur(10px);
  482. width: 300px;
  483. height: 100%;
  484. display: flex;
  485. flex-direction: column;
  486. align-items: center;
  487. & > .title {
  488. font-size: 18px;
  489. font-weight: bold;
  490. color: #fff;
  491. margin-top: 50px;
  492. margin-bottom: 20px;
  493. }
  494. & > .value {
  495. font-size: 14px;
  496. color: #fff;
  497. margin-bottom: 20px;
  498. }
  499. & > .ggImg {
  500. border-radius: 14px;
  501. overflow: hidden;
  502. margin-bottom: 20px;
  503. width: 211px;
  504. height: 120px;
  505. background-color: #fff;
  506. }
  507. & > .btn {
  508. user-select: none;
  509. cursor: pointer;
  510. width: 211px;
  511. border-radius: 100px;
  512. color: #fff;
  513. background-color: rgb(0, 122, 255);
  514. text-align: center;
  515. height: 30px;
  516. line-height: 30px;
  517. transition: all 0.2s;
  518. &:hover {
  519. background-color: rgb(2, 106, 244);
  520. }
  521. }
  522. & > .header_user {
  523. display: flex;
  524. align-items: center;
  525. justify-content: space-between;
  526. width: 100%;
  527. padding: 30px;
  528. & > div {
  529. display: flex;
  530. align-items: center;
  531. & > img {
  532. width: 40px;
  533. height: 40px;
  534. margin-right: 6px;
  535. overflow: hidden;
  536. border-radius: 50%;
  537. }
  538. & > span {
  539. color: #fff;
  540. margin-right: 6px;
  541. }
  542. & > i {
  543. color: #fff;
  544. }
  545. }
  546. }
  547. & > .header_li {
  548. width: 100%;
  549. display: flex;
  550. align-items: center;
  551. justify-content: space-between;
  552. padding: 0px 30px;
  553. & > div {
  554. color: #fff;
  555. & > img {
  556. width: 60px;
  557. height: 60px;
  558. overflow: hidden;
  559. border-radius: 50%;
  560. margin-bottom: 6px;
  561. }
  562. & > p {
  563. text-align: center;
  564. }
  565. }
  566. }
  567. & > .f_box {
  568. user-select: none;
  569. padding: 10px;
  570. color: #fff;
  571. width: 100%;
  572. & > .btnsy {
  573. display: inline-block;
  574. border-radius: 14px;
  575. padding: 4px 8px;
  576. border: 1px solid #fff;
  577. margin-bottom: 6px;
  578. }
  579. & > .title {
  580. margin-bottom: 6px;
  581. cursor: pointer;
  582. &:hover {
  583. color: #409eff;
  584. }
  585. }
  586. & > .remark {
  587. display: flex;
  588. align-items: center;
  589. justify-content: space-between;
  590. margin-bottom: 6px;
  591. }
  592. }
  593. }
  594. }
  595. }
  596. .swiper-slide {
  597. cursor: pointer;
  598. height: 400px;
  599. img {
  600. width: 100%;
  601. height: 100%;
  602. }
  603. }
  604. .swiper-pagination {
  605. text-align: right;
  606. padding-right: 24px;
  607. /deep/ .swiper-pagination-bullet {
  608. background: rgba(255, 255, 255, 0.4);
  609. &-active {
  610. background: rgba(255, 255, 255, 1);
  611. }
  612. }
  613. }
  614. .fgx {
  615. margin: 15px 0px;
  616. height: 1px;
  617. background-color: #eee;
  618. }
  619. </style>