index_old.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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="tType == 1 || 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. import { myMixin } from '../../mixins/mixin';
  39. export default {
  40. mixins: [myMixin],
  41. data() {
  42. return {
  43. id: this.$route.query.courseId,
  44. userid: this.$route.query.userid,
  45. classId: this.$route.query.cid,
  46. role: this.$route.query.role,
  47. oid: this.$route.query.oid,
  48. org: this.$route.query.org,
  49. tType: this.$route.query.tType,
  50. courseType: this.$route.query.type,
  51. screenType: this.$route.query.screenType,
  52. tcid2: this.$route.query.tcid,
  53. tcid:"",
  54. showIframe: false,
  55. iframeSrc: "",
  56. courseDetail: {},
  57. pageLoading: false,
  58. inviteCode:"",
  59. startTime: "",
  60. opertimer: null, // 定时器
  61. };
  62. },
  63. methods: {
  64. goTo(path) {
  65. this.$router.push(path);
  66. },
  67. refreshCourse() {
  68. this.getCourseDetail();
  69. },
  70. getCourseDetail() {
  71. this.pageLoading = true;
  72. let params = {
  73. courseId: this.id
  74. };
  75. this.ajax
  76. .get(this.$store.state.api + "selectCourseDetail3", params)
  77. .then(res => {
  78. console.log("getCourseDetail", res);
  79. this.courseDetail = res.data[0][0];
  80. this.courseDetail.chapters = JSON.parse(this.courseDetail.chapters);
  81. this.tcid = this.arrayToArray(
  82. this.courseDetail.juri ? this.courseDetail.juri.split(",") : [],
  83. this.tcid2 ? this.tcid2.split(",") : []
  84. )[0] || "";
  85. if (this.tcid && res.data[1].length) {
  86. let _inviteA = [];
  87. for (var ik = 0; ik < res.data[1].length; ik++) {
  88. _inviteA.push({
  89. cid: res.data[1][ik].classid,
  90. ic: res.data[1][ik].code,
  91. });
  92. }
  93. for (var ik = 0; ik < _inviteA.length; ik++) {
  94. if (
  95. this.arrayToArray(
  96. _inviteA[ik].cid.split(","),
  97. this.tcid.split(",")
  98. ).length
  99. ) {
  100. this.inviteCode = _inviteA[ik].ic;
  101. break;
  102. }
  103. }
  104. }
  105. this.setPptIframe()
  106. this.pageLoading = false;
  107. })
  108. .catch(err => {
  109. console.log(err);
  110. this.$message.error("获取课程数据失败");
  111. this.pageLoading = false;
  112. });
  113. },
  114. setPptIframe() {
  115. this.showIframe = false;
  116. this.$nextTick(() => {
  117. 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}`;
  118. this.iframeSrc = _url;
  119. this.showIframe = true;
  120. });
  121. },
  122. arrayToArray(arrayo, arrayt) {
  123. let array1 = arrayo;
  124. let array2 = arrayt;
  125. let commonElements = [];
  126. for (let i = 0; i < array1.length; i++) {
  127. for (let j = 0; j < array2.length; j++) {
  128. if (array1[i] === array2[j]) {
  129. commonElements.push(array1[i]);
  130. }
  131. }
  132. }
  133. return commonElements;
  134. },
  135. back(){
  136. if(this.tType!=2){
  137. this.goTo(
  138. '/courseDetail?userid=' +
  139. this.userid +
  140. '&oid=' +
  141. this.oid +
  142. '&org=' +
  143. this.org +
  144. '&cid=' +
  145. this.classId +
  146. '&courseId=' +
  147. this.id +
  148. '&tType=' +
  149. this.tType +
  150. '&screenType=' +
  151. this.screenType
  152. )
  153. }else{
  154. this.goTo(
  155. '/index?userid=' +
  156. this.userid +
  157. '&oid=' +
  158. this.oid +
  159. '&org=' +
  160. this.org +
  161. '&cid=' +
  162. this.classId +
  163. '&tType=' +
  164. this.tType +
  165. '&screenType=' +
  166. this.screenType
  167. )
  168. }
  169. },
  170. setOperationTime() {
  171. let _this = this;
  172. if (_this.opertimer) {
  173. clearInterval(_this.opertimer);
  174. _this.opertimer = null;
  175. }
  176. _this.opertimer = setInterval(() => {
  177. _this.setoTime("600");
  178. }, 600000);
  179. },
  180. setoTime(time) {
  181. let params = [
  182. {
  183. uid: this.userid,
  184. cid: this.id,
  185. type: "2",
  186. time: time,
  187. },
  188. ];
  189. this.ajax
  190. .post(this.$store.state.api + "addOperationTimeT2", params)
  191. .then((res) => {})
  192. .catch((err) => {
  193. console.error(err);
  194. });
  195. },
  196. },
  197. destroyed() {
  198. clearInterval(this.opertimer);
  199. this.opertimer = null;
  200. if (this.courseDetail.userid == this.userid && this.org == '16ace517-b5c7-4168-a9bb-a9e0035df840') {
  201. let endTime = new Date().toLocaleString("zh-CN", {
  202. hour12: false,
  203. timeZone: "Asia/Shanghai"
  204. }).replace(/\//g, "-")
  205. let courseTime = Math.max(1, Math.ceil((new Date(endTime) - new Date(this.startTime)) / (1000 * 60)))
  206. this.syncClassData({
  207. courseId: this.id,
  208. title: this.courseDetail.title,
  209. ctitle: this.courseDetail.copyTitle || this.courseDetail.title,
  210. courseGrade: this.tcid2 ? this.tcid2 : '',
  211. courseTime: courseTime,
  212. startTime: this.startTime,
  213. endTime: endTime,
  214. })
  215. console.log('同步数据')
  216. }
  217. },
  218. mounted() {
  219. // this.setoTime("1");
  220. this.startTime = new Date().toLocaleString("zh-CN", {
  221. hour12: false,
  222. timeZone: "Asia/Shanghai"
  223. }).replace(/\//g, "-")
  224. this.getCourseDetail();
  225. this.setOperationTime();
  226. }
  227. };
  228. </script>
  229. <style scoped>
  230. .pptEasyClass {
  231. width: 100vw;
  232. height: 100vh;
  233. display: flex;
  234. flex-direction: column;
  235. overflow: hidden;
  236. box-sizing: border-box;
  237. padding: 20px;
  238. background-color: #f2f2f2;
  239. }
  240. .pec_main {
  241. width: 100%;
  242. height: 100%;
  243. background-color: #fff;
  244. border-radius: 12px;
  245. }
  246. .pec_header {
  247. width: 100%;
  248. height: 80px;
  249. border-radius: 12px 12px 0 0;
  250. box-sizing: border-box;
  251. border-bottom: solid 1px #cad1dc;
  252. display: flex;
  253. align-items: center;
  254. justify-content: space-between;
  255. }
  256. .pec_h_left {
  257. width: auto;
  258. height: 100%;
  259. display: flex;
  260. align-items: center;
  261. justify-content: center;
  262. margin-left: 20px;
  263. font-weight: bold;
  264. font-size: 20px;
  265. color: #0e1e33;
  266. }
  267. .pec_h_right {
  268. width: auto;
  269. height: 100%;
  270. display: flex;
  271. align-items: center;
  272. justify-content: center;
  273. margin-right: 20px;
  274. }
  275. .pec_h_r_btnArea {
  276. display: flex;
  277. align-items: center;
  278. justify-content: center;
  279. }
  280. .pec_h_r_btnArea > div {
  281. width: auto;
  282. height: auto;
  283. display: flex;
  284. align-items: center;
  285. justify-content: center;
  286. padding: 10px 20px;
  287. background-color: #f0f4fa;
  288. border-radius: 4px;
  289. cursor: pointer;
  290. margin-right: 10px;
  291. font-size: 14px;
  292. font-weight: 400;
  293. color: #000;
  294. border: 1px solid #cad1dc;
  295. }
  296. .pec_h_r_btnArea > div > img {
  297. width: 15px;
  298. height: 15px;
  299. margin-right: 5px;
  300. }
  301. .pec_h_r_btnArea > .pec_h_r_btn_refresh {
  302. color: #fff;
  303. background-color: #0061ff;
  304. border-color: #0061ff;
  305. }
  306. .pec_content {
  307. width: 100%;
  308. height: calc(100% - 80px);
  309. border-radius: 0 0 12px 12px;
  310. background-color: #fff;
  311. }
  312. .inviteBox {
  313. font-size: 14px;
  314. /* margin-top: 5px; */
  315. color: #00000099;
  316. text-align: center;
  317. }
  318. </style>