Browse Source

对接一书一码

natasha 5 months ago
parent
commit
b2fda94036
5 changed files with 68 additions and 4 deletions
  1. 7 1
      src/api/ajax.js
  2. 3 3
      src/permission.js
  3. 6 0
      src/router/index.js
  4. 43 0
      src/views/bookOBOCView.vue
  5. 9 0
      src/views/courseView.vue

+ 7 - 1
src/api/ajax.js

@@ -24,7 +24,13 @@ export function getContens(MethodName, data, AccessToken, AppID) {
     data
   })
 }
-
+export function GCLSBookServer(MethodName, data){
+return request({
+    url: `/GCLSBookServer/ServiceInterface?MethodName=${MethodName}`,
+    method: 'post',
+    data
+  })
+}
 export function getLogin(MethodName, data) {
   const userInfor = getToken()
   let UserCode = ''

+ 3 - 3
src/permission.js

@@ -8,7 +8,7 @@ import getPageTitle from '@/utils/get-page-title'
 
 NProgress.configure({ showSpinner: false }) // NProgress Configuration
 
-const whiteList = ['/login', '/BookBrowsing'] // no redirect whitelist
+const whiteList = ['/login', '/BookBrowsing', '/BookOBOCView'] // no redirect whitelist
 
 router.beforeEach(async(to, from, next) => {
   // start progress bar
@@ -18,9 +18,9 @@ router.beforeEach(async(to, from, next) => {
   // next();
   NProgress.done()
   const hasToken = getToken()
-  if (hasToken || to.path === '/BookBrowsing' || to.path === '/courseview' || to.path === '/Integration/Courseware') {
+  if (hasToken || to.path === '/BookBrowsing' || to.path === '/courseview' || to.path === '/Integration/Courseware' || to.path === '/BookOBOCView') {
     const config = getConfig()
-    if (config || to.path === '/BookBrowsing' || to.path === '/courseview' || to.path === '/Integration/Courseware') {
+    if (config || to.path === '/BookBrowsing' || to.path === '/courseview' || to.path === '/Integration/Courseware' || to.path === '/BookOBOCView') {
       if (to.path === '/login') {
         // if is logged in, redirect to the home page
         next({ path: '/EnterSys' })

+ 6 - 0
src/router/index.js

@@ -199,6 +199,12 @@ export const constantRoutes = [{
   name: 'courseware',
   component: () =>
     import ('@/views/courseWare')
+  },
+{
+  path: '/BookOBOCView',
+  name: 'BookOBOCView',
+  component: () =>
+    import ('@/views/bookOBOCView.vue')
 },
 
 // 404 page must be placed at the end !!!

+ 43 - 0
src/views/bookOBOCView.vue

@@ -0,0 +1,43 @@
+<template></template>
+
+<script>
+import { GCLSBookServer, getStaticContent } from "@/api/ajax";
+import { setToken } from "@/utils/auth";
+export default {
+  name: "BookOBOCView",
+  components: {},
+  props: [],
+  data() {
+    return {};
+  },
+  mounted() {},
+  created() {
+    GCLSBookServer("oboc-CheckIdentityCode", {
+      identity_code: this.$route.query.IdentityCode,
+      check_code: this.$route.query.CheckCode,
+      app_id: this.$route.query.AppID,
+      user_name: this.$route.query.UserName,
+    })
+      .then((res) => {
+        if (res.status === 1) {
+          let id = res.book_id;
+          let Mname = "login_control-ParseAccessToken";
+          getStaticContent(Mname, {
+            access_code: res.access_token,
+          }).then((res) => {
+            setToken(res);
+            this.$router.push(
+              `/courseview?bookId=${id}&type=preview&fromPage=OBOC`
+            );
+          });
+        }
+      })
+      .catch((res) => {
+        _this.$message({
+          message: res.error,
+          type: "warning",
+        });
+      });
+  },
+};
+</script>

+ 9 - 0
src/views/courseView.vue

@@ -353,6 +353,15 @@ export default {
     } else if (_this.$route.query.showCourse) {
       _this.bookId = this.$route.query.bookId;
       this.showContent = true;
+    } else if (_this.$route.query.fromPage === "OBOC") {
+      const MethodName = "book-book_manager-GetBook";
+      const data = {
+        id: _this.$route.query.bookId,
+      };
+      getContent(MethodName, data).then((res) => {
+        this.showContent = true;
+        _this.name = res.name;
+      });
     } else {
       _this.$message({
         message: "链接已失效",