feat:
This commit is contained in:
@ -269,6 +269,21 @@
|
||||
flex: 2 2;
|
||||
.button(@height: 88px; @fontSize: 32px; @fontWeight: 500; @borderRadius: 44px;);
|
||||
margin-left: 32px;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
|
||||
&-tag {
|
||||
position: absolute;
|
||||
right: 8px;
|
||||
top: -12px;
|
||||
font-weight: 400;
|
||||
font-size: 24px;
|
||||
line-height: 32px;
|
||||
color: #FFFFFF;
|
||||
padding: 2px 8px;
|
||||
background: #FF5051;
|
||||
border-radius: 20px 24px 24px 0px;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -12,8 +12,9 @@ import { JoinGroupHint } from '@/components/join-group-hint';
|
||||
import LoginButton from '@/components/login-button';
|
||||
import PageLoading from '@/components/page-loading';
|
||||
import { PrejobPopup } from '@/components/prejob-popup';
|
||||
import ProductJobDialog from '@/components/product-dialog/job';
|
||||
import ProductContactDialog from '@/components/product-dialog/contact';
|
||||
import CompanyPublishJobBuy from '@/components/product-dialog/steps-ui/company-publish-job-buy';
|
||||
import JobBuy from '@/components/product-dialog/steps-ui/job-buy';
|
||||
import { EventName, PageUrl, RoleType } from '@/constants/app';
|
||||
import { CertificationStatusType } from '@/constants/company';
|
||||
import { ReportEventId } from '@/constants/event';
|
||||
@ -27,6 +28,7 @@ import { RESPONSE_ERROR_CODE } from '@/http/constant';
|
||||
import { HttpError } from '@/http/error';
|
||||
import { JobDetails } from '@/types/job';
|
||||
import { IMaterialMessage } from '@/types/message';
|
||||
import { ProductInfo } from '@/types/product';
|
||||
import { switchRoleType } from '@/utils/app';
|
||||
import { copy, logWithPrefix } from '@/utils/common';
|
||||
import { reportEvent } from '@/utils/event';
|
||||
@ -35,13 +37,11 @@ import { calcDistance, isValidLocation } from '@/utils/location';
|
||||
import { requestProfileDetail } from '@/utils/material';
|
||||
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
||||
import { requestProductBalance, requestProductUseRecord } from '@/utils/product';
|
||||
import { requestProductBalance } from '@/utils/product';
|
||||
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
||||
import { getCommonShareMessage } from '@/utils/share';
|
||||
import { formatDate } from '@/utils/time';
|
||||
import Toast from '@/utils/toast';
|
||||
import { isNeedCreateMaterial } from '@/utils/user';
|
||||
|
||||
import './index.less';
|
||||
|
||||
const PREFIX = 'job-detail';
|
||||
@ -70,8 +70,15 @@ const getMapCallout = (data: JobDetails): MapProps.callout | undefined => {
|
||||
const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
const { data } = props;
|
||||
const [errorTips, setErrorTips] = useState<string>('');
|
||||
const [dialogVisible, setDialogVisible] = useState(false);
|
||||
const [contactDialogVisible, setContactDialogVisible] = useState(false);
|
||||
const [showMaterialGuide, setShowMaterialGuide] = useState(false);
|
||||
const [showBuyDialog, setShowBuyDialog] = useState(false);
|
||||
const [productInfo, setProductInfo] = useState<undefined | ProductInfo>();
|
||||
|
||||
const getProductBalance = useCallback(async () => {
|
||||
const [, resp] = await requestProductBalance(ProductType.VIP);
|
||||
setProductInfo(resp);
|
||||
}, [data.id]);
|
||||
|
||||
const handleClickContact = useCallback(async () => {
|
||||
log('handleClickContact');
|
||||
@ -79,21 +86,8 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
return;
|
||||
}
|
||||
reportEvent(ReportEventId.CLICK_JOB_CONTACT);
|
||||
try {
|
||||
const needCreateMaterial = await isNeedCreateMaterial();
|
||||
|
||||
if (data.sourcePlat !== 'bl') {
|
||||
if (needCreateMaterial) {
|
||||
const result = await requestProductUseRecord(ProductType.VIP, { jobId: data.id });
|
||||
if (!result) {
|
||||
const [time, isPaidVip] = await requestProductBalance(ProductType.VIP);
|
||||
if (time <= 0 || !isPaidVip) {
|
||||
setShowMaterialGuide(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (data.isAuthed) {
|
||||
const toUserId = data.userId;
|
||||
if (isChatWithSelf(toUserId)) {
|
||||
@ -102,7 +96,7 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
}
|
||||
const chat = await postCreateChat(toUserId);
|
||||
let materialMessage: null | IMaterialMessage = null;
|
||||
if (!needCreateMaterial) {
|
||||
if (!!productInfo?.isCreateResume) {
|
||||
const profile = await requestProfileDetail();
|
||||
if (profile) {
|
||||
materialMessage = {
|
||||
@ -124,7 +118,17 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
jobId: data.id,
|
||||
});
|
||||
} else {
|
||||
setDialogVisible(true);
|
||||
if (!productInfo?.isCreateResume && !productInfo?.isPaidVip && !productInfo?.freeBalance) {
|
||||
setShowMaterialGuide(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!productInfo.isPaidVip && !productInfo.freeBalance) {
|
||||
setShowBuyDialog(true);
|
||||
return;
|
||||
}
|
||||
|
||||
setContactDialogVisible(true);
|
||||
}
|
||||
} catch (error) {
|
||||
const e = error as HttpError;
|
||||
@ -135,17 +139,57 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
Toast.error('请求失败请重试');
|
||||
}
|
||||
}
|
||||
}, [data]);
|
||||
}, [data, productInfo?.freeBalance, productInfo?.isCreateResume, productInfo?.isPaidVip]);
|
||||
|
||||
const handleDialogHidden = useCallback(() => {
|
||||
setDialogVisible(false);
|
||||
setContactDialogVisible(false);
|
||||
}, []);
|
||||
const handleConfirmPrejob = useCallback((type: GET_CONTACT_TYPE) => {
|
||||
setShowMaterialGuide(false);
|
||||
if (GET_CONTACT_TYPE.VIP === type) {
|
||||
setDialogVisible(true);
|
||||
}
|
||||
const handleConfirmPrejob = useCallback(
|
||||
(type: GET_CONTACT_TYPE) => {
|
||||
setShowMaterialGuide(false);
|
||||
if (GET_CONTACT_TYPE.VIP === type) {
|
||||
getProductBalance();
|
||||
setContactDialogVisible(true);
|
||||
}
|
||||
},
|
||||
[getProductBalance]
|
||||
);
|
||||
|
||||
const handleAfterBuy = useCallback(() => {
|
||||
setShowBuyDialog(false);
|
||||
getProductBalance();
|
||||
setContactDialogVisible(true);
|
||||
}, [getProductBalance]);
|
||||
|
||||
const handleCancel = useCallback(() => {
|
||||
setShowBuyDialog(false);
|
||||
}, []);
|
||||
|
||||
// const unAuthedButtonText = useMemo(() => {
|
||||
// if (haveSeen) {
|
||||
// return '查看联系方式';
|
||||
// }
|
||||
//
|
||||
// if (productInfo?.isPaidVip) {
|
||||
// return '您是会员,可直接查看';
|
||||
// }
|
||||
//
|
||||
// if (productInfo?.freeBalance) {
|
||||
// return `还剩${productInfo.freeBalance}次查看次数`;
|
||||
// }
|
||||
//
|
||||
// return productInfo?.isCreateResume? '升级会员即可查看': '创建模卡,免费查看';
|
||||
// }, [productInfo, haveSeen]);
|
||||
|
||||
useEffect(() => {
|
||||
Taro.eventCenter.on(EventName.CREATE_PROFILE, getProductBalance);
|
||||
Taro.eventCenter.on(EventName.READ_CONTACT, getProductBalance);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
getProductBalance();
|
||||
}, [getProductBalance]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`${PREFIX}__footer`}>
|
||||
@ -153,14 +197,28 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
分享
|
||||
</Button>
|
||||
<LoginButton className={`${PREFIX}__contact-publisher`} onClick={handleClickContact}>
|
||||
{data.isAuthed ? '急招岗位可免费查看' : '查看联系方式'}
|
||||
{data.isAuthed ? '在线沟通' : '查看联系方式'}
|
||||
{data.isAuthed || productInfo?.content ? (
|
||||
<div className={`${PREFIX}__contact-publisher-tag`}>
|
||||
{data.isAuthed ? '急招岗位可免费查看' : productInfo?.content}
|
||||
</div>
|
||||
) : null}
|
||||
</LoginButton>
|
||||
</div>
|
||||
<div>
|
||||
{dialogVisible && <ProductJobDialog data={data} onClose={handleDialogHidden} />}
|
||||
{contactDialogVisible && (
|
||||
<ProductContactDialog productInfo={productInfo} data={data} onClose={handleDialogHidden} />
|
||||
)}
|
||||
{showMaterialGuide && (
|
||||
<PrejobPopup onCancel={() => setShowMaterialGuide(false)} onConfirm={handleConfirmPrejob} />
|
||||
)}
|
||||
{showBuyDialog && (
|
||||
<Dialog open onClose={handleCancel}>
|
||||
<Dialog.Content>
|
||||
<JobBuy onConfirm={handleAfterBuy} />
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
)}
|
||||
<CommonDialog
|
||||
content={errorTips}
|
||||
confirm="确定"
|
||||
|
||||
Reference in New Issue
Block a user