From b1a0d701cf898c8b7812e66a808a1c91f2bae6cc Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 17 三月 2026 16:44:11 +0800
Subject: [PATCH] 2026.3.17

---
 src/api/fytz/creditApi.js |   32 +++++++++++++++++++-------------
 1 files changed, 19 insertions(+), 13 deletions(-)

diff --git a/src/api/fytz/creditApi.js b/src/api/fytz/creditApi.js
index 12ff2a8..967e7f1 100644
--- a/src/api/fytz/creditApi.js
+++ b/src/api/fytz/creditApi.js
@@ -5,25 +5,31 @@
  * 淇$敤璇勪及API鎺ュ彛
  */
 export default {
-  /**
-   * 涓嬭浇鐢ㄦ埛鐜俊鐮�
-   * @param {*} userId
-   * @param {*} userName
-   */
-  downloadCode(userId, userName) {
+  fetchCodeUrl(userId, userName) {
     return $fytz
       .get(`credit/ecCode/download?userId=${userId}`, { responseType: 'blob' })
       .then((res) => {
         const name = res.headers.get('fileName') || userName
         const fileName = Base64.decode(name)
         const url = window.URL.createObjectURL(res.data)
-        const link = document.createElement('a')
-        link.href = url
-        link.setAttribute('download', fileName)
-        document.body.appendChild(link)
-        link.click()
-        document.body.removeChild(link)
-        window.URL.revokeObjectURL(url)
+        return { fileName, url }
       })
   },
+  /**
+   * 涓嬭浇鐢ㄦ埛鐜俊鐮�
+   * @param {*} userId
+   * @param {*} userName
+   */
+  downloadCode(userId, userName) {
+    return this.fetchCodeUrl(userId, userName).then((res) => {
+      const { fileName, url } = res
+      const link = document.createElement('a')
+      link.href = url
+      link.setAttribute('download', fileName)
+      document.body.appendChild(link)
+      link.click()
+      document.body.removeChild(link)
+      window.URL.revokeObjectURL(url)
+    })
+  },
 }

--
Gitblit v1.9.3