course.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327
  1. <template>
  2. <div class="c_box">
  3. <div class="choice_box" v-loading="isloading" v-if="checkJson">
  4. <div class="title" style="display: flex;align-items: center;">
  5. <span class="g_t_index" 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: #00000066;margin-top: 5px;">
  10. </div>
  11. <div class="choices" v-if="checkJson.courses.length">
  12. <div class="course" @click="openCourse()">
  13. <div class="banner" :style=" isN==1? 'width:140px;height:90px;' : ''">
  14. <div v-if="tid" class="isRate">已评分</div>
  15. <img :src="courseDetail.cover" alt="">
  16. </div>
  17. <div class="content">
  18. <div class="c_c">
  19. <span>课程名称:</span>
  20. <el-tooltip :content="courseDetail.title" placement="top" effect="dark">
  21. <span :style=" isN==1? 'max-width:75px;' : ''">{{ courseDetail.title }}</span>
  22. </el-tooltip>
  23. </div>
  24. <div class="c_c">
  25. <span>课程类型:</span>
  26. <span v-if="!courseDetail.name">{{ '暂无' }}</span>
  27. <el-tooltip v-else :content="courseDetail.name" placement="top" effect="dark">
  28. <span :style=" isN==1? 'max-width:75px;' : ''">{{ courseDetail.name }}</span>
  29. </el-tooltip>
  30. </div>
  31. <div class="c_c">
  32. <span>创建人:</span>
  33. <span :style=" isN==1? 'max-width:75px;' : ''">{{ courseDetail.username }}</span>
  34. </div>
  35. <div class="c_c">
  36. <span>协作者:</span>
  37. <span v-if="!courseDetail.xieName">{{ '暂无' }}</span>
  38. <el-tooltip v-else :content="courseDetail.xieName" placement="top" effect="dark">
  39. <span :style=" isN==1? 'max-width:75px;' : ''">{{ courseDetail.xieName }}</span>
  40. </el-tooltip>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="page" v-if="checktype == '1'">
  45. <el-button type="primary" size="mini" :disabled="page == 0" @click="setPage('-1')">上一个</el-button>
  46. <div class="p_page"><span>{{ page + 1 }}</span><span>/</span><span>{{ checkJson.courses.length
  47. }}</span>
  48. </div>
  49. <el-button type="primary" size="mini" :disabled="page == (checkJson.courses.length - 1)"
  50. @click="setPage('1')">下一个</el-button>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script>
  57. export default {
  58. props: {
  59. tindex: {
  60. type: Number
  61. },
  62. cJson: {
  63. type: Object,
  64. },
  65. checktype: {
  66. type: Number,
  67. default: 1
  68. },
  69. see: {
  70. type: Boolean,
  71. default: false
  72. },
  73. issetPage: {
  74. type: Boolean,
  75. default: false
  76. },
  77. tid: {
  78. type: String
  79. }
  80. },
  81. data() {
  82. return {
  83. option: {
  84. 1: { name: '附件' },
  85. },
  86. userid: this.$route.query.userid,
  87. isN: this.$route.query.isN,
  88. checkJson: undefined,
  89. progress: 0,
  90. isFinishSize: 0,
  91. proVisible: false,
  92. isAllSize: 0,
  93. wurl: "",
  94. isTong: false,
  95. page: 0,
  96. isloading: false,
  97. courseDetail: {},
  98. courseid: ''
  99. }
  100. },
  101. computed: {
  102. },
  103. watch: {
  104. checkJson: {
  105. handler(newValue) {
  106. this.$emit('update:cJson', newValue)
  107. },
  108. deep: true
  109. },
  110. cJson: {
  111. handler(newValue) {
  112. if (newValue.answer2 != this.checkJson.answer2) {
  113. this.checkJson = this.depthCopy(newValue)
  114. if (this.checkJson.courses.length) {
  115. this.page = this.checkJson.courses.indexOf(this.courseid)
  116. this.checkJson.answer2 = this.courseid
  117. }
  118. this.$forceUpdate()
  119. }
  120. },
  121. deep: true
  122. },
  123. courseid: {
  124. handler(newValue) {
  125. if (this.issetPage) {
  126. this.$emit('update:issetPage', false)
  127. } else {
  128. this.$emit('getTestWorkByCid', newValue)
  129. }
  130. },
  131. deep: true
  132. }
  133. },
  134. methods: {
  135. depthCopy(s) {
  136. return JSON.parse(JSON.stringify(s));
  137. },
  138. openFileBox() {
  139. this.dialogVisiblefile = true
  140. },
  141. setPage(index) {
  142. this.$emit('publish2')
  143. setTimeout(() => {
  144. if (index == '1') {
  145. this.page++
  146. } else if (index == '-1') {
  147. this.page--
  148. }
  149. this.checkJson.answer2 = this.checkJson.courses[this.page]
  150. this.courseid = this.checkJson.answer2
  151. this.$forceUpdate()
  152. this.getCourse(this.checkJson.answer2)
  153. }, 500);
  154. },
  155. openCourse() {
  156. window.topU.postMessage({ cid: this.checkJson.answer2, screenType: "3" }, "*");
  157. },
  158. getCourse(id) {
  159. this.isloading = true
  160. let params = {
  161. cid: id,
  162. };
  163. this.ajax
  164. .get(this.$store.state.api + "getCourseInfoTest", params)
  165. .then((res) => {
  166. this.isloading = false
  167. this.courseDetail = res.data[0][0]
  168. this.courseDetail.cover = JSON.parse(this.courseDetail.cover)[0].url
  169. })
  170. .catch((err) => {
  171. this.isloading = false
  172. console.error(err);
  173. });
  174. }
  175. },
  176. mounted() {
  177. this.checkJson = this.cJson ? this.depthCopy(this.cJson) : undefined
  178. if (this.checkJson.courses.length) {
  179. this.page = this.checkJson.courses.indexOf(this.checkJson.answer2)
  180. this.courseid = this.checkJson.answer2
  181. this.getCourse(this.checkJson.answer2)
  182. }
  183. }
  184. }
  185. </script>
  186. <style scoped>
  187. .c_box {
  188. width: 100%;
  189. position: relative;
  190. padding-left: 45px;
  191. }
  192. /* .mask {
  193. position: absolute;
  194. height: 100%;
  195. width: 100%;
  196. z-index: 2;
  197. } */
  198. .choice_box {
  199. white-space: pre-line;
  200. }
  201. .choice_box>.title {
  202. font-weight: bold;
  203. width: 100%;
  204. word-break: break-all;
  205. }
  206. .choice_box>.choices {
  207. margin-top: 10px;
  208. display: flex;
  209. flex-direction: column;
  210. justify-content: center;
  211. align-items: center;
  212. }
  213. .choices>.page {
  214. margin-top: 10px;
  215. display: flex;
  216. align-items: center;
  217. }
  218. .p_page {
  219. margin: 0 10px;
  220. }
  221. .course {
  222. display: flex;
  223. align-items: center;
  224. cursor: pointer;
  225. }
  226. .course>.banner {
  227. width: 200px;
  228. height: 120px;
  229. border-radius: 5px;
  230. overflow: hidden;
  231. border: 1px solid #3896fc;
  232. box-sizing: border-box;
  233. padding: 5px;
  234. margin-right: 15px;
  235. position: relative;
  236. }
  237. .isRate {
  238. position: absolute;
  239. background: #0061FF;
  240. width: 70px;
  241. height: 30px;
  242. border-radius: 5px;
  243. color: #fff;
  244. font-size: 14px;
  245. text-align: center;
  246. line-height: 30px;
  247. top: 5px;
  248. left: 5px;
  249. }
  250. .course>.banner>img {
  251. width: 100%;
  252. height: 100%;
  253. object-fit: cover;
  254. }
  255. .course>.content {}
  256. .course>.content>.c_c {
  257. display: flex;
  258. align-items: center;
  259. }
  260. .course>.content>.c_c+.c_c {
  261. margin-top: 5px;
  262. }
  263. .course>.content>.c_c span:nth-child(1) {}
  264. .course>.content>.c_c span:nth-child(2) {
  265. max-width: 250px;
  266. overflow: hidden;
  267. white-space: nowrap;
  268. display: block;
  269. text-overflow: ellipsis;
  270. }
  271. .g_t_index{
  272. color: #3681FC;
  273. font-size: 28px;
  274. font-weight: bold;
  275. position: relative;
  276. margin-right: 30px;
  277. margin-left: -40px;
  278. }
  279. .g_t_index+span{
  280. font-weight: bold;
  281. font-size: 18px;
  282. }
  283. .g_t_index::after{
  284. content: "";
  285. width: 18px;
  286. height: 2px;
  287. position: absolute;
  288. right: -18px;
  289. top: 50%;
  290. transform: translateY(-50%);
  291. background: #3681FC;
  292. }
  293. .g_t_index::before{
  294. content: "";
  295. width: 6px;
  296. height: 6px;
  297. border-right: 2px solid #3681FC;
  298. border-top: 2px solid #3681FC;
  299. position: absolute;
  300. right: -15px;
  301. top: 50%;
  302. transform: rotate(45deg) translateY(-5px);
  303. }
  304. </style>