|
|
@@ -12,10 +12,12 @@ import IconHomeOutline from "@/components/icon/IconHomeOutline";
|
|
|
import AgentActionBar from "@/components/AgentPage/components/AgentActionBar";
|
|
|
import { useAgentStore } from "@/store/agentStore";
|
|
|
import style from "./index.module.less";
|
|
|
+import { DEFAULT_AVATAR_BG } from '@/config'
|
|
|
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";
|
|
|
|
|
|
export default function Profile() {
|
|
|
const { agentProfile, fetchAgentProfile, clearProfileAgent } = useAgentStore();
|
|
|
@@ -24,8 +26,15 @@ export default function Profile() {
|
|
|
|
|
|
const [agentId, setCurrentAgentId] = useState<null|string>(null)
|
|
|
const [shareKey, setShareKey] = useState<null|string>(null)
|
|
|
-
|
|
|
+ const [bg, setBg] = useState('')
|
|
|
+ const [isDefaultBg, setIsDefaultBg] = useState(false)
|
|
|
console.log(agentProfile, agentProfile?.status)
|
|
|
+
|
|
|
+ const setPageBg = (_agent:TAgentDetail)=> {
|
|
|
+ setBg(_agent?.avatarUrl ?? DEFAULT_AVATAR_BG)
|
|
|
+ setIsDefaultBg(!_agent?.avatarUrl)
|
|
|
+ }
|
|
|
+
|
|
|
// 定时 30 秒请求一次 log 接口
|
|
|
useSWR( (agentId && (agentProfile?.status === 'normal')) ? ['/blue-aiagent/api/v1/agent/visitor/log', {
|
|
|
agentId: agentId,
|
|
|
@@ -56,12 +65,14 @@ export default function Profile() {
|
|
|
};
|
|
|
if (originalScene.agentId) {
|
|
|
console.log("originalScene:", originalScene);
|
|
|
- fetchAgentProfile(
|
|
|
+ const _agent = await fetchAgentProfile(
|
|
|
originalScene.agentId,
|
|
|
originalScene.shareKey ?? ""
|
|
|
);
|
|
|
+ _agent && setPageBg(_agent)
|
|
|
setCurrentAgentId(originalScene.agentId)
|
|
|
setShareKey(originalScene.shareKey ?? "")
|
|
|
+
|
|
|
// postLog(originalScene.agentId, originalScene.shareKey ?? "");
|
|
|
}
|
|
|
} catch (e) {
|
|
|
@@ -74,6 +85,13 @@ export default function Profile() {
|
|
|
};
|
|
|
console.log(params.scene, "场景值");
|
|
|
|
|
|
+
|
|
|
+ const fetchPageData = async (params:any)=> {
|
|
|
+ const _agent = await fetchAgentProfile(params.agentId, params.shareKey ?? "");
|
|
|
+ _agent && setPageBg(_agent)
|
|
|
+ setCurrentAgentId(params.agentId)
|
|
|
+ setShareKey(params.shareKey ?? "")
|
|
|
+ }
|
|
|
|
|
|
useEffect(() => {
|
|
|
// 通过小程序码识别打开的页面
|
|
|
@@ -91,12 +109,12 @@ export default function Profile() {
|
|
|
}
|
|
|
}, []);
|
|
|
|
|
|
+
|
|
|
+
|
|
|
// 正常分享出来的页面
|
|
|
useEffect(() => {
|
|
|
if (params.agentId) {
|
|
|
- fetchAgentProfile(params.agentId, params.shareKey ?? "");
|
|
|
- setCurrentAgentId(params.agentId)
|
|
|
- setShareKey(params.shareKey ?? "")
|
|
|
+ fetchPageData(params)
|
|
|
// isLogin && postLog(params.agentId, params.shareKey);
|
|
|
}
|
|
|
}, [params.agentId]);
|
|
|
@@ -170,7 +188,7 @@ export default function Profile() {
|
|
|
}
|
|
|
|
|
|
return (
|
|
|
- <PageCustom styleBg={agentProfile?.avatarUrl}>
|
|
|
+ <PageCustom styleBg={bg}>
|
|
|
<View className="w-full">
|
|
|
<NavBarNormal blur scrollFadeIn scrollFadeInDelta={240} leftColumn={renderNavBarLeft}></NavBarNormal>
|
|
|
{agentProfile && <View className="blur-rounded-container">
|