From ccc970e575ef3f3e5c67af8da210263f4ac549f9 Mon Sep 17 00:00:00 2001
From: feiyu02 <risaku@163.com>
Date: 星期五, 10 四月 2026 16:44:55 +0800
Subject: [PATCH] 2026.4.10
---
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