feat: login

This commit is contained in:
魔力叉烧包
2025-06-08 22:57:23 +08:00
parent 082c5483c5
commit 5acc25c8c9
9 changed files with 190 additions and 36 deletions

View File

@ -0,0 +1,41 @@
@import '@/styles/common.less';
@import '@/styles/variables.less';
.agreement-popup {
&__content {
.flex-column();
padding: 40px 32px;
}
&__title {
font-size: 32px;
font-weight: 500;
line-height: 48px;
color: @blColor;;
margin-bottom: 24px;
}
&__body {
font-weight: 400;
font-size: 28px;
line-height: 40px;
color: @blColor;
margin-bottom: 24px;
align-self: flex-start;
};
&__btn-group {
margin-top: 32px;
.flex-row();
gap: 30px;
}
&__confirm-button {
.button(@width: 230px, @height: 72px, @fontSize: 28px, @fontWeight: 400, @borderRadius: 44px);
}
&__cancel-button {
.button(@width: 230px, @height: 72px, @fontSize: 28px, @fontWeight: 400, @borderRadius: 44px, @highlight: 0);
}
}

View File

@ -0,0 +1,66 @@
import { Button } from '@tarojs/components';
import { Popup } from '@taroify/core';
import { useCallback } from 'react';
import { BindPhoneStatus } from '@/components/login-button';
import PhoneButton from '@/components/phone-button';
import { ProtocolPrivacy } from '@/components/protocol-privacy';
import SafeBottomPadding from '@/components/safe-bottom-padding';
import './index.less';
interface IProps {
open: boolean;
onCancel: () => void;
onConfirm: () => void;
needPhone?: boolean;
}
const PREFIX = 'agreement-popup';
export function AgreementPopup({ open, onCancel, onConfirm, needPhone }: IProps) {
const handleBindPhone = useCallback(
status => {
if (status === BindPhoneStatus.Success) {
onConfirm();
} else {
onCancel();
}
},
[onCancel, onConfirm]
);
if (!open) {
return null;
}
return (
<Popup rounded className={PREFIX} placement="bottom" open={open} onClose={onCancel}>
<div className={`${PREFIX}__content`}>
<div className={`${PREFIX}__title`}></div>
<div className={`${PREFIX}__body`}>
<div></div>
<div>使</div>
</div>
<ProtocolPrivacy divider />
<div className={`${PREFIX}__btn-group`}>
<Button className={`${PREFIX}__cancel-button`} onClick={onCancel}>
</Button>
{needPhone ? (
<PhoneButton className={`${PREFIX}__confirm-button`} needPhone onBindPhone={handleBindPhone}>
</PhoneButton>
) : (
<Button className={`${PREFIX}__confirm-button`} onClick={onConfirm}>
</Button>
)}
</div>
</div>
<SafeBottomPadding />
</Popup>
);
}

View File

@ -18,6 +18,7 @@ import './index.less';
interface IProps {
data: AnchorInfo;
jobId?: string;
validator: (onSuccess: () => void) => void;
}
const PREFIX = 'anchor-card';
@ -34,14 +35,17 @@ const getSalary = (data: AnchorInfo) => {
};
function AnchorCard(props: IProps) {
const { data, jobId } = props;
const { data, jobId, validator } = props;
const style = data.isRead ? ({ '--read-color': '#999999' } as React.CSSProperties) : {};
const cover = (data.materialVideoInfoList.find(video => video.isDefault) || data.materialVideoInfoList[0])?.coverUrl;
const handleClick = useCallback(
() => navigateTo(PageUrl.MaterialView, { jobId, resumeId: data.id, source: MaterialViewSource.AnchorList }),
[data, jobId]
);
const handleNavTo = useCallback(() => {
navigateTo(PageUrl.MaterialView, { jobId, resumeId: data.id, source: MaterialViewSource.AnchorList });
}, [data, jobId]);
const handleClick = useCallback(() => {
validator(handleNavTo);
}, [handleNavTo, validator]);
return (
<div className={PREFIX} style={style} onClick={handleClick}>

View File

@ -9,9 +9,13 @@ import AnchorCard from '@/components/anchor-card';
import ListPlaceholder from '@/components/list-placeholder';
import { EventName } from '@/constants/app';
import { AnchorSortType } from '@/constants/material';
import useUserInfo from '@/hooks/use-user-info';
import { AnchorInfo, GetAnchorListRequest, IAnchorFilters } from '@/types/material';
import { logWithPrefix } from '@/utils/common';
import { requestAnchorList as requestData } from '@/utils/material';
import { getAgreementSigned, isNeedPhone, setAgreementSigned } from '@/utils/user';
import { AgreementPopup } from '../agreement-popup';
import './index.less';
@ -55,6 +59,10 @@ function AnchorList(props: IAnchorListProps) {
const requestProps = useRef<IRequestProps>({});
const prevRequestProps = useRef<IRequestProps>({});
const onListEmptyRef = useRef(onListEmpty);
const [open, setOpen] = useState(false);
const successCallback = useRef<() => void>(() => {});
const userInfo = useUserInfo();
const needPhone = isNeedPhone(userInfo);
const handleRefresh = useCallback(async () => {
log('start pull refresh');
@ -120,6 +128,27 @@ function AnchorList(props: IAnchorListProps) {
[dataList]
);
const handleCancel = useCallback(() => {
setOpen(false);
setAgreementSigned(false);
}, []);
const handleConfirm = useCallback(() => {
setOpen(false);
setAgreementSigned(true);
//TODO 没手机号要授权一下; 必须要开弹窗才可以,与需求不符
successCallback.current();
}, []);
const validator = (onSuccess: () => void) => {
if (getAgreementSigned()) {
onSuccess();
} else {
successCallback.current = onSuccess;
setOpen(true);
}
};
useEffect(() => {
onListEmptyRef.current = onListEmpty;
}, [onListEmpty]);
@ -183,26 +212,29 @@ function AnchorList(props: IAnchorListProps) {
}, [jobId, ready, filters, cityCode, sortType]);
return (
<PullRefresh
className={classNames(`${PREFIX}__pull-refresh`, className)}
loading={refreshing}
onRefresh={handleRefresh}
disabled={refreshDisabled || !ready}
>
<List
hasMore={hasMore}
onLoad={handleLoadMore}
loading={loadingMore || refreshing}
disabled={loadMoreError || !ready}
fixedHeight={typeof listHeight !== 'undefined'}
style={listHeight ? { height: `${listHeight}px` } : undefined}
<>
<PullRefresh
className={classNames(`${PREFIX}__pull-refresh`, className)}
loading={refreshing}
onRefresh={handleRefresh}
disabled={refreshDisabled || !ready}
>
{dataList.map(item => (
<AnchorCard data={item} jobId={jobId} key={item.id} />
))}
<ListPlaceholder hasMore={hasMore} loadingMore={loadingMore} loadMoreError={loadMoreError} />
</List>
</PullRefresh>
<List
hasMore={hasMore}
onLoad={handleLoadMore}
loading={loadingMore || refreshing}
disabled={loadMoreError || !ready}
fixedHeight={typeof listHeight !== 'undefined'}
style={listHeight ? { height: `${listHeight}px` } : undefined}
>
{dataList.map(item => (
<AnchorCard data={item} jobId={jobId} key={item.id} validator={validator} />
))}
<ListPlaceholder hasMore={hasMore} loadingMore={loadingMore} loadMoreError={loadMoreError} />
</List>
</PullRefresh>
<AgreementPopup open={open} onCancel={handleCancel} onConfirm={handleConfirm} needPhone={needPhone} />
</>
);
}