From 64d3eae2852d17c3bbade662d3f7a7c47d681ad6 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期四, 19 三月 2026 14:17:04 +0800
Subject: [PATCH] 2026.3.19

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

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