BookView2.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <template>
  2. <div class="bookView2">
  3. <!-- <div>
  4. <el-button @click="goperview('book1')">新实用汉语课本1</el-button>
  5. </div>
  6. <div>
  7. <el-button @click="goperview('book2')">发展汉语初级综合(Ⅰ)</el-button>
  8. </div>
  9. <div>
  10. <el-button @click="goperview('book3')">HSK标准教程1</el-button>
  11. </div> -->
  12. <!-- <div>
  13. <el-button @click="goperview('book4')">新实用汉语</el-button>
  14. </div> -->
  15. </div>
  16. </template>
  17. <script>
  18. //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  19. //例如:import 《组件名称》from ‘《组件路径》';
  20. import { getStaticContent } from "@/api/ajax";
  21. import { setToken, removeToken } from "@/utils/auth";
  22. export default {
  23. //import引入的组件需要注入到对象中才能使用
  24. components: {},
  25. props: {},
  26. data() {
  27. //这里存放数据
  28. return {
  29. book1: {
  30. name: "新实用汉语课本(第3版)第1册",
  31. id: "002-20211006-10-NHVOMDLDRY",
  32. },
  33. book2: {
  34. name: "发展汉语初级综合(Ⅰ)",
  35. id: "002-20211007-06-4DGL2ZRIB5",
  36. },
  37. book3: {
  38. name: "HSK标准教程1",
  39. id: "002-20211007-14-UNYIWU8EKW",
  40. },
  41. book4: {
  42. name: "新实用汉语",
  43. id: "003-20210908-10-1ZWNGSASZL",
  44. },
  45. book5: {
  46. name: "新航标职业英语 综合英语(基础级)学生用书1(修订版)",
  47. id: "002-20211029-14-9VGMXLV2NU",
  48. },
  49. book6: {
  50. name: "新航标职业英语",
  51. id: "002-20211011-10-GOLXUZST4G",
  52. },
  53. loading: null,
  54. };
  55. },
  56. //计算属性 类似于data概念
  57. computed: {},
  58. //监控data中数据变化
  59. watch: {},
  60. //方法集合
  61. methods: {
  62. goperview(type) {
  63. this.loading = true;
  64. let name = "";
  65. let id = "";
  66. if (type == "book1") {
  67. name = this.book1.name;
  68. id = this.book1.id;
  69. } else if (type == "book2") {
  70. name = this.book2.name;
  71. id = this.book2.id;
  72. } else if (type == "book3") {
  73. name = this.book3.name;
  74. id = this.book3.id;
  75. } else if (type == "book4") {
  76. name = this.book4.name;
  77. id = this.book4.id;
  78. } else if (type == "book5") {
  79. name = this.book5.name;
  80. id = this.book5.id;
  81. } else if (type == "book6") {
  82. name = this.book6.name;
  83. id = this.book6.id;
  84. }
  85. let codeName = "login_control-CreateTempAccessCode";
  86. let access_code = null;
  87. getStaticContent(codeName, {}).then((res) => {
  88. access_code = res.access_code;
  89. let Mname = "login_control-GetLoginInfoByAccessCode";
  90. getStaticContent(Mname, {
  91. access_code: access_code,
  92. }).then((res) => {
  93. this.loading = false;
  94. setToken(res);
  95. this.$router.push(
  96. `/courseview?bookId=${id}&name=${name}&type=preview`
  97. );
  98. });
  99. });
  100. },
  101. },
  102. //生命周期 - 创建完成(可以访问当前this实例)
  103. created() {
  104. this.loading = this.$loading({
  105. lock: true,
  106. text: "跳转中",
  107. spinner: "el-icon-loading",
  108. background: "rgba(0, 0, 0, 0.7)",
  109. });
  110. let codeName = "login_control-CreateTempAccessCode";
  111. let access_code = null;
  112. let id = this.$route.query.bookId;
  113. getStaticContent(codeName, {}).then((res) => {
  114. access_code = res.access_code;
  115. let Mname = "login_control-GetLoginInfoByAccessCode";
  116. getStaticContent(Mname, {
  117. access_code: access_code,
  118. }).then((res) => {
  119. this.loading.close();
  120. setToken(res);
  121. this.$router.push(`/courseview?bookId=${id}&type=preview`);
  122. });
  123. });
  124. },
  125. //生命周期 - 挂载完成(可以访问DOM元素)
  126. mounted() {},
  127. //生命周期-创建之前
  128. beforeCreated() {},
  129. //生命周期-挂载之前
  130. beforeMount() {},
  131. //生命周期-更新之前
  132. beforUpdate() {},
  133. //生命周期-更新之后
  134. updated() {},
  135. //生命周期-销毁之前
  136. beforeDestory() {},
  137. //生命周期-销毁完成
  138. destoryed() {},
  139. //如果页面有keep-alive缓存功能,这个函数会触发
  140. activated() {},
  141. };
  142. </script>
  143. <style lang="scss" scoped>
  144. /* @import url(); 引入css类 */
  145. .bookView2 {
  146. width: 100%;
  147. height: 100vh;
  148. padding-left: 30px;
  149. div {
  150. margin-top: 15px;
  151. }
  152. }
  153. </style>