下载记录、钱包账单添加加载更多;监听键盘高度优化样式
This commit is contained in:
@@ -3,7 +3,7 @@ import { View, Text } from "@tarojs/components";
|
||||
|
||||
import "./index.scss";
|
||||
import httpService from "@/services/httpService";
|
||||
import Taro from "@tarojs/taro";
|
||||
import Taro, { useReachBottom } from "@tarojs/taro";
|
||||
|
||||
interface BillRecord {
|
||||
id: number;
|
||||
@@ -28,14 +28,22 @@ const DownloadBillRecords: React.FC = () => {
|
||||
limit: 20,
|
||||
});
|
||||
|
||||
const [totalPages, setTotalPages] = useState(1);
|
||||
|
||||
useReachBottom(() => {
|
||||
if (params.page < totalPages) {
|
||||
setParams({ ...params, page: params.page + 1 });
|
||||
}
|
||||
});
|
||||
useEffect(() => {
|
||||
fetchRecords();
|
||||
}, []);
|
||||
|
||||
}, [params]);
|
||||
|
||||
const fetchRecords = async () => {
|
||||
try {
|
||||
const response = await httpService.post<{ rows: BillRecord[] }>('/wallet/download_history', params);
|
||||
setRecords(response.data.rows);
|
||||
const response = await httpService.post<{ rows: BillRecord[], totalPages: number }>('/wallet/download_history', params);
|
||||
setRecords([...records, ...response.data.rows]);
|
||||
setTotalPages(response.data.totalPages);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
Taro.showToast({
|
||||
|
||||
Reference in New Issue
Block a user