index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div>
  3. <head-bar @back="back" v-if="routeType == 0">
  4. <template #title>
  5. <div class="navTitle">课程详情</div>
  6. </template>
  7. </head-bar>
  8. <div class="head-container" v-if="routeType == 1">
  9. <div class="head-box">
  10. <div class="navTitle">课程详情</div>
  11. </div>
  12. </div>
  13. <div class="courseBoxMes">
  14. <course-message
  15. :cDetail="courseDetail"
  16. :cInfo="chapInfo"
  17. :rwLength="rw"
  18. :cType="courseType"
  19. :cJson="courseTypeJson"
  20. :tName="Tname"
  21. ></course-message>
  22. <course-chap :chInfo="chapInfo" :brief="courseDetail.brief" @goCourse="goToStudy"></course-chap>
  23. </div>
  24. <div class="studyCss">
  25. <div style="stuButton" @click="goToStudy">点击学习</div>
  26. </div>
  27. </div>
  28. </template>
  29. <script>
  30. import { getCourseDetail } from '@/api/courseDetail'
  31. import headBar from '@/components/headBar.vue'
  32. import courseMessage from './components/courseMessage.vue'
  33. import courseChap from './components/courseChap.vue'
  34. export default {
  35. components: {
  36. headBar,
  37. courseMessage,
  38. courseChap
  39. },
  40. data() {
  41. return {
  42. courseid: this.$route.query.courseid,
  43. courseDetail: {},
  44. routeType: 0,
  45. courseTypeJson: {},
  46. chapInfo: [],
  47. courseType: [],
  48. Tname: [],
  49. rw: 0
  50. }
  51. },
  52. methods: {
  53. back() {
  54. this.$router.push({ path: '/home' })
  55. },
  56. goToStudy() {
  57. // eslint-disable-next-line object-curly-spacing
  58. this.$router.push({ path: '/course', query: { courseid: this.courseid } })
  59. },
  60. getCourse() {
  61. const params = {
  62. courseId: this.courseid
  63. }
  64. getCourseDetail(params)
  65. .then(res => {
  66. this.courseDetail = res[0][0]
  67. var a = res[0]
  68. var b = res[1]
  69. var c = res[2]
  70. for (var i = 0; i < b.length; i++) {
  71. for (var j = 0; j < a.length; j++) {
  72. if (b[i].id === a[j].pid) {
  73. if (!this.courseTypeJson[b[i].name]) {
  74. this.courseType.push(b[i].name)
  75. this.courseTypeJson[b[i].name] = []
  76. }
  77. this.courseTypeJson[b[i].name].push(a[j].name)
  78. }
  79. }
  80. }
  81. this.Tname = []
  82. for (var k = 0; k < c.length; k++) {
  83. this.Tname.push(c[k].name)
  84. }
  85. this.chapInfo = JSON.parse(this.courseDetail.chapters)
  86. for (var z = 0; z < this.chapInfo.length; z++) {
  87. this.rw += this.chapInfo[z].chapterInfo[0].taskJson.length
  88. }
  89. })
  90. .catch(err => {
  91. console.error(err)
  92. })
  93. }
  94. },
  95. mounted() {
  96. console.log('type', this.$route.query)
  97. if (this.$route.query.urlType) {
  98. sessionStorage .setItem('urlType', this.$route.query.urlType)
  99. }
  100. this.routeType = sessionStorage .getItem('urlType')
  101. // console.log('hahahha',!localStorage.getItem('urlType'));
  102. // console.log('kakakaka', this.$store.getters.shareCourseId)
  103. // if (localStorage.getItem('urlType') == 1) {
  104. // this.routeType = 1
  105. // } else {
  106. // this.routeType = 0
  107. // }
  108. this.getCourse()
  109. }
  110. }
  111. </script>
  112. <style lang="scss" scoped>
  113. .courseBoxMes {
  114. height: 100vh;
  115. overflow: auto;
  116. padding: 0 0 60px;
  117. box-sizing: border-box;
  118. }
  119. .head-container {
  120. height: 55px;
  121. width: 100%;
  122. background-image: url(../../assets/images/course/head-back.png);
  123. position: fixed;
  124. top: 0;
  125. .back {
  126. width: 0.3rem;
  127. height: 0.3rem;
  128. border-top: 2px solid #fff;
  129. border-left: 2px solid #fff;
  130. position: absolute;
  131. transform: rotate(-45deg) translateY(-50%);
  132. top: 47%;
  133. left: 0.8rem;
  134. cursor: pointer;
  135. }
  136. .head-box {
  137. padding: 0 1.5rem;
  138. display: flex;
  139. width: 100%;
  140. height: 100%;
  141. align-items: center;
  142. justify-content: center;
  143. box-sizing: border-box;
  144. }
  145. }
  146. .navTitle {
  147. font-size: 16px;
  148. color: #fff;
  149. }
  150. .studyCss {
  151. height: 60px;
  152. border-top: 1px solid #dddddd;
  153. position: fixed;
  154. width: 100%;
  155. bottom: 0;
  156. background: #fff;
  157. > div {
  158. width: 90%;
  159. height: 40px;
  160. margin: 10px auto;
  161. text-align: center;
  162. color: #fff;
  163. background-image: linear-gradient(90deg, #477cd7, #65b9fc);
  164. line-height: 40px;
  165. border-radius: 10px;
  166. }
  167. }
  168. </style>