import { useState } from "react"; import { View } from "@tarojs/components"; import Taro, { useRouter } from "@tarojs/taro"; import PageCustom from "@/components/page-custom/index"; import NavBarNormal from "@/components/NavBarNormal/index"; import ButtonCardAdd from "@/components/button-card-add"; import ContactCard from "@/components/AgentCard/index"; import style from './index.module.less' import Popup from "@/components/popup/popup"; import WemetaTabs from "@/components/wemeta-tabs/index"; import BottomBar from "@/components/BottomBar"; import { TContactItem } from "@/types/contact"; import AgentScrollList from './components/MyContactsScrollList' import MyAgentsScrollList from './components/MyAgentsScrollList' import MyEntAgentsScrollList from './components/MyEntAgentsScrollList' import { TAgent } from "@/types/agent"; import IconMoreBlack from "@/components/icon/IconMoreBlack"; import PopupSheets from "@/components/popup/popup-sheets"; import { EComponentType } from "@/consts/enum"; import { useComponentStore } from "@/store/componentStore"; import { useAgentStore } from "@/store/agentStore"; export default function Index() { const { saveComponent } = useComponentStore(); let currentComponent = useComponentStore((state) => state.currentComponent); const loading = useComponentStore((state) => state.loading); const prevData = currentComponent?.data.values ?? [] const [picked, setPicked] = useState<(TContactItem|TAgent)[]>(prevData); const [agents, setAgents] = useState<(TContactItem|TAgent)[]>(prevData); const [current, setCurrent] = useState<(TContactItem|TAgent)|null>(null); const agent = useAgentStore((state)=> state.agent) // 是否显示选择器 const [show, setShow] = useState(false); const [showPopupSheets, setShowPopupSheets] = useState(false); const handleSubmit = async () => { if(!currentComponent?.data?.id){ return } if (loading) { return; } // 过虑掉 email, mobile, qrCodeUrl const newPicked = picked.map(item=> { return { ...item, email: undefined, mobile: undefined, qrCodeUrl: undefined, } }) const c = { data: { values: newPicked, layout: currentComponent.data.layout ?? 'mini', id: currentComponent.data.id, index: currentComponent.data.index, }, enabled: currentComponent?.enabled ?? true, type: EComponentType.bluebook, }; await saveComponent(c); Taro.navigateBack(); }; const handleClickMore = (item: TAgent|TContactItem) => { setCurrent(item) setShowPopupSheets(true) }; const handleClick = () => { setShow(true) } const handlePicked = () => { setShow(false) setPicked(agents) } const visitorCurrent = ()=> { if(!current){ return; } setShowPopupSheets(false) Taro.navigateTo({ url: "/pages/profile/index?agentId=" + current?.agentId, }); setCurrent(null) } const removePicked = ()=> { if(!current){ return; } setShowPopupSheets(false) const restAgent = picked.filter(item => item.agentId !== current.agentId); setPicked(restAgent) setAgents(restAgent) setCurrent(null) } const renderContactList = () => { if (!picked.length) { return ( <> ); } return ( {picked.map((item) => { return ( { return ( handleClickMore(item)}> ); }} > ); })} ); }; const colleagues = { key: "3", label: "企业同事", children: ( ), } const tabsBaseList = [ { key: "1", label: "我创建的", children: ( ), }, { key: "2", label: "我的联系⼈", children: ( ), }, ] const tabList = agent?.isEnt ? [...tabsBaseList, colleagues] : tabsBaseList; return ( 智能体 {renderContactList()} 保存 引用 ); }