瀏覽代碼

不需要登录进入书籍预览

秦鹏 3 年之前
父節點
當前提交
d6d2415844
共有 3 個文件被更改,包括 321 次插入177 次删除
  1. 180 175
      src/router/index.js
  2. 117 0
      src/views/BookView2.vue
  3. 24 2
      src/views/courseView.vue

+ 180 - 175
src/router/index.js

@@ -30,195 +30,200 @@ Vue.use(Router)
  * all roles can be accessed
  */
 export const constantRoutes = [{
-  path: '/404',
-  component: () =>
-    import('@/views/404'),
-  hidden: true
-},
-{
-  path: '/login',
-  component: () =>
-    import('@/views/login'),
-  hidden: true
-},
-{
-  path: '/EnterSys',
-  beforeEnter: (to, from, next) => {
-    let loadingInstance = Loading.service({
-      text: '跳转中...'
-    });
-    let config = getConfig();
-    if (config) {
-      let configObj = JSON.parse(config);
-      let path = handleSysType(configObj.sys_type, 'home');
-      if (path) {
-        loadingInstance.close();
-        if (configObj.sys_type == 'GCLS') {
-          next(path);
-        } else {
-          window.location.href = path
+        path: '/404',
+        component: () =>
+            import ('@/views/404'),
+        hidden: true
+    },
+    {
+        path: '/login',
+        component: () =>
+            import ('@/views/login'),
+        hidden: true
+    },
+    {
+        path: '/EnterSys',
+        beforeEnter: (to, from, next) => {
+            let loadingInstance = Loading.service({
+                text: '跳转中...'
+            });
+            let config = getConfig();
+            if (config) {
+                let configObj = JSON.parse(config);
+                let path = handleSysType(configObj.sys_type, 'home');
+                if (path) {
+                    loadingInstance.close();
+                    if (configObj.sys_type == 'GCLS') {
+                        next(path);
+                    } else {
+                        window.location.href = path
+                    }
+                } else {
+                    loadingInstance.close();
+                    Message({
+                        message: '此路径不存在',
+                        type: 'error',
+                        showClose: true,
+                        duration: 0
+                    })
+                }
+            }
         }
-      } else {
-        loadingInstance.close();
-        Message({
-          message: '此路径不存在',
-          type: 'error',
-          showClose: true,
-          duration: 0
-        })
-      }
-    }
-  }
-},
-// {
-//   path: '/',
-//   redirect: '/EnterSys',
-//   hidden: true
-// },
-{
-  path: '/input',
-  component: () =>
-    import('@/views/input'),
-  hidden: true
-},
-{
-  path: '/cate',
-  component: () =>
-    import('@/views/catelog'),
-  hidden: true
-},
-{
-  path: '/input2',
-  component: () =>
-    import('@/views/input2'),
-  hidden: true
-},
-{
-  path: '/input3',
-  component: () =>
-    import('@/views/input3'),
-  hidden: true
-},
-{
-  path: '/',
-  component: () =>
-    import('@/views/courseList'),
+    },
+    // {
+    //   path: '/',
+    //   redirect: '/EnterSys',
+    //   hidden: true
+    // },
+    {
+        path: '/input',
+        component: () =>
+            import ('@/views/input'),
+        hidden: true
+    },
+    {
+        path: '/cate',
+        component: () =>
+            import ('@/views/catelog'),
+        hidden: true
+    },
+    {
+        path: '/input2',
+        component: () =>
+            import ('@/views/input2'),
+        hidden: true
+    },
+    {
+        path: '/input3',
+        component: () =>
+            import ('@/views/input3'),
+        hidden: true
+    },
+    {
+        path: '/',
+        component: () =>
+            import ('@/views/courseList'),
 
-},
-{
-  path: '/preview',
-  component: () =>
-    import('@/views/preview')
-},
-{
-  path: '/login',
-  component: () =>
-    import('@/views/login')
-},
-{
-  path: '/courseView',
-  component: () =>
-    import('@/views/courseView')
-},
-{
-  path: '/bookView',
-  component: () =>
-    import('@/views/bookView')
-},
-{
-  path: '/GoodsDetail',
-  beforeEnter: (to, from, next) => {
-    let loadingInstance = Loading.service({
-      text: '跳转中...'
-    });
-    let config = getConfig();
-    if (config) {
-      let configObj = JSON.parse(config);
-      let path = handleSysType(configObj.sys_type, 'goods');
-      if (path) {
-        loadingInstance.close();
-        if (configObj.sys_type == 'GCLS') {
-          next(path);
-        } else {
-          window.location.href = path
+    },
+    {
+        path: '/preview',
+        component: () =>
+            import ('@/views/preview')
+    },
+    {
+        path: '/login',
+        component: () =>
+            import ('@/views/login')
+    },
+    {
+        path: '/courseView',
+        component: () =>
+            import ('@/views/courseView')
+    },
+    {
+        path: '/bookView',
+        component: () =>
+            import ('@/views/bookView')
+    },
+    {
+        path: '/GoodsDetail',
+        beforeEnter: (to, from, next) => {
+            let loadingInstance = Loading.service({
+                text: '跳转中...'
+            });
+            let config = getConfig();
+            if (config) {
+                let configObj = JSON.parse(config);
+                let path = handleSysType(configObj.sys_type, 'goods');
+                if (path) {
+                    loadingInstance.close();
+                    if (configObj.sys_type == 'GCLS') {
+                        next(path);
+                    } else {
+                        window.location.href = path
+                    }
+                } else {
+                    loadingInstance.close();
+                    Message({
+                        message: '此路径不存在',
+                        type: 'error',
+                        showClose: true,
+                        duration: 0
+                    })
+                }
+            }
         }
-      } else {
-        loadingInstance.close();
-        Message({
-          message: '此路径不存在',
-          type: 'error',
-          showClose: true,
-          duration: 0
-        })
-      }
-    }
-  }
-},
-{
-  path: '/curGoodsDetail',
-  component: () =>
-    import('@/views/TextbookDetail')
-},
-{
-  path: '/discountCodeList',
-  component: () =>
-    import('@/views/discountCodeList')
-},
-{
-  path: '/adultInput',
-  component: () =>
-    import('@/views/adultInput')
-},
-{
-  path: '/adultInput2',
-  component: () =>
-    import('@/views/adultInput2')
-},
-// 404 page must be placed at the end !!!
-{ path: '*', redirect: '/', hidden: true }
+    },
+    {
+        path: '/curGoodsDetail',
+        component: () =>
+            import ('@/views/TextbookDetail')
+    },
+    {
+        path: '/discountCodeList',
+        component: () =>
+            import ('@/views/discountCodeList')
+    },
+    {
+        path: '/adultInput',
+        component: () =>
+            import ('@/views/adultInput')
+    },
+    {
+        path: '/adultInput2',
+        component: () =>
+            import ('@/views/adultInput2')
+    },
+    {
+        path: "/bookView2",
+        component: () =>
+            import ('@/views/BookView2')
+    },
+    // 404 page must be placed at the end !!!
+    { path: '*', redirect: '/', hidden: true }
 ]
 
 const createRouter = () =>
-  new Router({
-    // mode: 'history', // require service support
-    scrollBehavior: () => ({ y: 0 }),
-    routes: constantRoutes
-  })
+    new Router({
+        // mode: 'history', // require service support
+        scrollBehavior: () => ({ y: 0 }),
+        routes: constantRoutes
+    })
 
 const router = createRouter()
 
 // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
 export function resetRouter() {
-  const newRouter = createRouter()
-  router.matcher = newRouter.matcher // reset router
+    const newRouter = createRouter()
+    router.matcher = newRouter.matcher // reset router
 }
 export function handleSysType(sys_type, path_type) {
-  let path = '';
-  let csArr = window.location.href.split('?');
-  let cs = csArr[1];
-  switch (sys_type) {
-    case 'GCLS':
-      console.log('全球汉语教学平台')
-      if (path_type == 'home') {
-        path = '/';
-      } else if (path_type == 'goods') {
+    let path = '';
+    let csArr = window.location.href.split('?');
+    let cs = csArr[1];
+    switch (sys_type) {
+        case 'GCLS':
+            console.log('全球汉语教学平台')
+            if (path_type == 'home') {
+                path = '/';
+            } else if (path_type == 'goods') {
 
-        path = '/curGoodsDetail?' + cs
-      }
-      break;
-    case 'AILP':
-      console.log('课后三点半')
-      if (path_type == 'home') {
-        path = '/GCLS-Book-AILP/#/EnterSys';
-      } else if (path_type == 'goods') {
-        path = '/GCLS-Book-AILP/#/GoodsDetail?' + cs;
-      }
-      break;
-    default:
-      path = '';
-      break;
-  }
-  return path;
+                path = '/curGoodsDetail?' + cs
+            }
+            break;
+        case 'AILP':
+            console.log('课后三点半')
+            if (path_type == 'home') {
+                path = '/GCLS-Book-AILP/#/EnterSys';
+            } else if (path_type == 'goods') {
+                path = '/GCLS-Book-AILP/#/GoodsDetail?' + cs;
+            }
+            break;
+        default:
+            path = '';
+            break;
+    }
+    return path;
 }
 
 export default router

+ 117 - 0
src/views/BookView2.vue

@@ -0,0 +1,117 @@
+<template>
+  <div class="bookView2" v-loading="loading">
+    <div>
+      <el-button @click="goperview('book1')">新实用汉语课本1</el-button>
+    </div>
+    <div>
+      <el-button @click="goperview('book2')">发展汉语初级综合(Ⅰ)</el-button>
+    </div>
+    <div>
+      <el-button @click="goperview('book3')">HSK标准教程1</el-button>
+    </div>
+    <!-- <div>
+      <el-button @click="goperview('book4')">新实用汉语</el-button>
+    </div> -->
+  </div>
+</template>
+
+<script>
+//这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
+//例如:import 《组件名称》from ‘《组件路径》';
+import { getStaticContent } from "@/api/ajax";
+import { setToken ,removeToken} from "@/utils/auth";
+
+export default {
+  //import引入的组件需要注入到对象中才能使用
+  components: {},
+  props: {},
+  data() {
+    //这里存放数据
+    return {
+      book1: {
+        name: "新实用汉语课本1",
+        id: "002-20211006-10-NHVOMDLDRY",
+      },
+      book2: {
+        name: "发展汉语初级综合(Ⅰ)",
+        id: "002-20211007-06-4DGL2ZRIB5",
+      },
+      book3: {
+        name: "HSK标准教程1",
+        id: "002-20211007-14-UNYIWU8EKW",
+      },
+      // book4: {
+      //   name: "新实用汉语",
+      //   id: "003-20210908-10-1ZWNGSASZL",
+      // },
+      loading: false,
+    };
+  },
+  //计算属性 类似于data概念
+  computed: {},
+  //监控data中数据变化
+  watch: {},
+  //方法集合
+  methods: {
+    goperview(type) {
+      this.loading = true;
+      let name = "";
+      let id = "";
+      if (type == "book1") {
+        name = this.book1.name;
+        id = this.book1.id;
+      } else if (type == "book2") {
+        name = this.book2.name;
+        id = this.book2.id;
+      } else if (type == "book3") {
+        name = this.book3.name;
+        id = this.book3.id;
+      } else if (type == "book4") {
+        name = this.book4.name;
+        id = this.book4.id;
+      }
+      let codeName = "login_control-CreateTempAccessCode";
+      let access_code = null;
+      getStaticContent(codeName, {}).then((res) => {
+        access_code = res.access_code;
+        let Mname = "login_control-GetLoginInfoByAccessCode";
+        getStaticContent(Mname, {
+          access_code: access_code,
+        }).then((res) => {
+          this.loading = false;
+          setToken(res);
+          // this.$router.push(
+          //   `/courseview?bookId=${id}&name=${name}&type=preview`
+          // );
+        });
+      });
+    },
+  },
+  //生命周期 - 创建完成(可以访问当前this实例)
+  created() {},
+  //生命周期 - 挂载完成(可以访问DOM元素)
+  mounted() {},
+  //生命周期-创建之前
+  beforeCreated() {},
+  //生命周期-挂载之前
+  beforeMount() {},
+  //生命周期-更新之前
+  beforUpdate() {},
+  //生命周期-更新之后
+  updated() {},
+  //生命周期-销毁之前
+  beforeDestory() {},
+  //生命周期-销毁完成
+  destoryed() {},
+  //如果页面有keep-alive缓存功能,这个函数会触发
+  activated() {},
+};
+</script>
+<style lang="scss" scoped>
+/* @import url(); 引入css类 */
+.bookView2 {
+  div {
+    margin-top: 15px;
+  }
+}
+</style>

+ 24 - 2
src/views/courseView.vue

@@ -1,7 +1,14 @@
 <template>
   <div class="container">
-    <Header />
-    <Nav nav-value="书籍预览" />
+    <template v-if="!name">
+      <Header />
+      <Nav nav-value="书籍预览" />
+    </template>
+    <template>
+      <div class="bookname">
+        {{ name }}
+      </div>
+    </template>
     <div class="content">
       <div id="content-tree" class="content-tree">
         <TreeView
@@ -108,11 +115,16 @@ export default {
       category: "",
       FatherTreeData: null,
       themeColor: "",
+      type: "",
+      name: "",
     };
   },
   created() {
     const _this = this;
     _this.bookId = this.$route.query.bookId;
+
+    _this.type = this.$route.query.type;
+    _this.name = this.$route.query.name;
   },
   methods: {
     changeTreeData(val) {
@@ -192,6 +204,16 @@ export default {
 .container {
   width: 100%;
   height: auto;
+  .bookname {
+    width: 100%;
+    height: 60px;
+    display: flex;
+    justify-content: space-between;
+    align-items: center;
+    box-sizing: border-box;
+    padding: 0 46px;
+    background: #f3f7fa;
+  }
   .content {
     width: 100%;
     display: flex;