|
|
@@ -19,18 +19,24 @@ import { sceneUnzip } from "@/service/wechat";
|
|
|
import { postLog } from "./profile";
|
|
|
import { useIsLogin } from "@/xiaolanbenlib/hooks/data/useAuth";
|
|
|
import useSWR from "swr";
|
|
|
-import { TAgentDetail } from "@/types/agent";
|
|
|
+import type { TAgentDetail } from "@/types/agent";
|
|
|
+import { useAppStore } from "@/store/appStore";
|
|
|
|
|
|
export default function Profile() {
|
|
|
const [agentProfile, setAgentProfile] = useState<TAgentDetail|null>(null)
|
|
|
// const { agentProfile, clearProfileAgent } = useAgentStore();
|
|
|
const params = useRouter().params;
|
|
|
const isLogin = useIsLogin();
|
|
|
+ const windowHeight = useAppStore((state)=> state.windowHeight);
|
|
|
+ const headerHeight = useAppStore((state)=> state.headerHeight);
|
|
|
+
|
|
|
+ const components = agentProfile?.components ?? []
|
|
|
|
|
|
const [agentId, setCurrentAgentId] = useState<null|string>(null)
|
|
|
const [shareKey, setShareKey] = useState<null|string>(null)
|
|
|
const [bg, setBg] = useState('')
|
|
|
-
|
|
|
+ const [marginTop, setMarginTop] = useState(0);
|
|
|
+
|
|
|
console.log(agentProfile, agentProfile?.status)
|
|
|
|
|
|
const fetchAgentProfile = async (agentId: string, shareKey?:string) => {
|
|
|
@@ -53,15 +59,15 @@ export default function Profile() {
|
|
|
|
|
|
// 定时 30 秒请求一次 log 接口
|
|
|
useSWR( (agentId && (agentProfile?.status === 'normal')) ? ['/blue-aiagent/api/v1/agent/visitor/log', {
|
|
|
- agentId: agentId,
|
|
|
+ agentId: agentId,
|
|
|
shareKey: shareKey,
|
|
|
}] : false
|
|
|
,
|
|
|
([_url, data]) => {
|
|
|
-
|
|
|
+
|
|
|
if(isLogin){
|
|
|
postLog(data.agentId, data.shareKey ?? '')
|
|
|
- }
|
|
|
+ }
|
|
|
},
|
|
|
{
|
|
|
refreshInterval: 30000,
|
|
|
@@ -88,7 +94,7 @@ export default function Profile() {
|
|
|
_agent && setPageBg(_agent)
|
|
|
setCurrentAgentId(originalScene.agentId)
|
|
|
setShareKey(originalScene.shareKey ?? "")
|
|
|
-
|
|
|
+
|
|
|
// postLog(originalScene.agentId, originalScene.shareKey ?? "");
|
|
|
}
|
|
|
} catch (e) {
|
|
|
@@ -108,7 +114,7 @@ export default function Profile() {
|
|
|
setCurrentAgentId(params.agentId)
|
|
|
setShareKey(params.shareKey ?? "")
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
useEffect(() => {
|
|
|
// 通过小程序码识别打开的页面
|
|
|
const scene = decodeURIComponent(params.scene ?? "");
|
|
|
@@ -133,6 +139,25 @@ export default function Profile() {
|
|
|
}
|
|
|
}, [params.agentId]);
|
|
|
|
|
|
+
|
|
|
+ useEffect(()=> {
|
|
|
+ const query = Taro.createSelectorQuery();
|
|
|
+ // 获取滚动容器高度
|
|
|
+ query
|
|
|
+ .select('#BlurRoundedContainer')
|
|
|
+ .boundingClientRect((rect: any) => {
|
|
|
+ if (rect) {
|
|
|
+ console.log('ScrollView height:', rect.height, windowHeight, headerHeight)
|
|
|
+ if(rect.height + 296 < windowHeight - headerHeight){
|
|
|
+ setMarginTop(windowHeight - headerHeight - rect.height);
|
|
|
+ }else{
|
|
|
+ setMarginTop(296);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .exec();
|
|
|
+ }, [components])
|
|
|
+
|
|
|
const renderNavBarLeft = () => {
|
|
|
const pages = getCurrentPages();
|
|
|
console.log(pages, "当前页面");
|
|
|
@@ -177,7 +202,7 @@ export default function Profile() {
|
|
|
});
|
|
|
}}>前往访问</View>
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
// 下线了
|
|
|
return <View className="button-rounded-big" onClick={()=> {
|
|
|
Taro.navigateBack()
|
|
|
@@ -205,11 +230,11 @@ export default function Profile() {
|
|
|
<PageCustom styleBg={bg}>
|
|
|
<View className="w-full">
|
|
|
<NavBarNormal blur scrollFadeIn scrollFadeInDelta={240} leftColumn={renderNavBarLeft}></NavBarNormal>
|
|
|
- {agentProfile && <View className="blur-rounded-container">
|
|
|
+ {agentProfile && <View className="blur-rounded-container" id="BlurRoundedContainer" style={{marginTop: `${marginTop}px`}}>
|
|
|
<AgentActionBar isVisitor agent={agentProfile}></AgentActionBar>
|
|
|
<View className="flex flex-col w-full p-16 gap-12">
|
|
|
<ComponentList
|
|
|
- components={agentProfile.components ?? []}
|
|
|
+ components={components}
|
|
|
></ComponentList>
|
|
|
</View>
|
|
|
</View>}
|