"use client"; import React, { useState, useCallback, useEffect } from "react"; import baseRequest from "@/utils/baseRequest"; import { generateSignature } from "@/utils/crypto"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { faAngleLeft } from "@fortawesome/free-solid-svg-icons"; import { Input, Button, PullToRefresh, List, InfiniteScroll, } from "antd-mobile"; import { useRouter } from "next/navigation"; const blurhash = "LcKUTa%gOYWBYRt6xuoJo~s8V@fk"; /* params格式: { mid: item.mid, } */ export default function MessageDetail({}) { const [hasMore, setHasMore] = useState(true); const router = useRouter(); const getSession = async () => { const apiUrl = process.env.EXPO_PUBLIC_API_URL; try { const base = baseRequest(); const account = await get("account"); const signature = generateSignature({ mid: account.mid, ...base, }); const detailResponse = await fetch( `${apiUrl}/api/contact_customer_service_session/list_by_mid?signature=${signature}`, { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ mid: account.mid, ...base, }), } ); const detailData = await detailResponse.json(); if (detailData.ret === -1) { Toast.show({ type: "error", text1: detailData.msg, topOffset: 60, }); return; } if (detailData.data.session) { setSessionId(detailData.data.session.id); return; } } catch (error) { console.error(error); } }; async function doRefresh() { await sleep(1000); Toast.show({ icon: "fail", content: "刷新失败", }); throw new Error("刷新失败"); } async function loadMore() { const append = await mockRequest(); setData((val) => [...val, ...append]); setHasMore(append.length > 0); } return (
在线服务