course2.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="c_box">
  3. <div class="choice_box" v-loading="isloading">
  4. <div class="title" style="display: flex;">
  5. <span style="min-width: fit-content;">{{ tindex + 1 + "、" }}</span>
  6. <span>{{ checkJson.title }}</span>
  7. </div>
  8. <div class="detail" v-if="checkJson.detail" v-html="checkJson.detail"
  9. style="color: #00000099;margin-top: 5px;">
  10. </div>
  11. <div class="choices">
  12. <el-button type="primary" size="small" @click="openCourseD">选择课程</el-button>
  13. </div>
  14. <div class="choices" v-if="checkJson.answer2.length">
  15. <div class="course" @click="openCourse(course.courseId)" v-for="(course, index) in courseDetail" :key="index">
  16. <div class="banner">
  17. <img :src="course.cover" alt="">
  18. </div>
  19. <div class="content">
  20. <div class="c_c">
  21. <span>课程名字:</span>
  22. <span>{{ course.title }}</span>
  23. </div>
  24. <div class="c_c">
  25. <span>课程类型:</span>
  26. <span>{{ course.name ? course.name : '暂无' }}</span>
  27. </div>
  28. <div class="c_c">
  29. <span>创建人:</span>
  30. <span>{{ course.username }}</span>
  31. </div>
  32. <div class="c_c">
  33. <span>协作者:</span>
  34. <span>{{ course.xieName ? course.xieName : '暂无' }}</span>
  35. </div>
  36. </div>
  37. </div>
  38. <!-- <div class="page" v-if="checktype == '1'">
  39. <el-button type="primary" size="mini" :disabled="page == 0" @click="setPage('-1')">上一个</el-button>
  40. <div class="p_page"><span>{{ page + 1 }}</span><span>/</span><span>{{ checkJson.courses.length }}</span>
  41. </div>
  42. <el-button type="primary" size="mini" :disabled="page == (checkJson.courses.length - 1)"
  43. @click="setPage('1')">下一个</el-button>
  44. </div> -->
  45. </div>
  46. </div>
  47. <courseDilogVue :dialogVisibleCourse.sync="dialogVisibleCourse" :courses="checkJson.answer2" @setCourse="setCourse">
  48. </courseDilogVue>
  49. </div>
  50. </template>
  51. <script>
  52. import courseDilogVue from '../../../add/components/course2/courseDilog.vue'
  53. export default {
  54. components: {
  55. courseDilogVue,
  56. },
  57. props: {
  58. tindex: {
  59. type: Number
  60. },
  61. cJson: {
  62. type: Object,
  63. },
  64. checktype: {
  65. type: Number,
  66. default: 1
  67. },
  68. see: {
  69. type: Boolean,
  70. default: false
  71. }
  72. },
  73. data() {
  74. return {
  75. option: {
  76. 1: { name: '附件' },
  77. },
  78. userid: this.$route.query.userid,
  79. checkJson: undefined,
  80. progress: 0,
  81. isFinishSize: 0,
  82. proVisible: false,
  83. isAllSize: 0,
  84. wurl: "",
  85. isTong: false,
  86. page: 0,
  87. isloading: false,
  88. courseDetail:[],
  89. dialogVisibleCourse: false
  90. }
  91. },
  92. computed: {
  93. },
  94. watch: {
  95. checkJson: {
  96. handler(newValue) {
  97. this.$emit('update:cJson', newValue)
  98. },
  99. deep: true
  100. },
  101. },
  102. methods: {
  103. setCourse(courses) {
  104. this.checkJson.answer2 = courses
  105. this.getCourse(this.checkJson.answer2)
  106. this.$forceUpdate()
  107. },
  108. depthCopy(s) {
  109. return JSON.parse(JSON.stringify(s));
  110. },
  111. openFileBox() {
  112. this.dialogVisiblefile = true
  113. },
  114. setPage(index) {
  115. if (index == '1') {
  116. this.page++
  117. } else if (index == '-1') {
  118. this.page--
  119. }
  120. this.checkJson.answer2 = this.checkJson.courses[this.page]
  121. this.getCourse(this.checkJson.answer2)
  122. },
  123. openCourse(cid){
  124. top.postMessage({ cid: cid, screenType: "3" }, "*");
  125. },
  126. getCourse(id) {
  127. this.isloading = true
  128. let params = {
  129. cid: id.join(","),
  130. };
  131. this.ajax
  132. .get(this.$store.state.api + "getCourseInfoTestAll", params)
  133. .then((res) => {
  134. this.isloading = false
  135. this.courseDetail = res.data[0]
  136. this.courseDetail.forEach(element => {
  137. element.cover = JSON.parse(element.cover)[0].url
  138. });
  139. })
  140. .catch((err) => {
  141. this.isloading = false
  142. console.error(err);
  143. });
  144. },
  145. openCourseD(){
  146. this.dialogVisibleCourse = true
  147. }
  148. },
  149. mounted() {
  150. this.checkJson = this.cJson ? this.depthCopy(this.cJson) : undefined
  151. if(this.checkJson.answer2.length){
  152. // this.page = this.checkJson.courses.indexOf(this.checkJson.answer2)
  153. this.getCourse(this.checkJson.answer2)
  154. }
  155. }
  156. }
  157. </script>
  158. <style scoped>
  159. .c_box {
  160. width: 100%;
  161. position: relative;
  162. }
  163. /* .mask {
  164. position: absolute;
  165. height: 100%;
  166. width: 100%;
  167. z-index: 2;
  168. } */
  169. .choice_box {
  170. white-space: pre-line;
  171. }
  172. .choice_box>.title {
  173. font-weight: bold;
  174. width: 100%;
  175. word-break: break-all;
  176. }
  177. .choice_box>.choices {
  178. margin-top: 10px;
  179. }
  180. .choices > .page{
  181. margin-top: 10px;
  182. display: flex;
  183. align-items: center;
  184. }
  185. .p_page{
  186. margin: 0 10px;
  187. }
  188. .course {
  189. display: flex;
  190. align-items: center;
  191. cursor: pointer;
  192. }
  193. .course + .course{
  194. margin-top: 10px;
  195. }
  196. .course > .banner {
  197. width: 200px;
  198. height: 120px;
  199. border-radius: 5px;
  200. overflow: hidden;
  201. border: 1px solid #3896fc;
  202. box-sizing: border-box;
  203. padding: 5px;
  204. margin-right: 15px;
  205. }
  206. .course > .banner > img{
  207. width: 100%;
  208. height: 100%;
  209. object-fit: cover;
  210. }
  211. .course > .content {}
  212. .course > .content > .c_c {}
  213. .course > .content > .c_c + .c_c{
  214. margin-top: 5px;
  215. }
  216. .course > .content > .c_c span:nth-child(1){}
  217. .course > .content > .c_c span:nth-child(2){}
  218. </style>