"use client"; import React, { useState, useCallback } from "react"; import { List, InfiniteScroll, Toast, Image } from "antd-mobile"; import { useRouter, useSearchParams } from "next/navigation"; import requireAPI from "@/utils/requireAPI"; import Empty from "@/components/Empty"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft, faCalendar } from "@fortawesome/free-solid-svg-icons"; //todo:等接口上线补全字段 export default function PostPurchasers() { //查询数据 const [data, setData] = useState([]); const [offset, setOffset] = useState(0); const [more, setMore] = useState(1); const searchParams = useSearchParams(); const router = useRouter(); const getData = async () => { if (!more) return; try { const body = { moment_id: Number(searchParams.get("id")), offset: offset, limit: 12, }; const _data = await requireAPI("POST", "/api/vas/moment_order_list", { body, }); if (_data.ret === -1) { Toast.show({ icon: "fail", content: _data.msg, position: "top", }); return; } setData((prev) => [...prev, ..._data.data.list]); setOffset(_data.data.offset); setMore(_data.data.more); } catch (error) { console.error(error); } }; //格式化时间 const formatDate = useCallback((timestamp) => { const date = new Date(timestamp * 1000); const year = date.getFullYear(); const month = date.getMonth() + 1; // 月份从0开始,所以需要加1 const day = date.getDate(); const hours = date.getHours(); const minutes = date.getMinutes(); return `${year}/${month}/${day} ${hours}:${minutes}`; }, []); const RenderItem = ({ item }) => { return (
{item?.account?.name}
{item?.account?.user_id}
{formatDate(item?.buy_time)}
); }; return (
{/* 头部标题 */}
{ router.back(); }} />

已购用户

{/* 内容 */}
{data.length == 0 && (
)} {data?.map((item, index) => ( ))} {null} {/* getData()} ListEmptyComponent={} /> */}
); }