查询下载账单

This commit is contained in:
2026-02-08 16:03:08 +08:00
parent 2bcdd93479
commit f7f10f5d15

View File

@@ -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 ( return (
<View className="download-bill-records-page"> <View className="download-bill-records-page">
{/* 导航栏 */} {/* 导航栏 */}
@@ -111,7 +139,7 @@ const DownloadBillRecords: React.FC = () => {
</View> </View>
<View className="info-item"> <View className="info-item">
<Text></Text> <Text></Text>
<Text className="btn"></Text> <Text className="btn" onClick={() => handlePreviewFile(record.file_url)}></Text>
</View> </View>
</View> </View>
)) : <EmptyState text="暂无数据" />} )) : <EmptyState text="暂无数据" />}