feat: update tonggao
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { Map, MapProps, Text, Image, Button } from '@tarojs/components';
|
||||
import { Button, Image, Map, MapProps, Text } from '@tarojs/components';
|
||||
import Taro, { useLoad, useShareAppMessage } from '@tarojs/taro';
|
||||
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
@ -12,10 +12,10 @@ 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 { RoleType, EventName, PageUrl } from '@/constants/app';
|
||||
import { EventName, PageUrl, RoleType } from '@/constants/app';
|
||||
import { CertificationStatusType } from '@/constants/company';
|
||||
import { CollectEventName, ReportEventId } from '@/constants/event';
|
||||
import { EMPLOY_TYPE_TITLE_MAP, GET_CONTACT_TYPE } from '@/constants/job';
|
||||
import { EMPLOY_TYPE_TITLE_MAP, GET_CONTACT_TYPE, JobManageStatus } from '@/constants/job';
|
||||
import useInviteCode from '@/hooks/use-invite-code';
|
||||
import useUserInfo from '@/hooks/use-user-info';
|
||||
import useRoleType from '@/hooks/user-role-type';
|
||||
@ -26,7 +26,7 @@ import { IMaterialMessage } from '@/types/message';
|
||||
import { switchRoleType } from '@/utils/app';
|
||||
import { copy, logWithPrefix } from '@/utils/common';
|
||||
import { collectEvent, reportEvent } from '@/utils/event';
|
||||
import { getJobTitle, getJobSalary, postPublishJob, requestJobDetail } from '@/utils/job';
|
||||
import { getJobSalary, getJobTitle, postPublishJob, requestJobDetail } from '@/utils/job';
|
||||
import { calcDistance, isValidLocation } from '@/utils/location';
|
||||
import { requestProfileDetail } from '@/utils/material';
|
||||
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
||||
@ -38,6 +38,10 @@ import Toast from '@/utils/toast';
|
||||
import { isNeedCreateMaterial } from '@/utils/user';
|
||||
|
||||
import './index.less';
|
||||
import { Dialog } from '@taroify/core';
|
||||
import CompanyPublishJobBuy from '@/components/product-dialog/steps-ui/company-publish-job-buy';
|
||||
import { requestProductBalance } from '@/utils/product';
|
||||
import { ProductType } from '@/constants/product';
|
||||
|
||||
const PREFIX = 'job-detail';
|
||||
const log = logWithPrefix(PREFIX);
|
||||
@ -79,8 +83,11 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
|
||||
if (data.sourcePlat !== 'bl') {
|
||||
if (needCreateMaterial) {
|
||||
setShowMaterialGuide(true);
|
||||
return;
|
||||
const [time] = await requestProductBalance(ProductType.VIP);
|
||||
if (time <= 0) {
|
||||
setShowMaterialGuide(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (data.isAuthed) {
|
||||
@ -162,6 +169,7 @@ const AnchorFooter = (props: { data: JobDetails }) => {
|
||||
|
||||
const CompanyFooter = (props: { data: JobDetails }) => {
|
||||
const { data } = props;
|
||||
const [showBuy, setShowBuy] = useState(false);
|
||||
|
||||
const handleClickEdit = useCallback(() => navigateTo(PageUrl.JobPublish, { jobId: data.id }), [data]);
|
||||
|
||||
@ -170,17 +178,22 @@ const CompanyFooter = (props: { data: JobDetails }) => {
|
||||
Taro.showLoading();
|
||||
await postPublishJob(data.id);
|
||||
Taro.eventCenter.trigger(EventName.COMPANY_JOB_PUBLISH_CHANGED);
|
||||
setShowBuy(false);
|
||||
Toast.success('发布成功');
|
||||
Taro.hideLoading();
|
||||
} catch (error) {
|
||||
Taro.hideLoading();
|
||||
const e = error as HttpError;
|
||||
const errorCode = e.errorCode;
|
||||
const errorMsg = e.info?.() || e.message;
|
||||
collectEvent(CollectEventName.PUBLISH_OPEN_JOB_FAILED, { jobId: data.id, error: e.info?.() || e.message });
|
||||
if (errorCode === RESPONSE_ERROR_CODE.BOSS_VIP_EXPIRED) {
|
||||
if (errorCode === RESPONSE_ERROR_CODE.INSUFFICIENT_BALANCE) {
|
||||
Toast.info('您购买的产品已耗尽使用次数');
|
||||
setShowBuy(true);
|
||||
} else if (errorCode === RESPONSE_ERROR_CODE.BOSS_VIP_EXPIRED) {
|
||||
Toast.info('该通告已到期,请创建新通告', 3000);
|
||||
} else {
|
||||
Toast.error(e.message || '发布失败请重试', 3000);
|
||||
Toast.error(errorMsg || '发布失败请重试', 3000);
|
||||
}
|
||||
console.error(e);
|
||||
}
|
||||
@ -192,10 +205,19 @@ const CompanyFooter = (props: { data: JobDetails }) => {
|
||||
<Button className={`${PREFIX}__share-button`} onClick={handleClickEdit}>
|
||||
编辑
|
||||
</Button>
|
||||
<Button className={`${PREFIX}__contact-publisher`} onClick={handlePublishJob}>
|
||||
<Button
|
||||
disabled={data.status === JobManageStatus.Open}
|
||||
className={`${PREFIX}__contact-publisher`}
|
||||
onClick={handlePublishJob}
|
||||
>
|
||||
发布通告
|
||||
</Button>
|
||||
</div>
|
||||
<Dialog open={showBuy} onClose={() => setShowBuy(false)}>
|
||||
<Dialog.Content>
|
||||
<CompanyPublishJobBuy onNext={handlePublishJob} />
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user