import { useRef, useEffect } from 'react' import useShare from '@/utils/hooks/useShare' import { ROLE_CODE } from '@/constants/user' export default function useBuildingShare(person, buildingInfo, router, paramsRef) { const shareRef = useRef() const trackRef = useRef() useEffect(() => { if (buildingInfo?.buildingId) { const shareContents = (buildingInfo.shareContents || [])[0] || {} shareRef.current = { title: shareContents.shareContentTitle || buildingInfo.buildingName, path: `${router.path}?${paramsRef.current}`, image: shareContents.shareContentImg, } } // 判断当前人员是否置业顾问 const consultant = person.personType === ROLE_CODE.CONSULTANT ? { id: person.personId } : {} trackRef.current = { targetId: buildingInfo?.buildingId, consultantId: consultant.id, sharePersonId: person.personId, buildingId: buildingInfo?.buildingId, } // eslint-disable-next-line react-hooks/exhaustive-deps }, [buildingInfo, router.path]) useShare(shareRef, trackRef) }