featL
This commit is contained in:
@ -12,9 +12,8 @@ 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 ProductContactDialog from '@/components/product-dialog/contact';
|
||||
import ProductJobContactDialog from '@/components/product-dialog/job-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';
|
||||
@ -71,13 +70,13 @@ const getMapCallout = (data: JobDetails): MapProps.callout | undefined => {
|
||||
const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
const { data } = props;
|
||||
const [errorTips, setErrorTips] = useState<string>('');
|
||||
const [contactDialogVisible, setContactDialogVisible] = useState(false);
|
||||
const [showJobContactDialog, setShowJobContactDialog] = useState(false);
|
||||
const [showMaterialGuide, setShowMaterialGuide] = useState(false);
|
||||
const [showBuyDialog, setShowBuyDialog] = useState(false);
|
||||
const [productInfo, setProductInfo] = useState<undefined | ProductInfo>();
|
||||
const [productRecord, setProductRecord] = useState<undefined | GetProductIsUnlockResponse>();
|
||||
const userInfo = useUserInfo();
|
||||
const needPhone = isNeedPhone(userInfo);
|
||||
|
||||
const getProductRecord = useCallback(async () => {
|
||||
const result = await requestProductUseRecord(ProductType.VIP, { jobId: data.id });
|
||||
setProductRecord(result);
|
||||
@ -86,6 +85,7 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
const getProductBalance = useCallback(async () => {
|
||||
const [, resp] = await requestProductBalance(ProductType.VIP);
|
||||
setProductInfo(resp);
|
||||
return resp;
|
||||
}, []);
|
||||
|
||||
const handleClickContact = useCallback(async () => {
|
||||
@ -126,17 +126,13 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
jobId: data.id,
|
||||
});
|
||||
} else {
|
||||
// Show material guide if no resume and no VIP and no free balance
|
||||
if (!productInfo?.isCreateResume && !productInfo?.isPaidVip && !productInfo?.freeBalance) {
|
||||
setShowMaterialGuide(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!productRecord && !productInfo.isPaidVip && !productInfo.freeBalance) {
|
||||
setShowBuyDialog(true);
|
||||
return;
|
||||
}
|
||||
|
||||
setContactDialogVisible(true);
|
||||
// Open integrated dialog - it handles buy + contact internally
|
||||
setShowJobContactDialog(true);
|
||||
}
|
||||
} catch (error) {
|
||||
const e = error as HttpError;
|
||||
@ -149,33 +145,24 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
}
|
||||
}, [data, productInfo?.freeBalance, productInfo?.isCreateResume, productInfo?.isPaidVip]);
|
||||
|
||||
const handleDialogHidden = useCallback(() => {
|
||||
setContactDialogVisible(false);
|
||||
}, []);
|
||||
const handleDialogClose = useCallback(() => {
|
||||
setShowJobContactDialog(false);
|
||||
// Refresh data after dialog closes
|
||||
getProductRecord();
|
||||
}, [getProductRecord]);
|
||||
|
||||
const handleConfirmPrejob = useCallback(
|
||||
(type: GET_CONTACT_TYPE) => {
|
||||
setShowMaterialGuide(false);
|
||||
if (GET_CONTACT_TYPE.VIP === type) {
|
||||
getProductBalance();
|
||||
setContactDialogVisible(true);
|
||||
getProductBalance().then(() => {
|
||||
setShowJobContactDialog(true);
|
||||
});
|
||||
}
|
||||
},
|
||||
[getProductBalance]
|
||||
);
|
||||
|
||||
const handleAfterBuy = useCallback(async () => {
|
||||
setShowBuyDialog(false);
|
||||
Taro.showLoading({ mask: true, title: '加载中...' });
|
||||
await getProductBalance();
|
||||
console.log('购买后重新获取次数');
|
||||
setContactDialogVisible(true);
|
||||
Taro.hideLoading();
|
||||
}, [getProductBalance]);
|
||||
|
||||
const handleCancel = useCallback(() => {
|
||||
setShowBuyDialog(false);
|
||||
}, []);
|
||||
|
||||
// const unAuthedButtonText = useMemo(() => {
|
||||
// if (haveSeen) {
|
||||
// return '查看联系方式';
|
||||
@ -194,11 +181,8 @@ 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]);
|
||||
|
||||
@ -228,12 +212,13 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
</LoginButton>
|
||||
</div>
|
||||
<div>
|
||||
{contactDialogVisible && (
|
||||
<ProductContactDialog
|
||||
productInfo={productInfo}
|
||||
productRecord={productRecord}
|
||||
{showJobContactDialog && (
|
||||
<ProductJobContactDialog
|
||||
data={data}
|
||||
onClose={handleDialogHidden}
|
||||
productRecord={productRecord}
|
||||
productInfo={productInfo}
|
||||
onRefreshBalance={getProductBalance}
|
||||
onClose={handleDialogClose}
|
||||
/>
|
||||
)}
|
||||
{showMaterialGuide && (
|
||||
@ -243,13 +228,6 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
onConfirm={handleConfirmPrejob}
|
||||
/>
|
||||
)}
|
||||
{showBuyDialog && (
|
||||
<Dialog open onClose={handleCancel}>
|
||||
<Dialog.Content>
|
||||
<JobBuy onConfirm={handleAfterBuy} isCreateResume={productInfo?.isCreateResume} />
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
)}
|
||||
<CommonDialog
|
||||
content={errorTips}
|
||||
confirm="确定"
|
||||
|
||||
Reference in New Issue
Block a user