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 { ProtocolPrivacy } from '@/components/protocol-privacy';
import SafeBottomPadding from '@/components/safe-bottom-padding'; import SafeBottomPadding from '@/components/safe-bottom-padding';
import './index.less'; import './index.less';
interface IProps { interface IProps {

View File

@ -5,7 +5,7 @@ import { useCallback, useState } from 'react';
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 { isNeedLogin } from '@/utils/user'; import { getAgreementSigned, isNeedLogin } from '@/utils/user';
import './index.less'; import './index.less';
@ -26,6 +26,7 @@ function LoginButton(props: ILoginButtonProps) {
const userInfo = useUserInfo(); const userInfo = useUserInfo();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const needLogin = isNeedLogin(userInfo); const needLogin = isNeedLogin(userInfo);
const needSign = !getAgreementSigned();
const onSuccess = useCallback( const onSuccess = useCallback(
e => { e => {
@ -40,11 +41,13 @@ function LoginButton(props: ILoginButtonProps) {
<Button <Button
{...otherProps} {...otherProps}
className={classNames(PREFIX, className)} className={classNames(PREFIX, className)}
onClick={needLogin ? () => setVisible(true) : onClick} onClick={needLogin || needSign ? () => setVisible(true) : onClick}
> >
{children} {children}
</Button> </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 { interface IProps {
title?: string; title?: string;
onCancel: () => void; onCancel: () => void;
disableCheck?: boolean;
needPhone?: IPhoneButtonProps['needPhone']; needPhone?: IPhoneButtonProps['needPhone'];
onSuccess?: IPhoneButtonProps['onSuccess']; onSuccess?: IPhoneButtonProps['onSuccess'];
onBindPhone?: IPhoneButtonProps['onBindPhone']; onBindPhone?: IPhoneButtonProps['onBindPhone'];
@ -20,8 +21,15 @@ interface IProps {
const PREFIX = 'login-dialog'; const PREFIX = 'login-dialog';
export default function LoginDialog(props: IProps) { export default function LoginDialog(props: IProps) {
const { title = '使用播络服务前,请先登录', needPhone, onSuccess, onCancel, onBindPhone } = props; const {
const [checked, setChecked] = useState(false); title = '使用播络服务前,请先登录',
disableCheck = false,
needPhone,
onSuccess,
onCancel,
onBindPhone,
} = props;
const [checked, setChecked] = useState(disableCheck);
const handleTipCheck = useCallback(() => { const handleTipCheck = useCallback(() => {
Toast.info('请先阅读并同意协议'); Toast.info('请先阅读并同意协议');
@ -50,7 +58,9 @@ export default function LoginDialog(props: IProps) {
<Button className={`${PREFIX}__cancel-button`} onClick={onCancel}> <Button className={`${PREFIX}__cancel-button`} onClick={onCancel}>
</Button> </Button>
<ProtocolPrivacyCheckbox checked={checked} onChange={setChecked} className={`${PREFIX}__checkbox`} /> {!disableCheck && (
<ProtocolPrivacyCheckbox checked={checked} onChange={setChecked} className={`${PREFIX}__checkbox`} />
)}
</div> </div>
</Dialog.Content> </Dialog.Content>
</Dialog> </Dialog>

View File

@ -60,7 +60,9 @@ export default function PartnerBanner() {
)} )}
<div className={`${PREFIX}__close`} onClick={handlePartnerBannerClose} /> <div className={`${PREFIX}__close`} onClick={handlePartnerBannerClose} />
</div> </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> </Button>
)} )}
</div> </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) { function ProfileIntentionFragment(props: IProps, ref) {
const { profile } = props; const { profile } = props;
const [cityCodes, setCityCodes] = useState(calcInitCityCodes(profile.cityCodes)); const [cityCodes, setCityCodes] = useState(calcInitCityCodes(profile.cityCodes || ''));
const [employType, setEmployType] = useState(profile.employType); const [employType, setEmployType] = useState(profile.employType);
const [fullSalary, setFullSalary] = useState(calcSalarySelect(profile, true)); const [fullSalary, setFullSalary] = useState(calcSalarySelect(profile, true));
const [partSalary, setPartSalary] = useState(calcSalarySelect(profile, false)); const [partSalary, setPartSalary] = useState(calcSalarySelect(profile, false));