index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. <template>
  2. <div class="pptEasyClass">
  3. <div class="pec_main" v-loading="pageLoading">
  4. <div class="pec_header">
  5. <div class="pec_h_left">
  6. <div class="pec_h_l_title">
  7. <span>{{ courseDetail.title }}</span>
  8. </div>
  9. <div v-if="tcid && inviteCode" class="inviteBox" style="margin-left: 20px;">
  10. <span>随机码:{{ inviteCode }}</span>
  11. </div>
  12. </div>
  13. <div class="pec_h_right">
  14. <div class="pec_h_r_btnArea">
  15. <el-tooltip effect="light" content="刷新" placement="top">
  16. <div class="pec_h_r_btn_refresh" @click="refreshCourse">
  17. <img src="../../assets/icon/newIcons/refresh.png" alt="" />
  18. <span>刷新</span>
  19. </div>
  20. </el-tooltip>
  21. <div
  22. @click.stop="back"
  23. v-if="screenType!=2"
  24. >
  25. <img src="../../assets/icon/newIcon/return.png" alt="" />
  26. <span style="color: #000">返回</span>
  27. </div>
  28. </div>
  29. </div>
  30. </div>
  31. <div class="pec_content">
  32. <iframe allow="camera *; microphone *;display-capture;midi;encrypted-media;clipboard-write;clipboard-read" webkitallowfullscreen="" mozallowfullscreen="" allowfullscreen="" frameborder="no" border="0" :src="iframeSrc" v-if="showIframe" style="width: 100%; height: 100%; border: none"></iframe>
  33. </div>
  34. </div>
  35. </div>
  36. </template>
  37. <script>
  38. export default {
  39. data() {
  40. return {
  41. id: this.$route.query.courseId,
  42. userid: this.$route.query.userid,
  43. classId: this.$route.query.cid,
  44. role: this.$route.query.role,
  45. oid: this.$route.query.oid,
  46. org: this.$route.query.org,
  47. tType: this.$route.query.tType,
  48. courseType: this.$route.query.type,
  49. screenType: this.$route.query.screenType,
  50. tcid2: this.$route.query.tcid,
  51. tcid:"",
  52. showIframe: false,
  53. iframeSrc: "",
  54. courseDetail: {},
  55. pageLoading: false,
  56. inviteCode:"",
  57. opertimer: null, // 定时器
  58. };
  59. },
  60. methods: {
  61. goTo(path) {
  62. this.$router.push(path);
  63. },
  64. refreshCourse() {
  65. this.getCourseDetail();
  66. },
  67. getCourseDetail() {
  68. this.pageLoading = true;
  69. let params = {
  70. courseId: this.id
  71. };
  72. this.ajax
  73. .get(this.$store.state.api + "selectCourseDetail3", params)
  74. .then(res => {
  75. console.log("getCourseDetail", res);
  76. this.courseDetail = res.data[0][0];
  77. this.courseDetail.chapters = JSON.parse(this.courseDetail.chapters);
  78. this.tcid = this.arrayToArray(
  79. this.courseDetail.juri ? this.courseDetail.juri.split(",") : [],
  80. this.tcid2 ? this.tcid2.split(",") : []
  81. )[0] || "";
  82. if (this.tcid && res.data[1].length) {
  83. let _inviteA = [];
  84. for (var ik = 0; ik < res.data[1].length; ik++) {
  85. _inviteA.push({
  86. cid: res.data[1][ik].classid,
  87. ic: res.data[1][ik].code,
  88. });
  89. }
  90. for (var ik = 0; ik < _inviteA.length; ik++) {
  91. if (
  92. this.arrayToArray(
  93. _inviteA[ik].cid.split(","),
  94. this.tcid.split(",")
  95. ).length
  96. ) {
  97. this.inviteCode = _inviteA[ik].ic;
  98. break;
  99. }
  100. }
  101. }
  102. this.setPptIframe()
  103. this.pageLoading = false;
  104. })
  105. .catch(err => {
  106. console.log(err);
  107. this.$message.error("获取课程数据失败");
  108. this.pageLoading = false;
  109. });
  110. },
  111. setPptIframe() {
  112. this.showIframe = false;
  113. this.$nextTick(() => {
  114. let _url = `https://ppt.cocorobo.cn/?mode=student&courseid=${this.id}&userid=${this.userid}&oid=${this.oid}&org=${this.org}&cid=${this.tcid}&type=${this.tType}`;
  115. this.iframeSrc = _url;
  116. this.showIframe = true;
  117. });
  118. },
  119. arrayToArray(arrayo, arrayt) {
  120. let array1 = arrayo;
  121. let array2 = arrayt;
  122. let commonElements = [];
  123. for (let i = 0; i < array1.length; i++) {
  124. for (let j = 0; j < array2.length; j++) {
  125. if (array1[i] === array2[j]) {
  126. commonElements.push(array1[i]);
  127. }
  128. }
  129. }
  130. return commonElements;
  131. },
  132. back(){
  133. if(this.tType!=2){
  134. this.goTo(
  135. '/courseDetail?userid=' +
  136. this.userid +
  137. '&oid=' +
  138. this.oid +
  139. '&org=' +
  140. this.org +
  141. '&cid=' +
  142. this.classId +
  143. '&courseId=' +
  144. this.id +
  145. '&tType=' +
  146. this.tType +
  147. '&screenType=' +
  148. this.screenType
  149. )
  150. }else{
  151. this.goTo(
  152. '/index?userid=' +
  153. this.userid +
  154. '&oid=' +
  155. this.oid +
  156. '&org=' +
  157. this.org +
  158. '&cid=' +
  159. this.classId +
  160. '&tType=' +
  161. this.tType +
  162. '&screenType=' +
  163. this.screenType
  164. )
  165. }
  166. },
  167. setOperationTime() {
  168. let _this = this;
  169. if (_this.opertimer) {
  170. clearInterval(_this.opertimer);
  171. _this.opertimer = null;
  172. }
  173. _this.opertimer = setInterval(() => {
  174. _this.setoTime("600");
  175. }, 600000);
  176. },
  177. setoTime(time) {
  178. let params = [
  179. {
  180. uid: this.userid,
  181. cid: this.id,
  182. type: "2",
  183. time: time,
  184. },
  185. ];
  186. this.ajax
  187. .post(this.$store.state.api + "addOperationTimeT2", params)
  188. .then((res) => {})
  189. .catch((err) => {
  190. console.error(err);
  191. });
  192. },
  193. },
  194. destroyed() {
  195. clearInterval(this.opertimer);
  196. this.opertimer = null;
  197. },
  198. mounted() {
  199. this.getCourseDetail();
  200. this.setOperationTime();
  201. }
  202. };
  203. </script>
  204. <style scoped>
  205. .pptEasyClass {
  206. width: 100vw;
  207. height: 100vh;
  208. display: flex;
  209. flex-direction: column;
  210. overflow: hidden;
  211. box-sizing: border-box;
  212. padding: 20px;
  213. background-color: #f2f2f2;
  214. }
  215. .pec_main {
  216. width: 100%;
  217. height: 100%;
  218. background-color: #fff;
  219. border-radius: 12px;
  220. }
  221. .pec_header {
  222. width: 100%;
  223. height: 80px;
  224. border-radius: 12px 12px 0 0;
  225. box-sizing: border-box;
  226. border-bottom: solid 1px #cad1dc;
  227. display: flex;
  228. align-items: center;
  229. justify-content: space-between;
  230. }
  231. .pec_h_left {
  232. width: auto;
  233. height: 100%;
  234. display: flex;
  235. align-items: center;
  236. justify-content: center;
  237. margin-left: 20px;
  238. font-weight: bold;
  239. font-size: 20px;
  240. color: #0e1e33;
  241. }
  242. .pec_h_right {
  243. width: auto;
  244. height: 100%;
  245. display: flex;
  246. align-items: center;
  247. justify-content: center;
  248. margin-right: 20px;
  249. }
  250. .pec_h_r_btnArea {
  251. display: flex;
  252. align-items: center;
  253. justify-content: center;
  254. }
  255. .pec_h_r_btnArea > div {
  256. width: auto;
  257. height: auto;
  258. display: flex;
  259. align-items: center;
  260. justify-content: center;
  261. padding: 10px 20px;
  262. background-color: #f0f4fa;
  263. border-radius: 4px;
  264. cursor: pointer;
  265. margin-right: 10px;
  266. font-size: 14px;
  267. font-weight: 400;
  268. color: #000;
  269. border: 1px solid #cad1dc;
  270. }
  271. .pec_h_r_btnArea > div > img {
  272. width: 15px;
  273. height: 15px;
  274. margin-right: 5px;
  275. }
  276. .pec_h_r_btnArea > .pec_h_r_btn_refresh {
  277. color: #fff;
  278. background-color: #0061ff;
  279. border-color: #0061ff;
  280. }
  281. .pec_content {
  282. width: 100%;
  283. height: calc(100% - 80px);
  284. border-radius: 0 0 12px 12px;
  285. background-color: #fff;
  286. }
  287. .inviteBox {
  288. font-size: 14px;
  289. /* margin-top: 5px; */
  290. color: #00000099;
  291. text-align: center;
  292. }
  293. </style>