This commit is contained in:
chashaobao
2025-12-09 07:55:14 +08:00
parent 6c1e1cfd2d
commit e5facdff6a
2 changed files with 11 additions and 7 deletions

View File

@ -6,7 +6,7 @@ import { useCallback, useState } from 'react';
import { AgreementPopup } from '@/components/agreement-popup'; import { AgreementPopup } from '@/components/agreement-popup';
import LoginDialog from '@/components/login-dialog'; import LoginDialog from '@/components/login-dialog';
import useUserInfo from '@/hooks/use-user-info'; import useUserInfo from '@/hooks/use-user-info';
import { getAgreementSigned, isNeedLogin, setAgreementSigned } from '@/utils/user'; import { getAgreementSigned, isNeedLogin, requestUserInfo, setAgreementSigned } from '@/utils/user';
import './index.less'; import './index.less';
@ -18,13 +18,14 @@ export enum BindPhoneStatus {
export interface ILoginButtonProps extends ButtonProps { export interface ILoginButtonProps extends ButtonProps {
needPhone?: boolean; needPhone?: boolean;
needRefresh?: boolean;
needAssignment?: boolean; needAssignment?: boolean;
} }
const PREFIX = 'login-button'; const PREFIX = 'login-button';
function LoginButton(props: ILoginButtonProps) { function LoginButton(props: ILoginButtonProps) {
const { className, children, needPhone, onClick, ...otherProps } = props; const { className, children, needPhone, onClick, needRefresh, ...otherProps } = props;
const userInfo = useUserInfo(); const userInfo = useUserInfo();
const [loginVisible, setLoginVisible] = useState(false); const [loginVisible, setLoginVisible] = useState(false);
const [assignVisible, setAssignVisible] = useState(false); const [assignVisible, setAssignVisible] = useState(false);
@ -70,9 +71,12 @@ function LoginButton(props: ILoginButtonProps) {
const handleLoginSuccess = useCallback( const handleLoginSuccess = useCallback(
e => { e => {
setLoginVisible(false); setLoginVisible(false);
if (needRefresh) {
requestUserInfo();
}
onClick?.(e); onClick?.(e);
}, },
[onClick] [needRefresh, onClick]
); );
return ( return (

View File

@ -200,14 +200,14 @@ const AnchorFooter = (props: { data: JobDetails }) => {
<Button className={`${PREFIX}__share-button`} openType="share"> <Button className={`${PREFIX}__share-button`} openType="share">
</Button> </Button>
<LoginButton className={`${PREFIX}__contact-publisher`} onClick={handleClickContact}> <LoginButton needRefresh className={`${PREFIX}__contact-publisher`} onClick={handleClickContact}>
{data.isAuthed ? '在线沟通' : '查看联系方式'} {data.isAuthed ? '在线沟通' : '查看联系方式'}
{!productRecord && (data.isAuthed || productInfo?.content) ? ( {needPhone ? (
<div className={`${PREFIX}__contact-publisher-tag`}></div>
) : !productRecord && (data.isAuthed || productInfo?.content) ? (
<div className={`${PREFIX}__contact-publisher-tag`}> <div className={`${PREFIX}__contact-publisher-tag`}>
{data.isAuthed ? '急招岗位可免费查看' : productInfo?.content} {data.isAuthed ? '急招岗位可免费查看' : productInfo?.content}
</div> </div>
) : needPhone ? (
<div className={`${PREFIX}__contact-publisher-tag`}></div>
) : null} ) : null}
</LoginButton> </LoginButton>
</div> </div>