BookView2.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <div class="bookView2" v-loading="loading">
  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: "新实用汉语课本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. loading: false,
  46. };
  47. },
  48. //计算属性 类似于data概念
  49. computed: {},
  50. //监控data中数据变化
  51. watch: {},
  52. //方法集合
  53. methods: {
  54. goperview(type) {
  55. this.loading = true;
  56. let name = "";
  57. let id = "";
  58. if (type == "book1") {
  59. name = this.book1.name;
  60. id = this.book1.id;
  61. } else if (type == "book2") {
  62. name = this.book2.name;
  63. id = this.book2.id;
  64. } else if (type == "book3") {
  65. name = this.book3.name;
  66. id = this.book3.id;
  67. } else if (type == "book4") {
  68. name = this.book4.name;
  69. id = this.book4.id;
  70. }
  71. let codeName = "login_control-CreateTempAccessCode";
  72. let access_code = null;
  73. getStaticContent(codeName, {}).then((res) => {
  74. access_code = res.access_code;
  75. let Mname = "login_control-GetLoginInfoByAccessCode";
  76. getStaticContent(Mname, {
  77. access_code: access_code,
  78. }).then((res) => {
  79. this.loading = false;
  80. setToken(res);
  81. this.$router.push(
  82. `/courseview?bookId=${id}&name=${name}&type=preview`
  83. );
  84. });
  85. });
  86. },
  87. },
  88. //生命周期 - 创建完成(可以访问当前this实例)
  89. created() {},
  90. //生命周期 - 挂载完成(可以访问DOM元素)
  91. mounted() {},
  92. //生命周期-创建之前
  93. beforeCreated() {},
  94. //生命周期-挂载之前
  95. beforeMount() {},
  96. //生命周期-更新之前
  97. beforUpdate() {},
  98. //生命周期-更新之后
  99. updated() {},
  100. //生命周期-销毁之前
  101. beforeDestory() {},
  102. //生命周期-销毁完成
  103. destoryed() {},
  104. //如果页面有keep-alive缓存功能,这个函数会触发
  105. activated() {},
  106. };
  107. </script>
  108. <style lang="scss" scoped>
  109. /* @import url(); 引入css类 */
  110. .bookView2 {
  111. padding-left: 30px;
  112. div {
  113. margin-top: 15px;
  114. }
  115. }
  116. </style>