From 80a4cc35fa175b5e799d66cf5daca2fe9d5dba3d Mon Sep 17 00:00:00 2001
From: Ultrame <1019265060@qq.com>
Date: Mon, 27 Oct 2025 11:20:48 +0800
Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E8=B4=A6=E5=8D=95=E7=A4=BA?=
=?UTF-8?q?=E4=BE=8B=E6=96=87=E4=BB=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/user_pages/downloadBill/index.tsx | 38 +++++++++++++++++++++++++--
1 file changed, 36 insertions(+), 2 deletions(-)
diff --git a/src/user_pages/downloadBill/index.tsx b/src/user_pages/downloadBill/index.tsx
index bc9027c..d92b863 100644
--- a/src/user_pages/downloadBill/index.tsx
+++ b/src/user_pages/downloadBill/index.tsx
@@ -178,6 +178,37 @@ const DownloadBill: React.FC = () => {
});
setShowFilterPopup(false);
};
+ const downloadExample = async () => {
+ const { start, end } = dateRange;
+ if (!start || !end) return;
+ try {
+ const res = await httpService.post("/parameter/many_key", {
+ keys: "bill_example",
+ });
+ const { bill_example, fileName } = res.data;
+ // 调用下载文件接口
+ wx.downloadFile({
+ url: bill_example, // 文件路径
+ success: function (res) {
+ // 只有200状态码表示下载成功
+ if (res.statusCode === 200) {
+ // 下载成功后可以使用res.tempFilePath访问临时文件路径
+ console.log("文件下载成功,临时路径为:", res.tempFilePath);
+ // 保存文件到本地
+ wx.openDocument({
+ filePath: res.tempFilePath,
+ showMenu: true, // 显示保存菜单
+ });
+ }
+ },
+ fail: function (err) {
+ console.error("文件下载失败:", err);
+ },
+ });
+ } catch (error) {
+ console.error(error);
+ }
+ };
const handleDownloadBill = async () => {
const { start, end } = dateRange;
if (!start || !end) return;
@@ -188,10 +219,10 @@ const DownloadBill: React.FC = () => {
transaction_sub_type,
date_range,
});
- const { fileUrl, fileName } = res.data;
+ const { bill_example, fileName } = res.data;
// 调用下载文件接口
wx.downloadFile({
- url: fileUrl, // 文件路径
+ url: bill_example, // 文件路径
success: function (res) {
// 只有200状态码表示下载成功
if (res.statusCode === 200) {
@@ -233,6 +264,9 @@ const DownloadBill: React.FC = () => {
最长可导出三个月的账单
+
+ 示例文件
+
{/* 示例文件 */}