feat
This commit is contained in:
@ -7,18 +7,19 @@ import { DialogStatus, PREFIX } from '@/components/product-dialog/const';
|
|||||||
import ContactCustomerService from '@/components/product-dialog/steps-ui/job-contact-customer';
|
import ContactCustomerService from '@/components/product-dialog/steps-ui/job-contact-customer';
|
||||||
import ContactDirect from '@/components/product-dialog/steps-ui/job-contact-direct';
|
import ContactDirect from '@/components/product-dialog/steps-ui/job-contact-direct';
|
||||||
import UnableUnlockContent from '@/components/product-dialog/steps-ui/job-unable';
|
import UnableUnlockContent from '@/components/product-dialog/steps-ui/job-unable';
|
||||||
|
import { EventName } from '@/constants/app';
|
||||||
import { DeclarationType, ProductType } from '@/constants/product';
|
import { DeclarationType, ProductType } from '@/constants/product';
|
||||||
import { JobDetails } from '@/types/job';
|
import { JobDetails } from '@/types/job';
|
||||||
import { ProductInfo } from '@/types/product';
|
import { GetProductIsUnlockResponse, ProductInfo } from '@/types/product';
|
||||||
import { logWithPrefix } from '@/utils/common';
|
import { logWithPrefix } from '@/utils/common';
|
||||||
import { requestProductUseRecord, requestUseProduct } from '@/utils/product';
|
import { requestProductUseRecord, requestUseProduct } from '@/utils/product';
|
||||||
import Toast from '@/utils/toast';
|
import Toast from '@/utils/toast';
|
||||||
|
|
||||||
import '../index.less';
|
import '../index.less';
|
||||||
import { EventName } from '@/constants/app';
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
data: JobDetails;
|
data: JobDetails;
|
||||||
|
productRecord?: GetProductIsUnlockResponse;
|
||||||
productInfo?: ProductInfo;
|
productInfo?: ProductInfo;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
}
|
}
|
||||||
@ -27,7 +28,7 @@ const PRODUCT_CODE = ProductType.VIP;
|
|||||||
const log = logWithPrefix('product-contact-dialog');
|
const log = logWithPrefix('product-contact-dialog');
|
||||||
|
|
||||||
function ProductContactDialog(props: Omit<IProps, 'visible'>) {
|
function ProductContactDialog(props: Omit<IProps, 'visible'>) {
|
||||||
const { data, productInfo: productInfoProps, onClose } = props;
|
const { data, productInfo: productInfoProps, productRecord, onClose } = props;
|
||||||
const [status, setStatus] = useState<DialogStatus>(DialogStatus.LOADING);
|
const [status, setStatus] = useState<DialogStatus>(DialogStatus.LOADING);
|
||||||
const [publisherAcctNo, setPublisherAcctNo] = useState<string>('');
|
const [publisherAcctNo, setPublisherAcctNo] = useState<string>('');
|
||||||
const initRef = useRef(() => {});
|
const initRef = useRef(() => {});
|
||||||
@ -56,10 +57,9 @@ function ProductContactDialog(props: Omit<IProps, 'visible'>) {
|
|||||||
// setStatus(DialogStatus.JOB_CONTACT_CS);
|
// setStatus(DialogStatus.JOB_CONTACT_CS);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
const result = await requestProductUseRecord(PRODUCT_CODE, { jobId: data.id });
|
log('requestProductUseRecord result', productRecord);
|
||||||
log('requestProductUseRecord result', result);
|
if (productRecord) {
|
||||||
if (result) {
|
handleContact(productRecord.declarationTypeResult);
|
||||||
handleContact(result.declarationTypeResult);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!productInfoProps?.balance) {
|
if (!productInfoProps?.balance) {
|
||||||
@ -76,7 +76,7 @@ function ProductContactDialog(props: Omit<IProps, 'visible'>) {
|
|||||||
Taro.hideLoading();
|
Taro.hideLoading();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}, [data, handleCloseDialog]);
|
}, [data, handleCloseDialog, productRecord, productInfoProps?.balance]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
initRef.current();
|
initRef.current();
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import { RESPONSE_ERROR_CODE } from '@/http/constant';
|
|||||||
import { HttpError } from '@/http/error';
|
import { HttpError } from '@/http/error';
|
||||||
import { JobDetails } from '@/types/job';
|
import { JobDetails } from '@/types/job';
|
||||||
import { IMaterialMessage } from '@/types/message';
|
import { IMaterialMessage } from '@/types/message';
|
||||||
import { ProductInfo } from '@/types/product';
|
import { GetProductIsUnlockResponse, ProductInfo } from '@/types/product';
|
||||||
import { switchRoleType } from '@/utils/app';
|
import { switchRoleType } from '@/utils/app';
|
||||||
import { copy, logWithPrefix } from '@/utils/common';
|
import { copy, logWithPrefix } from '@/utils/common';
|
||||||
import { reportEvent } from '@/utils/event';
|
import { reportEvent } from '@/utils/event';
|
||||||
@ -37,7 +37,7 @@ import { calcDistance, isValidLocation } from '@/utils/location';
|
|||||||
import { requestProfileDetail } from '@/utils/material';
|
import { requestProfileDetail } from '@/utils/material';
|
||||||
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
||||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
||||||
import { requestProductBalance } from '@/utils/product';
|
import { requestProductBalance, requestProductUseRecord } from '@/utils/product';
|
||||||
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
import { getJumpUrl, getPageQuery, navigateTo } from '@/utils/route';
|
||||||
import { getCommonShareMessage } from '@/utils/share';
|
import { getCommonShareMessage } from '@/utils/share';
|
||||||
import { formatDate } from '@/utils/time';
|
import { formatDate } from '@/utils/time';
|
||||||
@ -74,11 +74,17 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
|||||||
const [showMaterialGuide, setShowMaterialGuide] = useState(false);
|
const [showMaterialGuide, setShowMaterialGuide] = useState(false);
|
||||||
const [showBuyDialog, setShowBuyDialog] = useState(false);
|
const [showBuyDialog, setShowBuyDialog] = useState(false);
|
||||||
const [productInfo, setProductInfo] = useState<undefined | ProductInfo>();
|
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 getProductBalance = useCallback(async () => {
|
||||||
const [, resp] = await requestProductBalance(ProductType.VIP);
|
const [, resp] = await requestProductBalance(ProductType.VIP);
|
||||||
setProductInfo(resp);
|
setProductInfo(resp);
|
||||||
}, [data.id]);
|
}, []);
|
||||||
|
|
||||||
const handleClickContact = useCallback(async () => {
|
const handleClickContact = useCallback(async () => {
|
||||||
log('handleClickContact');
|
log('handleClickContact');
|
||||||
@ -155,9 +161,9 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
|||||||
[getProductBalance]
|
[getProductBalance]
|
||||||
);
|
);
|
||||||
|
|
||||||
const handleAfterBuy = useCallback(() => {
|
const handleAfterBuy = useCallback(async () => {
|
||||||
setShowBuyDialog(false);
|
setShowBuyDialog(false);
|
||||||
getProductBalance();
|
await getProductBalance();
|
||||||
setContactDialogVisible(true);
|
setContactDialogVisible(true);
|
||||||
}, [getProductBalance]);
|
}, [getProductBalance]);
|
||||||
|
|
||||||
@ -184,12 +190,21 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Taro.eventCenter.on(EventName.CREATE_PROFILE, getProductBalance);
|
Taro.eventCenter.on(EventName.CREATE_PROFILE, getProductBalance);
|
||||||
Taro.eventCenter.on(EventName.READ_CONTACT, getProductBalance);
|
Taro.eventCenter.on(EventName.READ_CONTACT, getProductBalance);
|
||||||
}, []);
|
|
||||||
|
return () => {
|
||||||
|
Taro.eventCenter.off(EventName.CREATE_PROFILE);
|
||||||
|
Taro.eventCenter.off(EventName.READ_CONTACT);
|
||||||
|
};
|
||||||
|
}, [getProductBalance]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getProductBalance();
|
getProductBalance();
|
||||||
}, [getProductBalance]);
|
}, [getProductBalance]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getProductRecord();
|
||||||
|
}, [getProductRecord]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className={`${PREFIX}__footer`}>
|
<div className={`${PREFIX}__footer`}>
|
||||||
@ -198,7 +213,7 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
|||||||
</Button>
|
</Button>
|
||||||
<LoginButton className={`${PREFIX}__contact-publisher`} onClick={handleClickContact}>
|
<LoginButton className={`${PREFIX}__contact-publisher`} onClick={handleClickContact}>
|
||||||
{data.isAuthed ? '在线沟通' : '查看联系方式'}
|
{data.isAuthed ? '在线沟通' : '查看联系方式'}
|
||||||
{data.isAuthed || productInfo?.content ? (
|
{!productRecord && (data.isAuthed || productInfo?.content) ? (
|
||||||
<div className={`${PREFIX}__contact-publisher-tag`}>
|
<div className={`${PREFIX}__contact-publisher-tag`}>
|
||||||
{data.isAuthed ? '急招岗位可免费查看' : productInfo?.content}
|
{data.isAuthed ? '急招岗位可免费查看' : productInfo?.content}
|
||||||
</div>
|
</div>
|
||||||
@ -207,7 +222,12 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
{contactDialogVisible && (
|
{contactDialogVisible && (
|
||||||
<ProductContactDialog productInfo={productInfo} data={data} onClose={handleDialogHidden} />
|
<ProductContactDialog
|
||||||
|
productInfo={productInfo}
|
||||||
|
productRecord={productRecord}
|
||||||
|
data={data}
|
||||||
|
onClose={handleDialogHidden}
|
||||||
|
/>
|
||||||
)}
|
)}
|
||||||
{showMaterialGuide && (
|
{showMaterialGuide && (
|
||||||
<PrejobPopup onCancel={() => setShowMaterialGuide(false)} onConfirm={handleConfirmPrejob} />
|
<PrejobPopup onCancel={() => setShowMaterialGuide(false)} onConfirm={handleConfirmPrejob} />
|
||||||
|
|||||||
Reference in New Issue
Block a user