From 883491f466f235089acaac0628dd93578325a6d0 Mon Sep 17 00:00:00 2001 From: Ultrame <1019265060@qq.com> Date: Sun, 28 Sep 2025 22:45:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E8=BD=BD=E8=B4=A6=E5=8D=95=E3=80=81?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B4=A6=E5=8D=95=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/user_pages/downloadBill/index.tsx | 34 ++++++-- src/user_pages/downloadBillRecords/index.tsx | 90 +++++++++++++------- src/user_pages/validPhone/index.tsx | 24 +++++- src/user_pages/wallet/index.scss | 4 +- src/user_pages/wallet/index.tsx | 82 ++++++++++++++---- src/user_pages/withdrawal/index.scss | 2 +- src/user_pages/withdrawal/index.tsx | 1 + 7 files changed, 180 insertions(+), 57 deletions(-) diff --git a/src/user_pages/downloadBill/index.tsx b/src/user_pages/downloadBill/index.tsx index ef248b5..5632094 100644 --- a/src/user_pages/downloadBill/index.tsx +++ b/src/user_pages/downloadBill/index.tsx @@ -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 = () => { 最长可导出三个月的账单 - 示例文件 + {/* 示例文件 */} {/* @@ -226,9 +246,8 @@ const DownloadBill: React.FC = () => { 近一周 { selectDateRange("month"); }} @@ -236,9 +255,8 @@ const DownloadBill: React.FC = () => { 近一月 { selectDateRange("custom"); }} diff --git a/src/user_pages/downloadBillRecords/index.tsx b/src/user_pages/downloadBillRecords/index.tsx index 4a4d568..fe7808f 100644 --- a/src/user_pages/downloadBillRecords/index.tsx +++ b/src/user_pages/downloadBillRecords/index.tsx @@ -2,41 +2,71 @@ import React, { useState, useEffect } from "react"; import { View, Text } from "@tarojs/components"; import "./index.scss"; +import httpService from "@/services/httpService"; +import Taro from "@tarojs/taro"; + +interface BillRecord { + id: number; + file_name: string; + download_url: string; + file_size: number; + create_time: string; + expire_time: string; + bill_date_range_start: string; + bill_date_range_end: string; + bill_transaction_type: string; + bill_transaction_sub_type: string; + date_range_desc: string; + transaction_type_desc: string; + transaction_sub_type_desc: string; +} const DownloadBillRecords: React.FC = () => { + const [records, setRecords] = useState([]); + const [params, setParams] = useState({ + page: 1, + limit: 20, + }); + + useEffect(() => { + fetchRecords(); + }, []); + + const fetchRecords = async () => { + try { + const response = await httpService.post<{ rows: BillRecord[] }>('/wallet/download_history', params); + setRecords(response.data.rows); + } catch (error) { + console.log(error); + Taro.showToast({ + title: '获取账单记录失败', + icon: 'none', + duration: 2000, + }); + } + }; return ( - - 账单流水文件 - - 申请时间 - 2025年9月12日 19:03:06 - - - 账单范围 - 2025年9月12日 19:03:06 至 2025年9月12日 19:03:06 - - - - 查看材料 - - - - 账单流水文件 - - 申请时间 - 2025年9月12日 19:03:06 - - - 账单范围 - 2025年9月12日 19:03:06 至 2025年9月12日 19:03:06 - - - - 查看材料 - - + { + records.map((record) => ( + + {record.file_name} + + 申请时间 + {record.create_time} + + + 账单范围 + {record.date_range_desc} + + + + 查看材料 + + + )) + } 出于信息安全考虑,仅保留并展示7天内的账单下载记录 diff --git a/src/user_pages/validPhone/index.tsx b/src/user_pages/validPhone/index.tsx index 71a6464..4f8f92b 100644 --- a/src/user_pages/validPhone/index.tsx +++ b/src/user_pages/validPhone/index.tsx @@ -23,8 +23,28 @@ const ValidPhone: React.FC = () => { }; const handleConfirm = async () => { - // TODO: 校验验证码 - Taro.navigateTo({ url: `/user_pages/setTransactionPassword/index?type=reset&phone=${formData.phone}&sms_code=${formData.sms_code}` }); + const isValid = await validSMSCode(); + if (isValid) { + Taro.navigateTo({ url: `/user_pages/setTransactionPassword/index?type=reset&phone=${formData.phone}&sms_code=${formData.sms_code}` }); + } + }; + + const validSMSCode = async () => { + const { phone, sms_code } = formData; + try { + const res = await httpService.post("/wallet/verify_sms_code", { phone, sms_code, type: "reset_password" }); + const { verified } = res.data; + if (verified) { + return true; + } else { + Taro.showToast({ title: "验证码校验失败", icon: "none" }); + return false; + } + } catch (error) { + console.log(error); + Taro.showToast({ title: "验证码校验失败", icon: "none" }); + return false; + } }; const getSMSCode = async () => { diff --git a/src/user_pages/wallet/index.scss b/src/user_pages/wallet/index.scss index 51aad1b..03268b6 100644 --- a/src/user_pages/wallet/index.scss +++ b/src/user_pages/wallet/index.scss @@ -146,7 +146,6 @@ border: 0.5px solid #EBEBEB; border-radius: 20px; box-shadow: 0px 0px 36px 0px rgba(0, 0, 0, 0.1); - overflow: hidden; .history_header { display: flex; @@ -154,6 +153,9 @@ align-items: center; padding: 12px 20px; border-bottom: 0.5px solid rgba(120, 120, 128, 0.12); + position: sticky; + top: 0; + background-color: #fff; .history_title { font-size: 16px; diff --git a/src/user_pages/wallet/index.tsx b/src/user_pages/wallet/index.tsx index 2e8b8d5..f6aa600 100644 --- a/src/user_pages/wallet/index.tsx +++ b/src/user_pages/wallet/index.tsx @@ -5,6 +5,7 @@ import "./index.scss"; import { CommonPopup } from "@/components"; import httpService from "@/services/httpService"; import { withAuth } from "@/components"; +import { PopupPicker } from "@/components/Picker/index"; // 交易记录类型 interface Transaction { @@ -111,6 +112,16 @@ const WalletPage: React.FC = () => { // 交易记录过滤状态 const [showFilterPopup, setShowFilterPopup] = useState(false); + const [showMonthPicker, setShowMonthPicker] = useState(false); + + const [filterParams, setFilterParams] = useState({ + type: TransactionType.All, + transaction_sub_type: TransactionSubType.All, + }); + + const now = new Date(); + const year = now.getFullYear(); + const month = String(now.getMonth() + 1).padStart(2, "0"); const [load_transactions_params, set_load_transactions_params] = useState({ @@ -119,16 +130,31 @@ const WalletPage: React.FC = () => { type: TransactionType.All, transaction_sub_type: TransactionSubType.All, keyword: "", - date: "", + date: `${year}-${month}` }); + useEffect(() => { + load_transactions(); + }, [load_transactions_params]); // 页面显示时加载数据 useDidShow(() => { load_wallet_data(); - load_transactions(); check_password_status(); }); + const modify_load_transactions_params = () => { + const { type, transaction_sub_type } = filterParams; + set_load_transactions_params((prev) => { + return { + ...prev, + type, + transaction_sub_type, + } + }) + }; + + + const check_password_status = async () => { try { const res = await httpService.post("/wallet/check_password_status"); @@ -182,11 +208,10 @@ const WalletPage: React.FC = () => { // 加载交易记录 const load_transactions = async () => { setShowFilterPopup(false); - set_load_transactions_params({ ...load_transactions_params, page: 1 }); + // set_load_transactions_params({ ...load_transactions_params, page: 1 }); try { set_loading_transactions(true); console.log("开始加载交易记录..."); - const response = await httpService.post("/wallet/transactions", { ...load_transactions_params, }); @@ -327,6 +352,7 @@ const WalletPage: React.FC = () => { // 格式化时间显示 const format_time = (time: string) => { + time = time.replace(/-/g, "/"); const date = new Date(time); const month = String(date.getMonth() + 1).padStart(2, "0"); const day = String(date.getDate()).padStart(2, "0"); @@ -380,6 +406,14 @@ const WalletPage: React.FC = () => { setShowFilterPopup(true); }; + const handleFilterCancel = () => { + setShowFilterPopup(false); + setFilterParams({ + type: load_transactions_params.type, + transaction_sub_type: load_transactions_params.transaction_sub_type, + }); + }; + return ( {/* 钱包主卡片 */} @@ -465,8 +499,8 @@ const WalletPage: React.FC = () => { {/* 标题栏 */} 现金明细 - - 2025-09 + setShowMonthPicker(true)}> + {load_transactions_params.date} @@ -557,12 +591,30 @@ const WalletPage: React.FC = () => { - + {/* 选择月份弹窗 */} + {showMonthPicker && ( + { + const [year, month] = e; + set_load_transactions_params({ + ...load_transactions_params, + date: `${year}-${String(month).padStart(2, "0")}`, + }); + }} + /> + )} {/* 筛选账单弹窗 */} setShowFilterPopup(false)} - onConfirm={load_transactions} + onClose={handleFilterCancel} + onConfirm={modify_load_transactions_params} title="选择筛选项" className="filter_popup" > @@ -575,14 +627,14 @@ const WalletPage: React.FC = () => { (option: Option) => ( { - set_load_transactions_params({ - ...load_transactions_params, + setFilterParams({ + ...filterParams, type: option.value, }); }} @@ -600,15 +652,15 @@ const WalletPage: React.FC = () => { (option: Option) => ( { - set_load_transactions_params({ - ...load_transactions_params, + setFilterParams({ + ...filterParams, transaction_sub_type: option.value, }); }} diff --git a/src/user_pages/withdrawal/index.scss b/src/user_pages/withdrawal/index.scss index 9fcaba2..c9ab7da 100644 --- a/src/user_pages/withdrawal/index.scss +++ b/src/user_pages/withdrawal/index.scss @@ -95,7 +95,7 @@ } .tips-container { - padding: 20px 20px 0; + padding: 20px 20px; .title-text { font-weight: 600; diff --git a/src/user_pages/withdrawal/index.tsx b/src/user_pages/withdrawal/index.tsx index c0a03c4..114430a 100644 --- a/src/user_pages/withdrawal/index.tsx +++ b/src/user_pages/withdrawal/index.tsx @@ -253,6 +253,7 @@ const Withdrawal: React.FC = () => { 4. 用户在使用提现服务前,应充分了解并同意上述规则。 + {/* 提现输入密码弹窗 */}