Browse Source

下载资源文件

natasha 1 năm trước cách đây
mục cha
commit
1025bb5fdf

+ 10 - 0
src/icons/svg/no-read.svg

@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3552_54410)">
+<path d="M7.9987 14.6654C4.3168 14.6654 1.33203 11.6806 1.33203 7.9987C1.33203 4.3168 4.3168 1.33203 7.9987 1.33203C11.6806 1.33203 14.6654 4.3168 14.6654 7.9987C14.6654 11.6806 11.6806 14.6654 7.9987 14.6654ZM7.9987 13.332C10.9442 13.332 13.332 10.9442 13.332 7.9987C13.332 5.05318 10.9442 2.66536 7.9987 2.66536C5.05318 2.66536 2.66536 5.05318 2.66536 7.9987C2.66536 10.9442 5.05318 13.332 7.9987 13.332Z" fill="black" fill-opacity="0.88"/>
+</g>
+<defs>
+<clipPath id="clip0_3552_54410">
+<rect width="16" height="16" rx="4" fill="white"/>
+</clipPath>
+</defs>
+</svg>

+ 10 - 0
src/icons/svg/oppose.svg

@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_3552_54400)">
+<path d="M6.26808 10.6667H2.0013C1.26492 10.6667 0.667969 10.0697 0.667969 9.33333V7.93047C0.667969 7.75627 0.702089 7.5838 0.768395 7.4228L2.83131 2.41283C2.93417 2.16303 3.17762 2 3.44776 2H14.668C15.0362 2 15.3346 2.29848 15.3346 2.66667V9.33333C15.3346 9.70153 15.0362 10 14.668 10H12.3468C12.1301 10 11.927 10.1053 11.8021 10.2822L8.1665 15.4327C8.0715 15.5672 7.89243 15.6123 7.7451 15.5385L6.53572 14.9339C5.83462 14.5833 5.47255 13.7916 5.66593 13.032L6.26808 10.6667ZM11.3346 8.94167V3.33333H3.89423L2.0013 7.93047V9.33333H6.26808C7.1379 9.33333 7.77477 10.1527 7.56024 10.9956L6.95803 13.3609C6.91937 13.5129 6.99177 13.6712 7.13204 13.7413L7.57277 13.9617L10.7128 9.51333C10.8794 9.27727 11.0924 9.0838 11.3346 8.94167ZM12.668 8.66667H14.0013V3.33333H12.668V8.66667Z" fill="currentColor" fill-opacity="0.56"/>
+</g>
+<defs>
+<clipPath id="clip0_3552_54400">
+<rect width="16" height="16" rx="4" fill="white"/>
+</clipPath>
+</defs>
+</svg>

+ 10 - 0
src/icons/svg/readed.svg

@@ -0,0 +1,10 @@
+<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
+<g clip-path="url(#clip0_2553_100312)">
+<path d="M8.00065 14.6668C4.31875 14.6668 1.33398 11.682 1.33398 8.00016C1.33398 4.31826 4.31875 1.3335 8.00065 1.3335C11.6825 1.3335 14.6673 4.31826 14.6673 8.00016C14.6673 11.682 11.6825 14.6668 8.00065 14.6668ZM8.00065 13.3335C10.9462 13.3335 13.334 10.9457 13.334 8.00016C13.334 5.05464 10.9462 2.66683 8.00065 2.66683C5.05513 2.66683 2.66732 5.05464 2.66732 8.00016C2.66732 10.9457 5.05513 13.3335 8.00065 13.3335ZM7.33572 10.6668L4.50731 7.83843L5.45012 6.89556L7.33572 8.78123L11.107 5.00998L12.0498 5.95278L7.33572 10.6668Z" fill="#175DFF"/>
+</g>
+<defs>
+<clipPath id="clip0_2553_100312">
+<rect width="16" height="16" rx="4" fill="white"/>
+</clipPath>
+</defs>
+</svg>

+ 9 - 0
src/views/bookShelf/articlePeruseDetail.vue

@@ -32,7 +32,11 @@
                 </div>
             </div>
         </div>
+        <div class="article-bottom">
+
+        </div>
     </div>
+    <a></a>
   </div>
 </template>
 
@@ -259,6 +263,7 @@ export default {
 <style lang="scss" scoped>
 .bookStore{
     min-height: calc(100vh - 64px);
+    padding-bottom: 10px;
     .navBar-right{
         display: flex;
         align-items: center;
@@ -365,6 +370,10 @@ export default {
                 margin: 24px 0;
             }
         }
+        .article-bottom{
+            padding: 16px;
+            background: #F7F8FA;
+        }
     }
 }
 </style>

+ 68 - 12
src/views/bookShelf/components/ResourcesList.vue

@@ -1,6 +1,6 @@
 <template>
-  <div class="resource-list" v-if="list">
-    <a class="package-download"><svg-icon icon-class="download" class="icon-download"></svg-icon>打包下载</a>
+  <div class="resource-list" v-if="list" v-loading="loading">
+    <a class="package-download" @click="allDownload"><svg-icon icon-class="download" class="icon-download"></svg-icon>打包下载</a>
     <ul class="resource-box">
         <li :class="['item-'+type]" v-for="(item,index) in list" :key="index" :title="item.name" 
             :style="{
@@ -19,6 +19,7 @@
 //这里可以导入其它文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
 //例如:import 《组件名称》from ‘《组件路径》';
 import { getToken } from '@/utils/auth'
+import { getLogin } from "@/api/ajax";
 export default {
   //import引入的组件需要注入到对象中才能使用
   components: { },
@@ -26,7 +27,8 @@ export default {
   data() {
     //这里存放数据
     return {
-        list: []
+        list: [],
+        loading: false
     }
   },
   //计算属性 类似于data概念
@@ -76,22 +78,76 @@ export default {
         }
         return finalType
     },
-    // 下载图片
+    // 下载单个文件
     handleDownloadPic(item){
         let userInfor = getToken();
         let access_token = "";
         if (userInfor) {
             let user = JSON.parse(getToken());
             access_token = user.access_token;
+            let FileID = item.file_id
+            let data = {
+                access_token,
+                FileID
+            };
+            let href = process.env.VUE_APP_BASE_API +
+                `/FileServer/WebFileDownload?AccessToken=${data.access_token}&FileID=${data.FileID}`;
+            window.open(href)
+        }else{
+            this.$message.warning('请先登录')
+        }
+    },
+    // 打包下载
+    allDownload() {
+      let _this = this;
+      // 拿到当前课的所有文件id
+      let userInfor = getToken();
+        let access_token = "";
+        if (userInfor) {
+            _this.loading = true;
+            let user = JSON.parse(getToken());
+            access_token = user.access_token;
+            let FileID = null;
+            let data = {
+                access_token,
+                FileID,
+            };
+            let arr = [];
+            _this.list.forEach((item) => {
+                arr.push(`${item.file_id}`);
+            });
+            let MethodName = "/FileServer/FilePackManager/StartCreateFileCompressPack";
+            getLogin(MethodName, {
+                file_id_list: arr,
+            })
+            .then((res) => {
+            let MethodName2 = "/FileServer/FilePackManager/GetFileCompressTaskProgress";
+            let timer = setTimeout(() => {
+                getLogin(MethodName2, {
+                    file_compress_task_id: res.file_compress_task_id,
+                })
+                .then((res) => {
+                    if (res.is_finish == "true") {
+                        data.FileID = res.compress_pack_file_id;
+                        clearTimeout(timer);
+                        timer = null;
+                        _this.loading = false;
+                        location.href =
+                            process.env.VUE_APP_BASE_API +
+                            `/FileServer/WebFileDownload?AccessToken=${data.access_token}&FileID=${data.FileID}`;
+                        }
+                })
+                .catch((res) => {
+                    this.loading = false;
+                });
+            }, 1000);
+            })
+            .catch((res) => {
+                this.loading = false;
+            });
+        }else{
+            this.$message.warning('请先登录')
         }
-        let FileID = item.file_id
-        let data = {
-            access_token,
-            FileID
-        };
-        let href = process.env.VUE_APP_BASE_API +
-            `/FileServer/WebFileDownload?AccessToken=${data.access_token}&FileID=${data.FileID}`;
-        window.open(href)
     },
   },
   //生命周期 - 创建完成(可以访问当前this实例)