|
@@ -2,13 +2,11 @@ import { View, ScrollView, Text } from "@tarojs/components";
|
|
|
import Taro, { useDidShow, useRouter } from "@tarojs/taro";
|
|
|
import NavBarNormal from "@/components/NavBarNormal/index";
|
|
|
import PageCustom from "@/components/page-custom/index";
|
|
|
-import IconArrowDownRounded from "@/components/icon/IconArrowDownRounded";
|
|
|
import { useEffect, useState } from "react";
|
|
|
-import { useAgentStore } from "@/store/agentStore";
|
|
|
import { isSuccess } from "@/utils";
|
|
|
import ChatRecordItem from "@/components/ChatRecordItem";
|
|
|
import { getVisitorInfo } from "@/service/visitor";
|
|
|
-import { TSessionItem, TVisitorAgent, TVisitorMessage } from "@/types/visitor";
|
|
|
+import { TSessionItem, TVisitorAgent } from "@/types/visitor";
|
|
|
import VisitorSummary from "./components/VisitorSummary";
|
|
|
|
|
|
import { getVisitorSessions } from "@/service/visitor";
|
|
@@ -20,13 +18,13 @@ import EmptyData from "@/components/EmptyData";
|
|
|
export default () => {
|
|
|
const router = useRouter();
|
|
|
const { visitorId } = router.params;
|
|
|
+ const [visitor, setVisitor] = useState<TVisitorAgent>();
|
|
|
+ const [totalCount, setTotalCount] = useState(0)
|
|
|
+
|
|
|
if (!visitorId) {
|
|
|
return <View>...</View>;
|
|
|
}
|
|
|
|
|
|
- const [visitor, setVisitor] = useState<TVisitorAgent>();
|
|
|
-
|
|
|
-
|
|
|
const fetchData = async () => {
|
|
|
if (visitorId) {
|
|
|
const response = await getVisitorInfo(visitorId);
|
|
@@ -42,34 +40,27 @@ export default () => {
|
|
|
pageSize,
|
|
|
visitorId,
|
|
|
});
|
|
|
- const _totalCount = res.data.totalCount;
|
|
|
-
|
|
|
- if (_totalCount && res.data.data) {
|
|
|
- // 添加 visitTimes 第几轮访问
|
|
|
- const data = res.data;
|
|
|
- data.data = data.data.map((item: TSessionItem) => {
|
|
|
- let turns = _totalCount - (pageIndex-1)
|
|
|
- turns = turns <= 0 ? 1 : turns;
|
|
|
- return { ...item, visitTimes: turns };
|
|
|
- });
|
|
|
- return data;
|
|
|
- }
|
|
|
|
|
|
- // const data = res.data;
|
|
|
- // data.data = data.data.map((item: TSessionItem) => {
|
|
|
- // let turns = totalCount - pageIndex
|
|
|
- // turns = turns <= 0 ? 1 : turns;
|
|
|
- // return { ...item, visitTimes: turns };
|
|
|
- // });
|
|
|
-
|
|
|
- // return data;
|
|
|
+ let _totalCount = res.data.totalCount;
|
|
|
+ // 记录 totalCount
|
|
|
+ if (_totalCount && _totalCount !== null) {
|
|
|
+
|
|
|
+ setTotalCount(_totalCount)
|
|
|
+ }
|
|
|
+ return res.data;
|
|
|
};
|
|
|
|
|
|
-
|
|
|
-
|
|
|
- const { list, pageIndex, loadMore } = useLoadMoreInfinite<TSessionItem[]>(
|
|
|
+ const { list, loadMore } = useLoadMoreInfinite<TSessionItem[]>(
|
|
|
createKey(`api/v1/my/visitor/sessions${visitorId}`, 5),
|
|
|
- fetcher);
|
|
|
+ fetcher
|
|
|
+ );
|
|
|
+
|
|
|
+
|
|
|
+ const newList = list.map((item: TSessionItem, itemIndex: number) => {
|
|
|
+ let turns = totalCount - itemIndex
|
|
|
+ turns = turns <= 0 ? 1 : turns;
|
|
|
+ return { ...item, visitTimes: turns };
|
|
|
+ });
|
|
|
|
|
|
const onScrollToLower = () => {
|
|
|
loadMore();
|
|
@@ -78,8 +69,6 @@ export default () => {
|
|
|
useEffect(() => {
|
|
|
fetchData();
|
|
|
}, []);
|
|
|
-
|
|
|
-
|
|
|
|
|
|
|
|
|
return (
|
|
@@ -98,8 +87,8 @@ export default () => {
|
|
|
>
|
|
|
<View>
|
|
|
<View className="flex flex-col gap-16 px-16 w-full pb-100">
|
|
|
- {list.length <= 0 && <View className="pt-100"><EmptyData type={'chat'} /></View>}
|
|
|
- {list.map((item) => {
|
|
|
+ {newList.length <= 0 && <View className="pt-100"><EmptyData type={'chat'} /></View>}
|
|
|
+ {newList.map((item) => {
|
|
|
return (
|
|
|
<View className="w-full">
|
|
|
<View className="text-12 text-black leading-16">
|
|
@@ -107,7 +96,7 @@ export default () => {
|
|
|
</View>
|
|
|
<View className="flex h-full w-full">
|
|
|
<View className="text-14 font-normal text-black leading-20 flex flex-col items-end">
|
|
|
- <View>{item?.msgTime.slice(10, 16)} </View>
|
|
|
+ <View className="text-14 leading-24">{item?.msgTime.slice(10, 16)} </View>
|
|
|
</View>
|
|
|
<View className="flex flex-1 w-full">
|
|
|
<View className={style.gutterLine}>
|