Ver Fonte

临时链接有效期

natasha há 2 anos atrás
pai
commit
b2efecea24
3 ficheiros alterados com 97 adições e 20 exclusões
  1. 2 1
      src/views/BookView2.vue
  2. 61 2
      src/views/courseList.vue
  3. 34 17
      src/views/courseView.vue

+ 2 - 1
src/views/BookView2.vue

@@ -113,6 +113,7 @@ export default {
     let codeName = "login_control-CreateTempAccessCode";
     let codeName = "login_control-CreateTempAccessCode";
     let access_code = null;
     let access_code = null;
     let id = this.$route.query.bookId;
     let id = this.$route.query.bookId;
+    let encryption = this.$route.query.encryption
     getStaticContent(codeName, {}).then((res) => {
     getStaticContent(codeName, {}).then((res) => {
       access_code = res.access_code;
       access_code = res.access_code;
       let Mname = "login_control-GetLoginInfoByAccessCode";
       let Mname = "login_control-GetLoginInfoByAccessCode";
@@ -121,7 +122,7 @@ export default {
       }).then((res) => {
       }).then((res) => {
         this.loading.close();
         this.loading.close();
         setToken(res);
         setToken(res);
-        this.$router.push(`/courseview?bookId=${id}&type=preview`);
+        this.$router.push(`/courseview?bookId=${id}&type=preview&encryption=${encryption}`);
       });
       });
     });
     });
   },
   },

+ 61 - 2
src/views/courseList.vue

@@ -124,7 +124,7 @@
               prop="publish_scope"
               prop="publish_scope"
               width="100"
               width="100"
             ></el-table-column>
             ></el-table-column>
-            <el-table-column fixed="right" label="操作" prop width="300">
+            <el-table-column fixed="right" label="操作" prop width="370">
               <template slot-scope="scope">
               <template slot-scope="scope">
                 <el-button @click="handleClick(scope.row)" type="text"
                 <el-button @click="handleClick(scope.row)" type="text"
                   >编辑</el-button
                   >编辑</el-button
@@ -147,6 +147,9 @@
                 <el-button @click="handleDiscount(scope.row)" type="text"
                 <el-button @click="handleDiscount(scope.row)" type="text"
                   >激活码</el-button
                   >激活码</el-button
                 >
                 >
+                <el-button type="text" @click="handleCreatLink(scope.row)"
+                  >生成链接</el-button
+                >
                 <el-button @click="handleDel(scope.row)" type="text"
                 <el-button @click="handleDel(scope.row)" type="text"
                   >删除</el-button
                   >删除</el-button
                 >
                 >
@@ -165,6 +168,16 @@
           layout="total, sizes, prev, pager, next, jumper"
           layout="total, sizes, prev, pager, next, jumper"
         ></el-pagination>
         ></el-pagination>
       </div>
       </div>
+      <div
+        id="temporaryLinks"
+        style="
+          height: 0;
+          width: 1200px;
+          opacity: 0;
+          z-index: -1;
+          word-break: break-all;
+        "
+      ></div>
     </div>
     </div>
     <el-dialog
     <el-dialog
       :before-close="handleClose"
       :before-close="handleClose"
@@ -582,6 +595,52 @@ export default {
     handleDiscount(row) {
     handleDiscount(row) {
       this.$router.push("/discountCodeList?bookId=" + row.id);
       this.$router.push("/discountCodeList?bookId=" + row.id);
     },
     },
+    // 生成临时链接
+    handleCreatLink(row) {
+        var date1 = new Date(); 
+        var date2 = new Date(date1); 
+        date2.setDate(date1.getDate() + 30); 
+        let endtime = date2.getFullYear() + "-" + (date2.getMonth() + 1) + "-" + date2.getDate()
+        getContentFile('login_control-CreateValidDateEncryptionString', {
+            end_date: endtime,
+        })
+            .then((res) => {
+                let link =
+                    "https://" +
+                    window.location.host +
+                    "/GCLS-Book/#/BookBrowsing?bookId=" +
+                    row.id+"&encryption="+res.encryption_string;
+                document.getElementById("temporaryLinks").innerHTML = link;
+                var doc = document,
+                    text = doc.getElementById("temporaryLinks"),
+                    range,
+                    selection;
+                if (doc.body.createTextRange) {
+                    range = doc.body.createTextRange();
+                    range.moveToElementText(text);
+                    range.select();
+                } else if (window.getSelection) {
+                    selection = window.getSelection();
+                    range = doc.createRange();
+                    range.selectNodeContents(text);
+                    selection.removeAllRanges();
+                    selection.addRange(range);
+                }
+                document.execCommand("copy");
+                this.$message({
+                    message: "复制成功",
+                    type: "success",
+                });
+                window.getSelection().removeAllRanges();
+            })
+            .catch(() => {
+                this.$message({
+                    message: "生成失败,请稍后重试",
+                    type: "warning",
+                });
+            });
+      
+    },
     // 新建教材
     // 新建教材
     handleAdd() {
     handleAdd() {
       this.titleEdit = "新建教材";
       this.titleEdit = "新建教材";
@@ -1004,4 +1063,4 @@ export default {
 .el-dialog {
 .el-dialog {
   font-size: 0;
   font-size: 0;
 }
 }
-</style>
+</style>

+ 34 - 17
src/views/courseView.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-  <div class="container GCLS-BOOK-Container">
+  <div class="container GCLS-BOOK-Container" v-if="showContent">
     <div v-if="!type" class="header-box">
     <div v-if="!type" class="header-box">
       <Header />
       <Header />
       <Nav nav-value="书籍预览" />
       <Nav nav-value="书籍预览" />
@@ -125,7 +125,7 @@
 import Header from "@/components/inputModules/common/Header";
 import Header from "@/components/inputModules/common/Header";
 import Nav from "@/components/inputModules/common/Nav";
 import Nav from "@/components/inputModules/common/Nav";
 import TreeView from "@/components/inputModules/common/TreeView";
 import TreeView from "@/components/inputModules/common/TreeView";
-import { getContent } from "@/api/ajax";
+import { getContent,getLogin } from "@/api/ajax";
 import Cookies from "js-cookie";
 import Cookies from "js-cookie";
 // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
 // import Preview from '@/componentsAnswer/PreviewAnswer.vue'
 import Preview from "@/components/Preview";
 import Preview from "@/components/Preview";
@@ -177,6 +177,7 @@ export default {
       name: "",
       name: "",
       loading: false,
       loading: false,
       bookFontSize: "",
       bookFontSize: "",
+      showContent:false,
       bookName: [
       bookName: [
         {
         {
           name: "新实用汉语课本1",
           name: "新实用汉语课本1",
@@ -239,21 +240,37 @@ export default {
   },
   },
   created() {
   created() {
     const _this = this;
     const _this = this;
-    _this.bookId = this.$route.query.bookId;
-
-    _this.type = this.$route.query.type;
-    // _this.bookName.forEach((item) => {
-    //   if (item.id == _this.bookId) {
-    //     _this.name = item.name;
-    //   }
-    // });
-    const MethodName = "book-book_manager-GetBook";
-    const data = {
-      id: _this.bookId,
-    };
-    getContent(MethodName, data).then((res) => {
-      _this.name = res.name;
-    });
+    if(_this.$route.query.encryption&&_this.$route.query.encryption!='undefined'&&_this.$route.query.type){
+        getLogin('login_control-CheckValidDateEncryptionString', {encryption_string:_this.$route.query.encryption}).then((res) => {
+            if(res.is_check_pass=='true'){
+                _this.bookId = this.$route.query.bookId;
+                _this.type = this.$route.query.type;
+                const MethodName = "book-book_manager-GetBook";
+                const data = {
+                    id: _this.bookId,
+                };
+                getContent(MethodName, data).then((res) => {
+                    this.showContent = true
+                    _this.name = res.name;
+                });
+            }else{
+                _this.$message({
+                    message: "链接已失效",
+                    type: "warning",
+                });
+            }
+        }).catch(()=>{
+            _this.$message({
+                message: "链接已失效",
+                type: "warning",
+            });
+        });
+    }else {
+        _this.$message({
+            message: "链接已失效",
+            type: "warning",
+        });
+    }
   },
   },
   mounted() {},
   mounted() {},
   methods: {
   methods: {