feat
This commit is contained in:
@ -28,7 +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 { GetProductIsUnlockResponse, ProductInfo } from '@/types/product';
|
||||
import { switchRoleType } from '@/utils/app';
|
||||
import { copy, logWithPrefix } from '@/utils/common';
|
||||
import { reportEvent } from '@/utils/event';
|
||||
@ -37,7 +37,7 @@ import { calcDistance, isValidLocation } from '@/utils/location';
|
||||
import { requestProfileDetail } from '@/utils/material';
|
||||
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
||||
import { requestProductBalance } from '@/utils/product';
|
||||
import { requestProductBalance, requestProductUseRecord } from '@/utils/product';
|
||||
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
||||
import { getCommonShareMessage } from '@/utils/share';
|
||||
import { formatDate } from '@/utils/time';
|
||||
@ -74,11 +74,17 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
const [showMaterialGuide, setShowMaterialGuide] = useState(false);
|
||||
const [showBuyDialog, setShowBuyDialog] = useState(false);
|
||||
const [productInfo, setProductInfo] = useState<undefined | ProductInfo>();
|
||||
const [productRecord, setProductRecord] = useState<undefined | GetProductIsUnlockResponse>();
|
||||
|
||||
const getProductRecord = useCallback(async () => {
|
||||
const result = await requestProductUseRecord(ProductType.VIP, { jobId: data.id });
|
||||
setProductRecord(result);
|
||||
}, [data.id]);
|
||||
|
||||
const getProductBalance = useCallback(async () => {
|
||||
const [, resp] = await requestProductBalance(ProductType.VIP);
|
||||
setProductInfo(resp);
|
||||
}, [data.id]);
|
||||
}, []);
|
||||
|
||||
const handleClickContact = useCallback(async () => {
|
||||
log('handleClickContact');
|
||||
@ -155,9 +161,9 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
[getProductBalance]
|
||||
);
|
||||
|
||||
const handleAfterBuy = useCallback(() => {
|
||||
const handleAfterBuy = useCallback(async () => {
|
||||
setShowBuyDialog(false);
|
||||
getProductBalance();
|
||||
await getProductBalance();
|
||||
setContactDialogVisible(true);
|
||||
}, [getProductBalance]);
|
||||
|
||||
@ -184,12 +190,21 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
useEffect(() => {
|
||||
Taro.eventCenter.on(EventName.CREATE_PROFILE, getProductBalance);
|
||||
Taro.eventCenter.on(EventName.READ_CONTACT, getProductBalance);
|
||||
}, []);
|
||||
|
||||
return () => {
|
||||
Taro.eventCenter.off(EventName.CREATE_PROFILE);
|
||||
Taro.eventCenter.off(EventName.READ_CONTACT);
|
||||
};
|
||||
}, [getProductBalance]);
|
||||
|
||||
useEffect(() => {
|
||||
getProductBalance();
|
||||
}, [getProductBalance]);
|
||||
|
||||
useEffect(() => {
|
||||
getProductRecord();
|
||||
}, [getProductRecord]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={`${PREFIX}__footer`}>
|
||||
@ -198,7 +213,7 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
</Button>
|
||||
<LoginButton className={`${PREFIX}__contact-publisher`} onClick={handleClickContact}>
|
||||
{data.isAuthed ? '在线沟通' : '查看联系方式'}
|
||||
{data.isAuthed || productInfo?.content ? (
|
||||
{!productRecord && (data.isAuthed || productInfo?.content) ? (
|
||||
<div className={`${PREFIX}__contact-publisher-tag`}>
|
||||
{data.isAuthed ? '急招岗位可免费查看' : productInfo?.content}
|
||||
</div>
|
||||
@ -207,7 +222,12 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
</div>
|
||||
<div>
|
||||
{contactDialogVisible && (
|
||||
<ProductContactDialog productInfo={productInfo} data={data} onClose={handleDialogHidden} />
|
||||
<ProductContactDialog
|
||||
productInfo={productInfo}
|
||||
productRecord={productRecord}
|
||||
data={data}
|
||||
onClose={handleDialogHidden}
|
||||
/>
|
||||
)}
|
||||
{showMaterialGuide && (
|
||||
<PrejobPopup onCancel={() => setShowMaterialGuide(false)} onConfirm={handleConfirmPrejob} />
|
||||
|
||||
Reference in New Issue
Block a user