Browse Source

下载文件

huangxingxing 4 năm trước cách đây
mục cha
commit
910d1b8f8e
1 tập tin đã thay đổi với 23 bổ sung8 xóa
  1. 23 8
      src/views/megagame/topic/details/detailbzs2.vue

+ 23 - 8
src/views/megagame/topic/details/detailbzs2.vue

@@ -61,6 +61,7 @@
           <!-- <li> <a href="../../static/img/afa2.f909997b.jpg" download="test">Bladesign EPBA.doc</a></li> -->
           <li> <a href="/static/download/Bladesign_INTRODUCTION.doc" download="test.doc">Bladesign_INTRODUCTION.doc</a></li>
           <li><a href="/public/Bladesign_ReportTemp.docx"  download="test.docx">Bladesign_ReportTemp.docx</a></li>
+          <el-button @click="dow('b56e35a3c38d4fdf9d22ad27a8b45733')">下载_xxx</el-button>
         </ul>
       <el-button type="text" @click="download('Bladesign_ReportTemp.docx','Bladesign.docx')">下载</el-button>
    
@@ -72,6 +73,8 @@
 
 <script>
 import DetailLayout from '../components/DetailLayout'
+import { download,getToken } from '@/utils/request'
+import store from '@/store'
 //import a from '/static/download/1.docx'
 
 export default {
@@ -86,14 +89,26 @@ export default {
   created() {},
   mounted() {},
   methods: {
-     download(filename,name){
-    let a = document.createElement('a');
-    a.href = '/static/download/'+filename;
-    //路径中'/'为根目录,即index.html所在的目录
-    a.download = name;
-   console.log( a.href);
-    a.click()
-  },
+    dow(fileId){
+     // Request URL: http://localhost:8081/api/TransServlet?transCode=B00022&clientToken=d192a6df440544ef9bc63f274a1cb336&id=b7b4532a3085457a9d7260439ae00005
+        const params = {
+        transCode: 'B00022',    
+        clientToken: store.getters.token || getToken(),
+        id: fileId, // 每个题目的数据id
+        uid: this.$store.getters.userId,
+      }
+     download(params);
+    }
+    // download(filename,name){
+    //   let a = document.createElement('a');
+    //   a.href = '/static/download/'+filename;
+    //   //路径中'/'为根目录,即index.html所在的目录
+    //   a.download = name;
+    //   console.log( a.href);
+    //   a.click()
+    // },
+       
+
   },
 }
 </script>