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)}>查看材料
)) : }