CourseWarePage.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. mounted() {
  42. const params = {
  43. phone: localStorage.phone,
  44. password: localStorage.password
  45. };
  46. // this.$apis.loginAPI(params)
  47. // .then((res) => {
  48. // if (res.data.code === 0) {
  49. // console.log(res);
  50. // if (this.rememberMe) {
  51. // localStorage.phone = this.cardForm.phone;
  52. // localStorage.password = this.cardForm.password;
  53. // localStorage.rememberMe = this.rememberMe;
  54. // this.st="true";//修改登录状态为true
  55. // localStorage.setItem("s",this.st);
  56. // console.log(localStorage);
  57. // } else {
  58. // localStorage.removeItem("rememberMe");
  59. // localStorage.removeItem("phone");
  60. // localStorage.removeItem("password");
  61. // }
  62. //
  63. // //localStorage.setItem("token", res.data.data.token);
  64. //
  65. // this.$store.commit("state_set_user", res.data.data);
  66. // this.$message({
  67. // showClose: true,
  68. // message: "登录成功",
  69. // type: "success",
  70. // duration: 1000,
  71. // });
  72. // // setTimeout(() => {
  73. // // if (!res.data.data.redirectUri) {
  74. // // if (this.$route.params.login_to) {
  75. // // this.$router.push(String(this.$route.params.login_to));
  76. // // } else {
  77. // // this.$router.push("/portal");
  78. // // }
  79. // // } else {
  80. // // let p = new Promise(function (resolve, reject) {
  81. // // setCookie({redirect_uri: ""}, -1);
  82. // // resolve();
  83. // // }).then(r => {
  84. // // window.location.href = res.data.data.redirectUri + "?id_token=" + res.data.data.token;
  85. // // });
  86. // // }
  87. // // }, 500);
  88. // } else {
  89. // this.$message({
  90. // showClose: true,
  91. // message: res.data.message,
  92. // type: "error"
  93. // });
  94. // Object.assign(this.$data, this.$options.data());
  95. // this.$refs.verifier.init();
  96. // }
  97. // })
  98. // .catch((e) => {
  99. // this.$message({
  100. // showClose: true,
  101. // message: e,
  102. // type: "error"
  103. // });
  104. // });
  105. this.$store.commit(SET_CURRENT_PAGE, { currentPage: 1 });
  106. this.$apis.getCourseWareUrlById(this.$route.params.courseWareId).then(res => {
  107. this.$apis.previewpdf(res.data.data).then(res => {
  108. console.log(res);
  109. let blob = new Blob([res.data], {type: "application/pdf;charset=utf-8"});
  110. let href = URL.createObjectURL(blob);
  111. console.log(href);
  112. this.$store.commit(SET_SRC, { src: href });
  113. });
  114. });
  115. },
  116. methods: {
  117. handleBack() {
  118. this.$apis.getCourseIdById(this.$route.params.courseWareId).then(res => {
  119. this.$router.push("/course/" + res.data.data);
  120. });
  121. },
  122. }
  123. };
  124. </script>
  125. <style>
  126. #course-page-body {
  127. margin: 40px 60px 80px 0;
  128. min-height: calc(100vh - 340px);
  129. position: relative;
  130. }
  131. </style>