CourseWarePage.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. <template>
  2. <div>
  3. <el-row>
  4. <el-col :span="1" id="course-page-body">
  5. <el-card style="position: fixed;">
  6. <el-menu default-active="1" @select="handleBack">
  7. <el-menu-item index="0">
  8. <el-icon><Back/></el-icon>
  9. <span style="padding-left: 10px">返回课程</span>
  10. </el-menu-item>
  11. </el-menu>
  12. </el-card>
  13. </el-col>
  14. <el-col :span="20">
  15. <pdf-viewer></pdf-viewer>
  16. </el-col>
  17. </el-row>
  18. </div>
  19. </template>
  20. <script>
  21. import PdfViewer from "./pdf/PdfViewer";
  22. import {SET_SRC, SET_CURRENT_PAGE} from "../../store/types/pdf-types";
  23. import { mapState } from "vuex";
  24. export default {
  25. components: { PdfViewer },
  26. computed: {
  27. ...mapState({
  28. src: state => state.pdf.src,
  29. })
  30. },
  31. props: {
  32. courseWareId: {
  33. required: true,
  34. },
  35. },
  36. data() {
  37. return {
  38. //fileUrl: "https://seec-portal.oss-cn-hangzhou.aliyuncs.com/1/07-%E9%9C%80%E6%B1%82%E6%96%87%E6%A1%A3%E5%8C%96%E4%B8%8E%E9%AA%8C%E8%AF%81.pdf",
  39. };
  40. },
  41. watch: {
  42. $route(to, from) {
  43. window.location.reload(); //监测到路由发生跳转时刷新一次页面
  44. },
  45. },
  46. mounted() {
  47. const params = {
  48. phone: localStorage.phone,
  49. password: localStorage.password
  50. };
  51. // this.$apis.loginAPI(params)
  52. // .then((res) => {
  53. // if (res.data.code === 0) {
  54. // console.log(res);
  55. // if (this.rememberMe) {
  56. // localStorage.phone = this.cardForm.phone;
  57. // localStorage.password = this.cardForm.password;
  58. // localStorage.rememberMe = this.rememberMe;
  59. // this.st="true";//修改登录状态为true
  60. // localStorage.setItem("s",this.st);
  61. // console.log(localStorage);
  62. // } else {
  63. // localStorage.removeItem("rememberMe");
  64. // localStorage.removeItem("phone");
  65. // localStorage.removeItem("password");
  66. // }
  67. //
  68. // //localStorage.setItem("token", res.data.data.token);
  69. //
  70. // this.$store.commit("state_set_user", res.data.data);
  71. // this.$message({
  72. // showClose: true,
  73. // message: "登录成功",
  74. // type: "success",
  75. // duration: 1000,
  76. // });
  77. // // setTimeout(() => {
  78. // // if (!res.data.data.redirectUri) {
  79. // // if (this.$route.params.login_to) {
  80. // // this.$router.push(String(this.$route.params.login_to));
  81. // // } else {
  82. // // this.$router.push("/portal");
  83. // // }
  84. // // } else {
  85. // // let p = new Promise(function (resolve, reject) {
  86. // // setCookie({redirect_uri: ""}, -1);
  87. // // resolve();
  88. // // }).then(r => {
  89. // // window.location.href = res.data.data.redirectUri + "?id_token=" + res.data.data.token;
  90. // // });
  91. // // }
  92. // // }, 500);
  93. // } else {
  94. // this.$message({
  95. // showClose: true,
  96. // message: res.data.message,
  97. // type: "error"
  98. // });
  99. // Object.assign(this.$data, this.$options.data());
  100. // this.$refs.verifier.init();
  101. // }
  102. // })
  103. // .catch((e) => {
  104. // this.$message({
  105. // showClose: true,
  106. // message: e,
  107. // type: "error"
  108. // });
  109. // });
  110. this.$store.commit(SET_CURRENT_PAGE, { currentPage: 1 });
  111. this.$apis.getCourseWareUrlById(this.$route.params.courseWareId).then(res => {
  112. this.$apis.previewpdf(res.data.data).then(res => {
  113. console.log(res);
  114. let blob = new Blob([res.data], {type: "application/pdf;charset=utf-8"});
  115. let href = URL.createObjectURL(blob);
  116. console.log(href);
  117. this.$store.commit(SET_SRC, { src: href });
  118. });
  119. });
  120. },
  121. methods: {
  122. handleBack() {
  123. this.$apis.getCourseIdById(this.$route.params.courseWareId).then(res => {
  124. this.$router.push("/course/" + res.data.data);
  125. });
  126. },
  127. }
  128. };
  129. </script>
  130. <style>
  131. #course-page-body {
  132. margin: 40px 60px 80px 0;
  133. min-height: calc(100vh - 340px);
  134. position: relative;
  135. }
  136. </style>