feat: login whatever

This commit is contained in:
chashaobao 2025-06-15 01:09:30 +08:00
parent 5acc25c8c9
commit 80c0d71921
6 changed files with 26 additions and 10 deletions

View File

@ -8,7 +8,6 @@ import PhoneButton from '@/components/phone-button';
import { ProtocolPrivacy } from '@/components/protocol-privacy';
import SafeBottomPadding from '@/components/safe-bottom-padding';
import './index.less';
interface IProps {

View File

@ -5,7 +5,7 @@ import { useCallback, useState } from 'react';
import LoginDialog from '@/components/login-dialog';
import useUserInfo from '@/hooks/use-user-info';
import { isNeedLogin } from '@/utils/user';
import { getAgreementSigned, isNeedLogin } from '@/utils/user';
import './index.less';
@ -26,6 +26,7 @@ function LoginButton(props: ILoginButtonProps) {
const userInfo = useUserInfo();
const [visible, setVisible] = useState(false);
const needLogin = isNeedLogin(userInfo);
const needSign = !getAgreementSigned();
const onSuccess = useCallback(
e => {
@ -40,11 +41,13 @@ function LoginButton(props: ILoginButtonProps) {
<Button
{...otherProps}
className={classNames(PREFIX, className)}
onClick={needLogin ? () => setVisible(true) : onClick}
onClick={needLogin || needSign ? () => setVisible(true) : onClick}
>
{children}
</Button>
{visible && <LoginDialog onCancel={() => setVisible(false)} onSuccess={onSuccess} needPhone={needPhone} />}
{visible && (
<LoginDialog disableCheck onCancel={() => setVisible(false)} onSuccess={onSuccess} needPhone={needPhone} />
)}
</>
);
}

View File

@ -12,6 +12,7 @@ import './index.less';
interface IProps {
title?: string;
onCancel: () => void;
disableCheck?: boolean;
needPhone?: IPhoneButtonProps['needPhone'];
onSuccess?: IPhoneButtonProps['onSuccess'];
onBindPhone?: IPhoneButtonProps['onBindPhone'];
@ -20,8 +21,15 @@ interface IProps {
const PREFIX = 'login-dialog';
export default function LoginDialog(props: IProps) {
const { title = '使用播络服务前,请先登录', needPhone, onSuccess, onCancel, onBindPhone } = props;
const [checked, setChecked] = useState(false);
const {
title = '使用播络服务前,请先登录',
disableCheck = false,
needPhone,
onSuccess,
onCancel,
onBindPhone,
} = props;
const [checked, setChecked] = useState(disableCheck);
const handleTipCheck = useCallback(() => {
Toast.info('请先阅读并同意协议');
@ -50,7 +58,9 @@ export default function LoginDialog(props: IProps) {
<Button className={`${PREFIX}__cancel-button`} onClick={onCancel}>
</Button>
{!disableCheck && (
<ProtocolPrivacyCheckbox checked={checked} onChange={setChecked} className={`${PREFIX}__checkbox`} />
)}
</div>
</Dialog.Content>
</Dialog>

View File

@ -60,7 +60,9 @@ export default function PartnerBanner() {
)}
<div className={`${PREFIX}__close`} onClick={handlePartnerBannerClose} />
</div>
{visible && <LoginDialog onCancel={() => setVisible(false)} onSuccess={handleBind} needPhone={needPhone} />}
{visible && (
<LoginDialog disableCheck onCancel={() => setVisible(false)} onSuccess={handleBind} needPhone={needPhone} />
)}
</>
);
}

View File

@ -39,7 +39,9 @@ function JoinEntry({ onBindSuccess }: JoinEntryProps) {
</Button>
)}
</div>
{visible && <LoginDialog onCancel={() => setVisible(false)} onSuccess={onBindSuccess} needPhone={needPhone} />}
{visible && (
<LoginDialog disableCheck onCancel={() => setVisible(false)} onSuccess={onBindSuccess} needPhone={needPhone} />
)}
</>
);
}

View File

@ -62,7 +62,7 @@ const getSalaryPrice = (fullSalary?: SalaryRange, partSalary?: SalaryRange) => {
function ProfileIntentionFragment(props: IProps, ref) {
const { profile } = props;
const [cityCodes, setCityCodes] = useState(calcInitCityCodes(profile.cityCodes));
const [cityCodes, setCityCodes] = useState(calcInitCityCodes(profile.cityCodes || ''));
const [employType, setEmployType] = useState(profile.employType);
const [fullSalary, setFullSalary] = useState(calcSalarySelect(profile, true));
const [partSalary, setPartSalary] = useState(calcSalarySelect(profile, false));