下载账单、优化账单查询

This commit is contained in:
2025-09-28 22:45:30 +08:00
parent 8a3e41cef6
commit 883491f466
7 changed files with 180 additions and 57 deletions

View File

@@ -178,7 +178,27 @@ const DownloadBill: React.FC = () => {
const { transaction_sub_type } = load_transactions_params;
const { start, end } = dateRange;
const date_range = [start, end];
await httpService.post("/wallet/download_bill", {transaction_sub_type, date_range});
const res = await httpService.post("/wallet/download_bill", { transaction_sub_type, date_range });
const { fileUrl, fileName } = res.data;
// 调用下载文件接口
wx.downloadFile({
url: fileUrl, // 文件路径
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);
}
@@ -187,7 +207,7 @@ const DownloadBill: React.FC = () => {
<View className="download_bill_page">
<View className="hint_content">
<Text> </Text>
<Text className="button_text"></Text>
{/* <Text className="button_text">示例文件</Text> */}
</View>
<View className="form_container">
{/* <View className="form_item">
@@ -226,9 +246,8 @@ const DownloadBill: React.FC = () => {
</View>
<View
className={`option_button ${
dateType === "month" ? "active" : ""
}`}
className={`option_button ${dateType === "month" ? "active" : ""
}`}
onClick={() => {
selectDateRange("month");
}}
@@ -236,9 +255,8 @@ const DownloadBill: React.FC = () => {
</View>
<View
className={`option_button ${
dateType === "custom" ? "active" : ""
}`}
className={`option_button ${dateType === "custom" ? "active" : ""
}`}
onClick={() => {
selectDateRange("custom");
}}