自定义title
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import { View, Text, Button, Input } from "@tarojs/components";
|
||||
import { View, Text, Button, Input, Image } from "@tarojs/components";
|
||||
import Taro, { useDidShow } from "@tarojs/taro";
|
||||
import dayjs from "dayjs";
|
||||
|
||||
@@ -8,6 +8,7 @@ import { DialogCalendarCard } from "@/components/index";
|
||||
// import { CalendarUI } from "@/components";
|
||||
import { CommonPopup } from "@/components";
|
||||
import httpService from "@/services/httpService";
|
||||
import img from "@/config/images";
|
||||
|
||||
export enum TransactionSubType {
|
||||
All = "",
|
||||
@@ -30,6 +31,10 @@ interface TransactionLoadParams {
|
||||
date_range?: string[];
|
||||
}
|
||||
const DownloadBill: React.FC = () => {
|
||||
// 获取当前页面的配置
|
||||
const currentPage = Taro.getCurrentInstance();
|
||||
const pageConfig = currentPage.page?.config;
|
||||
const pageTitle = pageConfig?.navigationBarTitleText;
|
||||
const [dateRange, setDateRange] = useState({ start: "", end: "" });
|
||||
const [transactionSubType, setTransactionSubType] =
|
||||
useState<TransactionSubType>(TransactionSubType.All);
|
||||
@@ -179,7 +184,10 @@ const DownloadBill: React.FC = () => {
|
||||
try {
|
||||
const { transaction_sub_type } = load_transactions_params;
|
||||
const date_range = [start, end];
|
||||
const res = 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({
|
||||
@@ -188,17 +196,17 @@ const DownloadBill: React.FC = () => {
|
||||
// 只有200状态码表示下载成功
|
||||
if (res.statusCode === 200) {
|
||||
// 下载成功后可以使用res.tempFilePath访问临时文件路径
|
||||
console.log('文件下载成功,临时路径为:', res.tempFilePath);
|
||||
console.log("文件下载成功,临时路径为:", res.tempFilePath);
|
||||
// 保存文件到本地
|
||||
wx.openDocument({
|
||||
filePath: res.tempFilePath,
|
||||
showMenu: true // 显示保存菜单
|
||||
showMenu: true, // 显示保存菜单
|
||||
});
|
||||
}
|
||||
},
|
||||
fail: function (err) {
|
||||
console.error('文件下载失败:', err);
|
||||
}
|
||||
console.error("文件下载失败:", err);
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
@@ -206,6 +214,23 @@ const DownloadBill: React.FC = () => {
|
||||
};
|
||||
return (
|
||||
<View className="download_bill_page">
|
||||
{/* 导航栏 */}
|
||||
<View className="custom-navbar">
|
||||
<View className="detail-navigator">
|
||||
<View
|
||||
className="detail-navigator-back"
|
||||
onClick={() => {
|
||||
Taro.navigateBack();
|
||||
}}
|
||||
>
|
||||
<Image
|
||||
className="detail-navigator-back-icon"
|
||||
src={img.ICON_NAVIGATOR_BACK}
|
||||
/>
|
||||
<Text>{pageTitle}</Text>
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
<View className="hint_content">
|
||||
<Text>最长可导出三个月的账单 </Text>
|
||||
{/* <Text className="button_text">示例文件</Text> */}
|
||||
@@ -247,8 +272,9 @@ const DownloadBill: React.FC = () => {
|
||||
近一周
|
||||
</View>
|
||||
<View
|
||||
className={`option_button ${dateType === "month" ? "active" : ""
|
||||
}`}
|
||||
className={`option_button ${
|
||||
dateType === "month" ? "active" : ""
|
||||
}`}
|
||||
onClick={() => {
|
||||
selectDateRange("month");
|
||||
}}
|
||||
@@ -256,8 +282,9 @@ const DownloadBill: React.FC = () => {
|
||||
近一月
|
||||
</View>
|
||||
<View
|
||||
className={`option_button ${dateType === "custom" ? "active" : ""
|
||||
}`}
|
||||
className={`option_button ${
|
||||
dateType === "custom" ? "active" : ""
|
||||
}`}
|
||||
onClick={() => {
|
||||
selectDateRange("custom");
|
||||
}}
|
||||
@@ -298,7 +325,10 @@ const DownloadBill: React.FC = () => {
|
||||
>
|
||||
下载记录
|
||||
</Text>
|
||||
<Button className={`download_button ${!dateRange.start ? 'disabled' : ''}`} onClick={handleDownloadBill}>
|
||||
<Button
|
||||
className={`download_button ${!dateRange.start ? "disabled" : ""}`}
|
||||
onClick={handleDownloadBill}
|
||||
>
|
||||
下载
|
||||
</Button>
|
||||
</View>
|
||||
|
||||
Reference in New Issue
Block a user