From f7f10f5d155c84ded6839464c7cac45d94a72238 Mon Sep 17 00:00:00 2001
From: Ultrame <1019265060@qq.com>
Date: Sun, 8 Feb 2026 16:03:08 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E4=B8=8B=E8=BD=BD=E8=B4=A6?=
=?UTF-8?q?=E5=8D=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/user_pages/downloadBillRecords/index.tsx | 32 ++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/src/user_pages/downloadBillRecords/index.tsx b/src/user_pages/downloadBillRecords/index.tsx
index b075585..58ceb4a 100644
--- a/src/user_pages/downloadBillRecords/index.tsx
+++ b/src/user_pages/downloadBillRecords/index.tsx
@@ -66,6 +66,34 @@ const DownloadBillRecords: React.FC = () => {
});
}
};
+
+ const handlePreviewFile = (fileUrl: string) => {
+ wx.downloadFile({
+ url: fileUrl,
+ success: (res) => {
+ if (res.statusCode === 200) {
+ // 确保文件路径正确并添加扩展名
+ const filePath = res.tempFilePath;
+ wx.openDocument({
+ filePath: filePath,
+ fileType: 'xlsx', // 指定文件类型为xlsx
+ showMenu: true, // 显示右上角菜单按钮
+ success: (openRes) => {
+ console.log('打开文档成功');
+ },
+ fail: (err) => {
+ console.error('打开文档失败', err);
+ }
+ });
+ } else {
+ console.error('下载失败,状态码:', res.statusCode);
+ }
+ },
+ fail: (err) => {
+ console.error('下载失败', err);
+ }
+ });
+ }
return (
{/* 导航栏 */}
@@ -94,7 +122,7 @@ const DownloadBillRecords: React.FC = () => {
Taro.navigateBack();
}}
/>
-
@@ -111,7 +139,7 @@ const DownloadBillRecords: React.FC = () => {
- 查看材料
+ handlePreviewFile(record.file_url)}>查看材料
)) : }