列表加载更多
This commit is contained in:
@@ -435,11 +435,11 @@ export const useListStore = create<TennisStore>()((set, get) => ({
|
|||||||
const state = get();
|
const state = get();
|
||||||
const currentPageState = state.isSearchResult ? state.searchPageState : state.listPageState;
|
const currentPageState = state.isSearchResult ? state.searchPageState : state.listPageState;
|
||||||
const { pageOption, isHasMoreData } = currentPageState || {};
|
const { pageOption, isHasMoreData } = currentPageState || {};
|
||||||
|
|
||||||
if (!isHasMoreData) {
|
if (!isHasMoreData) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const newPageOption = {
|
const newPageOption = {
|
||||||
page: (pageOption?.page || 1) + 1,
|
page: (pageOption?.page || 1) + 1,
|
||||||
pageSize: 20,
|
pageSize: 20,
|
||||||
|
|||||||
@@ -1,206 +1,226 @@
|
|||||||
.listSearchContainer {
|
.listSearchContainer {
|
||||||
padding: 0 15px;
|
padding: 0 15px;
|
||||||
padding-top: 16px;
|
padding-top: 16px;
|
||||||
|
|
||||||
.icon16 {
|
.icon16 {
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topSearchWrapper {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
background-color: #fff;
|
||||||
|
width: 100vw;
|
||||||
|
padding: 5px 15px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.topSearch {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 44px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
gap: 10px;
|
||||||
|
border-radius: 44px;
|
||||||
|
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
||||||
|
background: #fff;
|
||||||
|
box-shadow: 0 4px 48px 0 rgba(0, 0, 0, 0.08);
|
||||||
|
padding: 0 16px 0 12px;
|
||||||
|
|
||||||
|
.nut-input {
|
||||||
|
padding: 0;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.historySearch {
|
||||||
|
padding-top: 50px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchRight {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
|
||||||
|
.searchLine {
|
||||||
|
width: 1px;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 20px;
|
||||||
|
background: rgba(0, 0, 0, 0.06);
|
||||||
}
|
}
|
||||||
|
|
||||||
.topSearch {
|
.searchText {
|
||||||
padding: 5px 16px 5px 12px;
|
color: #000000;
|
||||||
display: flex;
|
font-size: 16px;
|
||||||
align-items: center;
|
font-weight: 600;
|
||||||
height: 44px;
|
line-height: 20px;
|
||||||
box-sizing: border-box;
|
}
|
||||||
gap: 10px;
|
}
|
||||||
border-radius: 44px;
|
|
||||||
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
|
||||||
background: #fff;
|
|
||||||
box-shadow: 0 4px 48px 0 rgba(0, 0, 0, 0.08);
|
|
||||||
|
|
||||||
.nut-input {
|
.searchIcon {
|
||||||
padding: 0;
|
width: 20px;
|
||||||
height: 100%;
|
height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.historySearchTitleWrapper {
|
||||||
|
display: flex;
|
||||||
|
padding: 12px 0;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: flex-end;
|
||||||
|
align-self: stretch;
|
||||||
|
|
||||||
|
.historySearchTitle,
|
||||||
|
.historySearchClear {
|
||||||
|
color: #000;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 600;
|
||||||
|
line-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.searchRight {
|
.historySearchClear {
|
||||||
|
color: #9a9a9a;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.historySearchList {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
|
||||||
|
.historySearchItem {
|
||||||
|
color: #3c3c4399;
|
||||||
|
font-size: 12px;
|
||||||
|
flex-shrink: 0;
|
||||||
|
flex-grow: 0;
|
||||||
|
display: flex;
|
||||||
|
padding: 4px 12px;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
gap: 2px;
|
||||||
|
border-radius: 999px;
|
||||||
|
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
||||||
|
background: rgba(0, 0, 0, 0.03);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.searchSuggestion {
|
||||||
|
padding: 6px 0;
|
||||||
|
|
||||||
|
.searchSuggestionItem {
|
||||||
|
padding: 10px 20px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
.searchSuggestionItemLeft {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 12px;
|
gap: 12px;
|
||||||
|
color: rgba(60, 60, 67, 0.6);
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
.searchLine {
|
.highlight {
|
||||||
width: 1px;
|
color: #000000;
|
||||||
height: 20px;
|
}
|
||||||
border-radius: 20px;
|
}
|
||||||
background: rgba(0, 0, 0, 0.06);
|
}
|
||||||
}
|
|
||||||
|
|
||||||
.searchText {
|
.transaction_list {
|
||||||
color: #000000;
|
padding: 40px 0 70px;
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 600;
|
.loading_state,
|
||||||
line-height: 20px;
|
.empty_state {
|
||||||
}
|
padding: 40px 20px;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
.loading_text,
|
||||||
|
.empty_text {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #999;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.searchIcon {
|
.transaction_item {
|
||||||
width: 20px;
|
display: flex;
|
||||||
height: 20px;
|
justify-content: space-between;
|
||||||
}
|
align-items: center;
|
||||||
|
padding: 12px 0;
|
||||||
|
|
||||||
.historySearchTitleWrapper {
|
.transaction_left {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 12px 0;
|
flex-direction: column;
|
||||||
justify-content: space-between;
|
gap: 4px;
|
||||||
|
flex: 1;
|
||||||
|
|
||||||
|
.transaction_title {
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #000;
|
||||||
|
line-height: 1.5;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
.transaction_time {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
align-self: stretch;
|
||||||
|
gap: 4px;
|
||||||
|
|
||||||
|
.transaction_date,
|
||||||
|
.transaction_clock {
|
||||||
|
font-size: 10px;
|
||||||
|
font-weight: 400;
|
||||||
|
color: rgba(60, 60, 67, 0.6);
|
||||||
|
line-height: 1.2;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.transaction_right {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
align-self: stretch;
|
gap: 4px;
|
||||||
|
width: 68px;
|
||||||
|
|
||||||
.historySearchTitle,
|
.transaction_amount {
|
||||||
.historySearchClear {
|
font-size: 12px;
|
||||||
color: #000;
|
font-weight: 600;
|
||||||
font-size: 14px;
|
color: #000;
|
||||||
font-weight: 600;
|
line-height: 1.5;
|
||||||
line-height: 20px;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
.historySearchClear {
|
.balance_info {
|
||||||
color: #9a9a9a;
|
font-size: 10px;
|
||||||
display: flex;
|
font-weight: 400;
|
||||||
align-items: center;
|
color: rgba(60, 60, 67, 0.6);
|
||||||
gap: 4px;
|
line-height: 1.2;
|
||||||
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.historySearchList {
|
.tips_text {
|
||||||
display: flex;
|
font-size: 12px;
|
||||||
align-items: center;
|
text-align: center;
|
||||||
flex-wrap: wrap;
|
color: rgba(60, 60, 67, 0.6);
|
||||||
gap: 8px;
|
position: fixed;
|
||||||
|
bottom: 0;
|
||||||
.historySearchItem {
|
left: 0;
|
||||||
color: #3C3C4399;
|
width: 100%;
|
||||||
font-size: 12px;
|
padding: 20px 0 40px;
|
||||||
flex-shrink: 0;
|
background: #fff;
|
||||||
flex-grow: 0;
|
}
|
||||||
display: flex;
|
}
|
||||||
padding: 4px 12px;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
gap: 2px;
|
|
||||||
border-radius: 999px;
|
|
||||||
border: 0.5px solid rgba(0, 0, 0, 0.06);
|
|
||||||
background: rgba(0, 0, 0, 0.03);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.searchSuggestion {
|
|
||||||
padding: 6px 0;
|
|
||||||
|
|
||||||
.searchSuggestionItem {
|
|
||||||
padding: 10px 20px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
|
|
||||||
.searchSuggestionItemLeft {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 12px;
|
|
||||||
color: rgba(60, 60, 67, 0.6);
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.highlight {
|
|
||||||
color: #000000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.transaction_list {
|
|
||||||
|
|
||||||
.loading_state,
|
|
||||||
.empty_state {
|
|
||||||
padding: 40px 20px;
|
|
||||||
text-align: center;
|
|
||||||
|
|
||||||
.loading_text,
|
|
||||||
.empty_text {
|
|
||||||
font-size: 14px;
|
|
||||||
color: #999;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.transaction_item {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 12px 0;
|
|
||||||
|
|
||||||
.transaction_left {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 4px;
|
|
||||||
flex: 1;
|
|
||||||
|
|
||||||
.transaction_title {
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #000;
|
|
||||||
line-height: 1.5;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.transaction_time {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
align-self: stretch;
|
|
||||||
gap: 4px;
|
|
||||||
|
|
||||||
.transaction_date,
|
|
||||||
.transaction_clock {
|
|
||||||
font-size: 10px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: rgba(60, 60, 67, 0.6);
|
|
||||||
line-height: 1.2;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.transaction_right {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
align-items: flex-end;
|
|
||||||
gap: 4px;
|
|
||||||
width: 68px;
|
|
||||||
|
|
||||||
.transaction_amount {
|
|
||||||
font-size: 12px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: #000;
|
|
||||||
line-height: 1.5;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
|
|
||||||
.balance_info {
|
|
||||||
font-size: 10px;
|
|
||||||
font-weight: 400;
|
|
||||||
color: rgba(60, 60, 67, 0.6);
|
|
||||||
line-height: 1.2;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.tips_text {
|
|
||||||
font-size: 12px;
|
|
||||||
text-align: center;
|
|
||||||
color: #3C3C4399;
|
|
||||||
margin-top: 20px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
import { useState } from "react";
|
import { useState, useEffect, useRef } from "react";
|
||||||
import { View, Image, Text } from "@tarojs/components";
|
import { View, Image, Text } from "@tarojs/components";
|
||||||
import { Input } from "@nutui/nutui-react-taro";
|
import { Input } from "@nutui/nutui-react-taro";
|
||||||
import { useEffect, useRef } from "react";
|
|
||||||
import img from "@/config/images";
|
import img from "@/config/images";
|
||||||
import { withAuth } from "@/components";
|
import { withAuth } from "@/components";
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
import httpService from "@/services/httpService";
|
import httpService from "@/services/httpService";
|
||||||
import Taro from "@tarojs/taro";
|
import Taro, { useReachBottom } from "@tarojs/taro";
|
||||||
interface Transaction {
|
interface Transaction {
|
||||||
id: number;
|
id: number;
|
||||||
user_id: number;
|
user_id: number;
|
||||||
@@ -19,15 +18,6 @@ interface Transaction {
|
|||||||
related_id: number;
|
related_id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 钱包信息类型
|
|
||||||
interface WalletInfo {
|
|
||||||
balance: number;
|
|
||||||
frozen_balance?: number;
|
|
||||||
total_balance?: number;
|
|
||||||
total_income?: number;
|
|
||||||
total_withdraw?: number;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface History {
|
interface History {
|
||||||
id: number;
|
id: number;
|
||||||
keyword: string;
|
keyword: string;
|
||||||
@@ -39,6 +29,7 @@ interface TransactionLoadParams {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const QueryTransactions = () => {
|
const QueryTransactions = () => {
|
||||||
|
const isInitialMount = useRef(true);
|
||||||
const [loading_transactions, set_loading_transactions] = useState(false);
|
const [loading_transactions, set_loading_transactions] = useState(false);
|
||||||
const [transactions, setTransactions] = useState<Transaction[]>([]);
|
const [transactions, setTransactions] = useState<Transaction[]>([]);
|
||||||
const [searchHistory, setSearchHistory] = useState<History[]>([]);
|
const [searchHistory, setSearchHistory] = useState<History[]>([]);
|
||||||
@@ -63,6 +54,23 @@ const QueryTransactions = () => {
|
|||||||
}
|
}
|
||||||
}, [ref.current]);
|
}, [ref.current]);
|
||||||
|
|
||||||
|
useReachBottom(() => {
|
||||||
|
set_load_transactions_params((prev) => {
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
page: prev.page + 1,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (isInitialMount.current) {
|
||||||
|
isInitialMount.current = false;
|
||||||
|
} else {
|
||||||
|
handleSearch();
|
||||||
|
}
|
||||||
|
}, [load_transactions_params]);
|
||||||
|
|
||||||
// 是否显示清空图标
|
// 是否显示清空图标
|
||||||
const isShowClearIcon =
|
const isShowClearIcon =
|
||||||
load_transactions_params.keyword &&
|
load_transactions_params.keyword &&
|
||||||
@@ -106,7 +114,6 @@ const QueryTransactions = () => {
|
|||||||
*/
|
*/
|
||||||
const handleHistoryClick = (item: { id: number; keyword: string }) => {
|
const handleHistoryClick = (item: { id: number; keyword: string }) => {
|
||||||
set_load_transactions_params((prev) => {
|
set_load_transactions_params((prev) => {
|
||||||
handleSearch(item?.keyword);
|
|
||||||
return { ...prev, keyword: item?.keyword };
|
return { ...prev, keyword: item?.keyword };
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -123,21 +130,15 @@ const QueryTransactions = () => {
|
|||||||
* @description 点击搜索
|
* @description 点击搜索
|
||||||
*/
|
*/
|
||||||
const handleSearch = async (val?: string) => {
|
const handleSearch = async (val?: string) => {
|
||||||
if (!val) {
|
// set_loading_transactions(true);
|
||||||
return;
|
|
||||||
}
|
|
||||||
set_loading_transactions(true);
|
|
||||||
try {
|
try {
|
||||||
const response = await httpService.post("/wallet/transactions", {
|
const response = await httpService.post("/wallet/transactions", {
|
||||||
...load_transactions_params,
|
...load_transactions_params,
|
||||||
keyword: val,
|
keyword: val,
|
||||||
});
|
});
|
||||||
console.log("交易记录响应:", response);
|
|
||||||
|
|
||||||
if (response && response.data && response.data.list) {
|
if (response && response.data && response.data.list) {
|
||||||
setTransactions(response.data.list);
|
setTransactions([...transactions, ...response.data.list]);
|
||||||
} else {
|
|
||||||
setTransactions([]);
|
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
setTransactions([]);
|
setTransactions([]);
|
||||||
@@ -169,13 +170,9 @@ const QueryTransactions = () => {
|
|||||||
return numAmount.toFixed(2);
|
return numAmount.toFixed(2);
|
||||||
};
|
};
|
||||||
|
|
||||||
// 钱包信息状态
|
|
||||||
const [wallet_info, set_wallet_info] = useState<WalletInfo>({
|
|
||||||
balance: 0,
|
|
||||||
});
|
|
||||||
|
|
||||||
// 格式化时间显示
|
// 格式化时间显示
|
||||||
const format_time = (time: string) => {
|
const format_time = (time: string) => {
|
||||||
|
time = time.replace(/-/g, '/');
|
||||||
const date = new Date(time);
|
const date = new Date(time);
|
||||||
const month = String(date.getMonth() + 1).padStart(2, "0");
|
const month = String(date.getMonth() + 1).padStart(2, "0");
|
||||||
const day = String(date.getDate()).padStart(2, "0");
|
const day = String(date.getDate()).padStart(2, "0");
|
||||||
@@ -235,33 +232,35 @@ const QueryTransactions = () => {
|
|||||||
<>
|
<>
|
||||||
<View className="listSearchContainer">
|
<View className="listSearchContainer">
|
||||||
{/* 搜索 */}
|
{/* 搜索 */}
|
||||||
<View className="topSearch">
|
<View className="topSearchWrapper">
|
||||||
<Image className="searchIcon" src={img.ICON_LIST_SEARCH_SEARCH} />
|
<View className="topSearch">
|
||||||
<Input
|
<Image className="searchIcon" src={img.ICON_LIST_SEARCH_SEARCH} />
|
||||||
placeholder="查找"
|
<Input
|
||||||
value={load_transactions_params.keyword}
|
placeholder="查找"
|
||||||
defaultValue={load_transactions_params.keyword}
|
value={load_transactions_params.keyword}
|
||||||
onChange={handleChange}
|
defaultValue={load_transactions_params.keyword}
|
||||||
onClear={handleClear}
|
onChange={handleChange}
|
||||||
autoFocus
|
onClear={handleClear}
|
||||||
clearable={false}
|
autoFocus
|
||||||
ref={ref}
|
clearable={false}
|
||||||
/>
|
ref={ref}
|
||||||
<View className="searchRight">
|
/>
|
||||||
{isShowClearIcon && (
|
<View className="searchRight">
|
||||||
<Image
|
{isShowClearIcon && (
|
||||||
className="clearIcon icon16"
|
<Image
|
||||||
src={img.ICON_LIST_SEARCH_CLEAR}
|
className="clearIcon icon16"
|
||||||
onClick={handleClear}
|
src={img.ICON_LIST_SEARCH_CLEAR}
|
||||||
/>
|
onClick={handleClear}
|
||||||
)}
|
/>
|
||||||
<View className="searchLine" />
|
)}
|
||||||
<Text
|
<View className="searchLine" />
|
||||||
className="searchText"
|
<Text
|
||||||
onClick={() => handleSearch(load_transactions_params.keyword)}
|
className="searchText"
|
||||||
>
|
onClick={() => handleSearch(load_transactions_params.keyword)}
|
||||||
搜索
|
>
|
||||||
</Text>
|
搜索
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
{/* 查找历史 */}
|
{/* 查找历史 */}
|
||||||
@@ -329,7 +328,7 @@ const QueryTransactions = () => {
|
|||||||
{get_amount_display(transaction)}
|
{get_amount_display(transaction)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text className="balance_info">
|
<Text className="balance_info">
|
||||||
余额 ¥{format_amount(wallet_info.balance)}
|
余额 ¥{format_amount(transaction.amount)}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
@@ -341,11 +340,9 @@ const QueryTransactions = () => {
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
{
|
{transactions.length > 0 && (
|
||||||
transactions.length > 0 && (
|
<View className="tips_text">仅支持查找2024年9月1日以后的账单</View>
|
||||||
<View className="tips_text">仅支持查找2024年9月1日以后的账单</View>
|
)}
|
||||||
)
|
|
||||||
}
|
|
||||||
</View>
|
</View>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,95 +1,139 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect } from "react";
|
||||||
import Taro, { useRouter } from '@tarojs/taro';
|
import Taro, { useRouter } from "@tarojs/taro";
|
||||||
import { View, Text, Input, Button } from "@tarojs/components";
|
import { View, Text, Input, Button } from "@tarojs/components";
|
||||||
|
|
||||||
import "./index.scss";
|
import "./index.scss";
|
||||||
import httpService from "@/services/httpService";
|
import httpService from "@/services/httpService";
|
||||||
|
|
||||||
interface FormFields {
|
interface FormFields {
|
||||||
old_password?: string;
|
old_password?: string;
|
||||||
new_password: string;
|
new_password: string;
|
||||||
confirm_password: string;
|
confirm_password: string;
|
||||||
sms_code?: string;
|
sms_code?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SetTransactionPassword: React.FC = () => {
|
const SetTransactionPassword: React.FC = () => {
|
||||||
const [handleType, setHandleType] = useState("set");
|
const [handleType, setHandleType] = useState("set");
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { type, phone, sms_code } = router.params;
|
const { type, phone, sms_code } = router.params;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (type) {
|
if (type) {
|
||||||
setHandleType(type);
|
setHandleType(type);
|
||||||
}
|
}
|
||||||
}, [type]);
|
}, [type]);
|
||||||
|
|
||||||
const [formData, setFormData] = useState<FormFields>({
|
const [formData, setFormData] = useState<FormFields>({
|
||||||
old_password: "",
|
old_password: "",
|
||||||
new_password: "",
|
new_password: "",
|
||||||
confirm_password: "",
|
confirm_password: "",
|
||||||
sms_code: "",
|
sms_code: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
const handleInput = (e: any, field: string) => {
|
const handleInput = (e: any, field: string) => {
|
||||||
setFormData({ ...formData, [field]: e.detail.value });
|
setFormData({ ...formData, [field]: e.detail.value });
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirm = async () => {
|
const handleConfirm = async () => {
|
||||||
const { new_password, confirm_password } = formData;
|
const { new_password, confirm_password } = formData;
|
||||||
if (new_password !== confirm_password) {
|
if (new_password !== confirm_password) {
|
||||||
Taro.showToast({
|
Taro.showToast({
|
||||||
title: "两次密码输入不一致",
|
title: "两次密码输入不一致",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
await httpService.post("/wallet/set_payment_password", { password: new_password });
|
await httpService.post("/wallet/set_payment_password", {
|
||||||
Taro.showToast({
|
password: new_password,
|
||||||
title: "设置交易密码成功",
|
});
|
||||||
icon: "success",
|
Taro.showToast({
|
||||||
});
|
title: "设置交易密码成功",
|
||||||
Taro.navigateBack();
|
icon: "success",
|
||||||
} catch (error) {
|
});
|
||||||
Taro.showToast({
|
Taro.navigateBack();
|
||||||
title: "设置交易密码失败",
|
} catch (error) {
|
||||||
icon: "none",
|
Taro.showToast({
|
||||||
});
|
title: "设置交易密码失败",
|
||||||
return;
|
icon: "none",
|
||||||
}
|
});
|
||||||
};
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
const getSMSCode = async () => {
|
||||||
<View className="set-transaction-password-page">
|
try {
|
||||||
{
|
await httpService.post("/wallet/send_set_password_sms", {
|
||||||
// handleType === "reset" && (
|
type: "set_password",
|
||||||
// <View className="form-item">
|
});
|
||||||
// <Text className="form-label">旧密码</Text>
|
Taro.showToast({
|
||||||
// <Input placeholder="请输入旧密码" password type="number" maxlength={6} onInput={(e) => { handleInput(e, "old_password") }}></Input>
|
title: "验证码发送成功",
|
||||||
// </View>
|
icon: "none",
|
||||||
// )
|
});
|
||||||
}
|
} catch (error) {
|
||||||
<View className="form-item">
|
Taro.showToast({
|
||||||
<Text className="form-label">交易密码</Text>
|
title: "验证码发送失败",
|
||||||
<Input placeholder="请输入交易密码" password type="number" maxlength={6} onInput={(e) => { handleInput(e, "new_password") }}></Input>
|
icon: "none",
|
||||||
</View>
|
});
|
||||||
<View className="form-item">
|
return;
|
||||||
<Text className="form-label">重复密码</Text>
|
}
|
||||||
<Input placeholder="请再次输入交易密码" password type="number" maxlength={6} onInput={(e) => { handleInput(e, "confirm_password") }}></Input>
|
};
|
||||||
</View>
|
|
||||||
{
|
return (
|
||||||
handleType === "set" && (
|
<View className="set-transaction-password-page">
|
||||||
<View className="form-item">
|
{
|
||||||
<Text className="form-label">手机验证</Text>
|
// handleType === "reset" && (
|
||||||
<Input placeholder="请输入验证码" type="number" onInput={(e) => { handleInput(e, "sms_code") }}></Input>
|
// <View className="form-item">
|
||||||
<Button className="btn" >获取验证码</Button>
|
// <Text className="form-label">旧密码</Text>
|
||||||
</View>
|
// <Input placeholder="请输入旧密码" password type="number" maxlength={6} onInput={(e) => { handleInput(e, "old_password") }}></Input>
|
||||||
)
|
// </View>
|
||||||
}
|
// )
|
||||||
<Text className="tips">* 密码由6位数字组成</Text>
|
}
|
||||||
<Button className="btn bottom-btn" onClick={handleConfirm}>完成</Button>
|
<View className="form-item">
|
||||||
|
<Text className="form-label">交易密码</Text>
|
||||||
|
<Input
|
||||||
|
placeholder="请输入交易密码"
|
||||||
|
password
|
||||||
|
type="number"
|
||||||
|
maxlength={6}
|
||||||
|
onInput={(e) => {
|
||||||
|
handleInput(e, "new_password");
|
||||||
|
}}
|
||||||
|
></Input>
|
||||||
|
</View>
|
||||||
|
<View className="form-item">
|
||||||
|
<Text className="form-label">重复密码</Text>
|
||||||
|
<Input
|
||||||
|
placeholder="请再次输入交易密码"
|
||||||
|
password
|
||||||
|
type="number"
|
||||||
|
maxlength={6}
|
||||||
|
onInput={(e) => {
|
||||||
|
handleInput(e, "confirm_password");
|
||||||
|
}}
|
||||||
|
></Input>
|
||||||
|
</View>
|
||||||
|
{handleType === "set" && (
|
||||||
|
<View className="form-item">
|
||||||
|
<Text className="form-label">手机验证</Text>
|
||||||
|
<Input
|
||||||
|
placeholder="请输入验证码"
|
||||||
|
type="number"
|
||||||
|
onInput={(e) => {
|
||||||
|
handleInput(e, "sms_code");
|
||||||
|
}}
|
||||||
|
></Input>
|
||||||
|
<Button className="btn" onClick={getSMSCode}>
|
||||||
|
获取验证码
|
||||||
|
</Button>
|
||||||
</View>
|
</View>
|
||||||
);
|
)}
|
||||||
|
<Text className="tips">* 密码由6位数字组成</Text>
|
||||||
|
<Button className="btn bottom-btn" onClick={handleConfirm}>
|
||||||
|
完成
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default SetTransactionPassword;
|
export default SetTransactionPassword;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import httpService from "@/services/httpService";
|
|||||||
import { withAuth } from "@/components";
|
import { withAuth } from "@/components";
|
||||||
import { PopupPicker } from "@/components/Picker/index";
|
import { PopupPicker } from "@/components/Picker/index";
|
||||||
import { handleCustomerService } from "@/services/userService";
|
import { handleCustomerService } from "@/services/userService";
|
||||||
|
import { useReachBottom } from "@tarojs/taro";
|
||||||
|
|
||||||
// 交易记录类型
|
// 交易记录类型
|
||||||
interface Transaction {
|
interface Transaction {
|
||||||
@@ -96,6 +97,15 @@ const transaction_type_options: Option<TransactionSubType>[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const WalletPage: React.FC = () => {
|
const WalletPage: React.FC = () => {
|
||||||
|
useReachBottom(() => {
|
||||||
|
// 加载更多方法
|
||||||
|
set_load_transactions_params((prev) => {
|
||||||
|
return {
|
||||||
|
...prev,
|
||||||
|
page: prev.page + 1,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
// 钱包信息状态
|
// 钱包信息状态
|
||||||
const [wallet_info, set_wallet_info] = useState<WalletInfo>({
|
const [wallet_info, set_wallet_info] = useState<WalletInfo>({
|
||||||
balance: 0,
|
balance: 0,
|
||||||
@@ -131,7 +141,7 @@ const WalletPage: React.FC = () => {
|
|||||||
type: TransactionType.All,
|
type: TransactionType.All,
|
||||||
transaction_sub_type: TransactionSubType.All,
|
transaction_sub_type: TransactionSubType.All,
|
||||||
keyword: "",
|
keyword: "",
|
||||||
date: `${year}-${month}`
|
date: `${year}-${month}`,
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -150,12 +160,10 @@ const WalletPage: React.FC = () => {
|
|||||||
...prev,
|
...prev,
|
||||||
type,
|
type,
|
||||||
transaction_sub_type,
|
transaction_sub_type,
|
||||||
}
|
};
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const check_password_status = async () => {
|
const check_password_status = async () => {
|
||||||
try {
|
try {
|
||||||
const res = await httpService.post("/wallet/check_password_status");
|
const res = await httpService.post("/wallet/check_password_status");
|
||||||
@@ -163,7 +171,7 @@ const WalletPage: React.FC = () => {
|
|||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("检查交易密码状态失败:", e);
|
console.error("检查交易密码状态失败:", e);
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
// 加载钱包数据
|
// 加载钱包数据
|
||||||
const load_wallet_data = async () => {
|
const load_wallet_data = async () => {
|
||||||
@@ -211,7 +219,7 @@ const WalletPage: React.FC = () => {
|
|||||||
setShowFilterPopup(false);
|
setShowFilterPopup(false);
|
||||||
// set_load_transactions_params({ ...load_transactions_params, page: 1 });
|
// set_load_transactions_params({ ...load_transactions_params, page: 1 });
|
||||||
try {
|
try {
|
||||||
set_loading_transactions(true);
|
if (!transactions.length) set_loading_transactions(true);
|
||||||
console.log("开始加载交易记录...");
|
console.log("开始加载交易记录...");
|
||||||
const response = await httpService.post("/wallet/transactions", {
|
const response = await httpService.post("/wallet/transactions", {
|
||||||
...load_transactions_params,
|
...load_transactions_params,
|
||||||
@@ -220,7 +228,7 @@ const WalletPage: React.FC = () => {
|
|||||||
console.log("交易记录响应:", response);
|
console.log("交易记录响应:", response);
|
||||||
|
|
||||||
if (response && response.data && response.data.list) {
|
if (response && response.data && response.data.list) {
|
||||||
set_transactions(response.data.list);
|
set_transactions([...transactions, ...response.data.list]);
|
||||||
console.log("设置交易记录:", response.data.list);
|
console.log("设置交易记录:", response.data.list);
|
||||||
} else {
|
} else {
|
||||||
console.log("响应数据格式异常:", response);
|
console.log("响应数据格式异常:", response);
|
||||||
@@ -254,11 +262,11 @@ const WalletPage: React.FC = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const navigateToSetTransactionPassword = (type: "set" | "reset") => {
|
const navigateToSetTransactionPassword = (type: "set" | "reset") => {
|
||||||
let url = ""
|
let url = "";
|
||||||
if (type === "set") {
|
if (type === "set") {
|
||||||
url = `/user_pages/setTransactionPassword/index?type=${type}`
|
url = `/user_pages/setTransactionPassword/index?type=${type}`;
|
||||||
} else if (type === "reset") {
|
} else if (type === "reset") {
|
||||||
url = `/user_pages/validPhone/index`
|
url = `/user_pages/validPhone/index`;
|
||||||
}
|
}
|
||||||
Taro.navigateTo({
|
Taro.navigateTo({
|
||||||
url,
|
url,
|
||||||
@@ -422,7 +430,12 @@ const WalletPage: React.FC = () => {
|
|||||||
{/* 头部信息 */}
|
{/* 头部信息 */}
|
||||||
<View className="card_header">
|
<View className="card_header">
|
||||||
<Text className="header_title">我的现金</Text>
|
<Text className="header_title">我的现金</Text>
|
||||||
<Text className="modify_password" onClick={() => navigateToSetTransactionPassword("reset")}>修改交易密码</Text>
|
<Text
|
||||||
|
className="modify_password"
|
||||||
|
onClick={() => navigateToSetTransactionPassword("reset")}
|
||||||
|
>
|
||||||
|
修改交易密码
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
{/* 余额显示 */}
|
{/* 余额显示 */}
|
||||||
@@ -491,7 +504,7 @@ const WalletPage: React.FC = () => {
|
|||||||
className="function_icon"
|
className="function_icon"
|
||||||
src={require("@/static/wallet/custom-service.svg")}
|
src={require("@/static/wallet/custom-service.svg")}
|
||||||
/>
|
/>
|
||||||
<Text className="function_text" >客服中心</Text>
|
<Text className="function_text">客服中心</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
@@ -500,8 +513,13 @@ const WalletPage: React.FC = () => {
|
|||||||
{/* 标题栏 */}
|
{/* 标题栏 */}
|
||||||
<View className="history_header">
|
<View className="history_header">
|
||||||
<Text className="history_title">现金明细</Text>
|
<Text className="history_title">现金明细</Text>
|
||||||
<View className="month_selector" onClick={() => setShowMonthPicker(true)}>
|
<View
|
||||||
<Text className="current_month">{load_transactions_params.date}</Text>
|
className="month_selector"
|
||||||
|
onClick={() => setShowMonthPicker(true)}
|
||||||
|
>
|
||||||
|
<Text className="current_month">
|
||||||
|
{load_transactions_params.date}
|
||||||
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
@@ -599,7 +617,7 @@ const WalletPage: React.FC = () => {
|
|||||||
setvisible={setShowMonthPicker}
|
setvisible={setShowMonthPicker}
|
||||||
value={[
|
value={[
|
||||||
Number(load_transactions_params.date!.split("-")[0]),
|
Number(load_transactions_params.date!.split("-")[0]),
|
||||||
Number(load_transactions_params.date!.split("-")[1])
|
Number(load_transactions_params.date!.split("-")[1]),
|
||||||
]}
|
]}
|
||||||
type="month"
|
type="month"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
@@ -653,8 +671,7 @@ const WalletPage: React.FC = () => {
|
|||||||
(option: Option<TransactionSubType>) => (
|
(option: Option<TransactionSubType>) => (
|
||||||
<View
|
<View
|
||||||
className={
|
className={
|
||||||
filterParams.transaction_sub_type ===
|
filterParams.transaction_sub_type === option.value
|
||||||
option.value
|
|
||||||
? "option_item active"
|
? "option_item active"
|
||||||
: "option_item"
|
: "option_item"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,6 +50,8 @@ const Withdrawal: React.FC = () => {
|
|||||||
} else if (Number(amount) > 200) {
|
} else if (Number(amount) > 200) {
|
||||||
setShowTips(true);
|
setShowTips(true);
|
||||||
setTipsText("单笔提现金额不能超过 200元");
|
setTipsText("单笔提现金额不能超过 200元");
|
||||||
|
} else {
|
||||||
|
setShowTips(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -287,4 +289,4 @@ const Withdrawal: React.FC = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default Withdrawal;
|
export default Withdrawal;
|
||||||
|
|||||||
Reference in New Issue
Block a user