From 7fd5c1c66171b700ed3f4a68c33fd9b90d35451b Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期五, 23 一月 2026 16:38:54 +0800
Subject: [PATCH] 

---
 src/pages/managementMeetings/rulesRegulationsManagement/fileList.vue |  116 ++++++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 80 insertions(+), 36 deletions(-)

diff --git a/src/pages/managementMeetings/rulesRegulationsManagement/fileList.vue b/src/pages/managementMeetings/rulesRegulationsManagement/fileList.vue
index c31e39b..3105e4e 100644
--- a/src/pages/managementMeetings/rulesRegulationsManagement/fileList.vue
+++ b/src/pages/managementMeetings/rulesRegulationsManagement/fileList.vue
@@ -31,7 +31,7 @@
             <u-button size="small"
                       type="info"
                       plain
-                      @click="downloadFile(file)">涓嬭浇</u-button>
+                      @click="downloadFile(file)">涓嬭浇骞堕瑙�</u-button>
             <u-button size="small"
                       type="error"
                       plain
@@ -48,10 +48,10 @@
         <text class="empty-text">鏆傛棤闄勪欢</text>
       </view>
     </view>
-    <a rel="nofollow"
+    <!-- <a rel="nofollow"
        id="downloadLink"
        href="#"
-       style="display:none;">涓嬭浇鏂囨湰鏂囦欢</a>
+       style="display:none;">涓嬭浇鏂囨湰鏂囦欢</a> -->
     <!-- 涓婁紶鎸夐挳 -->
     <view class="upload-button"
           @click="chooseFile">
@@ -68,8 +68,6 @@
   import PageHeader from "@/components/PageHeader.vue";
   import config from "@/config";
   import { getToken } from "@/utils/auth";
-  import axios from "axios";
-  import requestApp from "@/utils/requestApp";
   // import { saveAs } from "file-saver";
   import {
     listRuleFiles,
@@ -143,18 +141,19 @@
 
   // 閫夋嫨鏂囦欢
   const chooseFile = () => {
-    // uni.chooseImage({
-    //   count: 9,
-    //   sizeType: ["original", "compressed"],
-    //   sourceType: ["album", "camera"],
-    //   success: res => {
-    //     uploadFiles(res.tempFiles);
-    //   },
-    //   fail: err => {
-    //     console.error("閫夋嫨鍥剧墖澶辫触:", err);
-    //     showToast("閫夋嫨鏂囦欢澶辫触");
-    //   },
-    // });
+    uni.chooseImage({
+      count: 9,
+      sizeType: ["original", "compressed"],
+      sourceType: ["album", "camera"],
+      success: res => {
+        console.log(res, "閫夋嫨鍥剧墖鎴愬姛");
+        uploadFiles(res.tempFiles);
+      },
+      fail: err => {
+        console.error("閫夋嫨鍥剧墖澶辫触:", err);
+        showToast("閫夋嫨鏂囦欢澶辫触");
+      },
+    });
     // uni.chooseFile({
     //   count: 9,
     //   extension: [
@@ -174,6 +173,7 @@
     //     ".rar",
     //   ],
     //   success: res => {
+    //     console.log(res, "閫夋嫨鏂囦欢鎴愬姛");
     //     uploadFiles(res.tempFiles);
     //   },
     //   fail: err => {
@@ -184,13 +184,14 @@
 
   // 涓婁紶鏂囦欢
   const uploadFiles = tempFiles => {
+    console.log(tempFiles, "涓婁紶鏂囦欢1");
     tempFiles.forEach((tempFile, index) => {
       // 鏄剧ず涓婁紶涓彁绀�
       uni.showLoading({
         title: "涓婁紶涓�...",
         mask: true,
       });
-      console.log(tempFile, "涓婁紶鏂囦欢");
+      console.log(tempFile, "涓婁紶鏂囦欢2");
       // 1. 鐩存帴浣跨敤 uni.uploadFile 涓婁紶鏂囦欢
       uni.uploadFile({
         url: config.baseUrl + "/file/upload",
@@ -201,12 +202,17 @@
         },
         success: uploadRes => {
           uni.hideLoading();
+          console.log(uploadRes, "涓婁紶鏂囦欢3");
+
           try {
             const res = JSON.parse(uploadRes.data);
+            console.log(res, "涓婁紶鏂囦欢4");
             if (res.code === 200) {
               // 2. 鎻愬彇鏂囦欢淇℃伅
-              const fileName = tempFile.name;
-              const fileType = fileName.split(".").pop();
+              const fileName = tempFile.name
+                ? tempFile.name
+                : tempFile.path.split("/").pop();
+              // const fileType = fileName.split(".").pop();
               // 3. 鏋勯�犱繚瀛樻枃浠朵俊鎭殑鍙傛暟
               const saveData = {
                 name: fileName,
@@ -250,7 +256,6 @@
       });
     });
   };
-
   // 涓嬭浇鏂囦欢
   const downloadFile = file => {
     var url =
@@ -267,21 +272,60 @@
         header: { Authorization: "Bearer " + getToken() },
       })
       .then(res => {
-        console.log(res, "res");
-        const isBlob = blobValidate(res.data);
-        console.log(isBlob, "isBlob");
-        if (isBlob) {
-          const blob = new Blob([res.data], { type: "text/plain" });
-          const url = URL.createObjectURL(blob);
-          const downloadLink = document.getElementById("downloadLink");
-          downloadLink.href = url;
-          downloadLink.download = file.name;
-          downloadLink.click();
-          // downloadLink.style.display = "block";
-          showToast("涓嬭浇鎴愬姛");
+        let osType = uni.getStorageSync("deviceInfo").osName;
+        let filePath = res.tempFilePath;
+        if (osType === "ios") {
+          uni.openDocument({
+            filePath: filePath,
+            showMenu: true,
+            success: res => {
+              resolve(res);
+            },
+            fail: err => {
+              console.log("uni.openDocument--fail");
+              reject(err);
+            },
+          });
         } else {
-          showToast("涓嬭浇澶辫触");
+          uni.saveFile({
+            tempFilePath: filePath,
+            success: fileRes => {
+              uni.showToast({
+                icon: "none",
+                mask: true,
+                title:
+                  "鏂囦欢宸蹭繚瀛橈細Android/data/uni.UNI720216F/apps/__UNI__720216F/" +
+                  fileRes.savedFilePath, //淇濆瓨璺緞
+                duration: 3000,
+              });
+              setTimeout(() => {
+                //鎵撳紑鏂囨。鏌ョ湅
+                uni.openDocument({
+                  filePath: fileRes.savedFilePath,
+                  success: function (res) {
+                    resolve(fileRes);
+                  },
+                });
+              }, 3000);
+            },
+            fail: err => {
+              console.log("uni.save--fail");
+              reject(err);
+            },
+          });
         }
+        // const isBlob = blobValidate(res.data);
+        // if (isBlob) {
+        //   const blob = new Blob([res.data], { type: "text/plain" });
+        //   const url = URL.createObjectURL(blob);
+        //   const downloadLink = document.getElementById("downloadLink");
+        //   downloadLink.href = url;
+        //   downloadLink.download = file.name;
+        //   downloadLink.click();
+        //   showToast("涓嬭浇鎴愬姛");
+        // } else {
+        //   showToast("涓嬭浇澶辫触");
+        // }
       })
       .catch(err => {
         console.error("涓嬭浇澶辫触:", err);
@@ -483,8 +527,8 @@
     position: fixed;
     bottom: 40rpx;
     right: 40rpx;
-    width: 80rpx;
-    height: 80rpx;
+    width: 130rpx;
+    height: 130rpx;
     border-radius: 50%;
     background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
     display: flex;

--
Gitblit v1.9.3