feat: job publish
This commit is contained in:
@ -7,7 +7,7 @@ import BlFormInput from '@/components/bl-form-input';
|
||||
import BlFormItem from '@/components/bl-form-item';
|
||||
import LoadingDialog from '@/components/loading-dialog';
|
||||
import SafeBottomPadding from '@/components/safe-bottom-padding';
|
||||
import { PageUrl } from '@/constants/app';
|
||||
import { EventName, PageUrl } from '@/constants/app';
|
||||
import { CertificationStatusType } from '@/constants/company';
|
||||
import { CollectEventName, ReportEventId } from '@/constants/event';
|
||||
import useUserInfo from '@/hooks/use-user-info';
|
||||
@ -16,12 +16,18 @@ import { isValidIdCard, isValidPhone, logWithPrefix } from '@/utils/common';
|
||||
import { postCertification, getPhone } from '@/utils/company';
|
||||
import { collectEvent, reportEvent } from '@/utils/event';
|
||||
import { chooseMedia } from '@/utils/material';
|
||||
import { redirectTo } from '@/utils/route';
|
||||
import { navigateBack, redirectTo } from '@/utils/route';
|
||||
import Toast from '@/utils/toast';
|
||||
import { dispatchUpdateUser, requestUserInfo } from '@/utils/user';
|
||||
import { uploadVideo } from '@/utils/video';
|
||||
|
||||
import './index.less';
|
||||
import { requestProductBalance } from '@/utils/product';
|
||||
import { ProductType } from '@/constants/product';
|
||||
import useCachedJob from '@/hooks/use-cached-job';
|
||||
import { postCreateJob } from '@/utils/job';
|
||||
import { Dialog } from '@taroify/core';
|
||||
import CompanyPublishJobBuy from '@/components/product-dialog/steps-ui/company-publish-job-buy';
|
||||
|
||||
const PREFIX = 'page-certification';
|
||||
const log = logWithPrefix(PREFIX);
|
||||
@ -100,6 +106,8 @@ export default function Certification() {
|
||||
// const [code, setCode] = useState('');
|
||||
const [company, setCompany] = useState('');
|
||||
const [open, setOpen] = useState(false);
|
||||
const [showBuy, setShowBuy] = useState(false);
|
||||
const cachedJobData = useCachedJob();
|
||||
|
||||
const handleClickIdCardLeft = useCallback(async () => {
|
||||
reportEvent(ReportEventId.CLICK_UPLOAD_ID_CARD, { type: 'left' });
|
||||
@ -133,6 +141,25 @@ export default function Certification() {
|
||||
setCompany(value);
|
||||
}, []);
|
||||
|
||||
const handleCreateJob = useCallback(async () => {
|
||||
if (cachedJobData.employType) {
|
||||
Taro.showLoading();
|
||||
try {
|
||||
await postCreateJob(cachedJobData);
|
||||
Taro.eventCenter.trigger(EventName.COMPANY_JOB_PUBLISH_CHANGED);
|
||||
await Toast.success('通告创建成功', 1500, true);
|
||||
} catch (e) {
|
||||
console.error('submit error', e);
|
||||
Toast.error('通告审核失败请重试');
|
||||
collectEvent(CollectEventName.PUBLISH_JOB_FAILED, e);
|
||||
} finally {
|
||||
Taro.hideLoading();
|
||||
}
|
||||
} else {
|
||||
Toast.error('数据出错');
|
||||
}
|
||||
}, [cachedJobData]);
|
||||
|
||||
const handleSubmit = useCallback(async () => {
|
||||
reportEvent(ReportEventId.CLICK_CERTIFICATION_SUBMIT);
|
||||
const data: ICertificationRequest = {
|
||||
@ -157,6 +184,17 @@ export default function Certification() {
|
||||
return;
|
||||
}
|
||||
dispatchUpdateUser({ bossAuthStatus: CertificationStatusType.Success });
|
||||
// 判断付钱没有
|
||||
const [time] = await requestProductBalance(ProductType.CompanyPublishJob);
|
||||
if (time <= 0) {
|
||||
// 付钱
|
||||
setShowBuy(true);
|
||||
Taro.hideLoading();
|
||||
return;
|
||||
} else {
|
||||
// 获取data创建
|
||||
await handleCreateJob();
|
||||
}
|
||||
redirectTo(PageUrl.CertificationManage);
|
||||
} catch (e) {
|
||||
console.error('submit error', e);
|
||||
@ -262,6 +300,11 @@ export default function Certification() {
|
||||
<div>
|
||||
<LoadingDialog open={open} text="认证中" />
|
||||
</div>
|
||||
<Dialog open={showBuy} onClose={() => setShowBuy(false)}>
|
||||
<Dialog.Content>
|
||||
<CompanyPublishJobBuy onNext={handleCreateJob} defaultSelect={1} />
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user