feat: update tonggao
This commit is contained in:
@ -1,13 +1,16 @@
|
||||
import { Button } from '@tarojs/components';
|
||||
import Taro, { useLoad, useShareAppMessage } from '@tarojs/taro';
|
||||
|
||||
import { Dialog } from '@taroify/core';
|
||||
import { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import CommonDialog from '@/components/common-dialog';
|
||||
import PageLoading from '@/components/page-loading';
|
||||
import CompanyPublishJobBuy from '@/components/product-dialog/steps-ui/company-publish-job-buy';
|
||||
import SafeBottomPadding from '@/components/safe-bottom-padding';
|
||||
import { EventName, OpenSource, PageUrl, RoleType } from '@/constants/app';
|
||||
import { CollectEventName } from '@/constants/event';
|
||||
import { JobManageStatus } from '@/constants/job';
|
||||
import { MaterialViewSource } from '@/constants/material';
|
||||
import ProfileViewFragment from '@/fragments/profile/view';
|
||||
import useInviteCode from '@/hooks/use-invite-code';
|
||||
@ -19,7 +22,7 @@ import { IJobMessage } from '@/types/message';
|
||||
import { switchRoleType } from '@/utils/app';
|
||||
import { copy } from '@/utils/common';
|
||||
import { collectEvent } from '@/utils/event';
|
||||
import { requestHasPublishedJob, requestJobDetail } from '@/utils/job';
|
||||
import { postPublishJob, requestHasPublishedJob, requestJobDetail } from '@/utils/job';
|
||||
import { getMaterialShareMessage, requestReadProfile, requestShareProfile } from '@/utils/material';
|
||||
import { isChatWithSelf, postCreateChat } from '@/utils/message';
|
||||
import { getInviteCodeFromQueryAndUpdate } from '@/utils/partner';
|
||||
@ -67,15 +70,16 @@ export default function MaterialViewPage() {
|
||||
const [jobId, setJobId] = useState<string>();
|
||||
const [errorTips, setErrorTips] = useState<string>('');
|
||||
const [publishDialogVisible, setPublishDialogVisible] = useState(false);
|
||||
const [certificationDialogVisible, setCertificationDialogVisible] = useState(false);
|
||||
const [noTimeDialogVisible, setNoTimeDialogVisible] = useState(false);
|
||||
const [noVipLimitVisible, setNoVipLimitVisible] = useState(false);
|
||||
const [vipExpiredVisible, setVipExpiredVisible] = useState(false);
|
||||
const inviteCode = useInviteCode();
|
||||
const [showBuy, setShowBuy] = useState(false);
|
||||
|
||||
const onDev = useCallback(async () => profile && copy(profile.userId), [profile]);
|
||||
|
||||
const handleClickContact = useCallback(async () => {
|
||||
setShowBuy(false);
|
||||
if (!profile) {
|
||||
return;
|
||||
}
|
||||
@ -87,6 +91,10 @@ export default function MaterialViewPage() {
|
||||
return;
|
||||
}
|
||||
const jobDetail = await requestJobDetail(jobId);
|
||||
if (jobDetail.status !== JobManageStatus.Open) {
|
||||
setShowBuy(true);
|
||||
return;
|
||||
}
|
||||
const chat = await postCreateChat(toUserId);
|
||||
const jobMessage: IJobMessage = {
|
||||
id: jobDetail.id,
|
||||
@ -116,7 +124,16 @@ export default function MaterialViewPage() {
|
||||
}
|
||||
}
|
||||
}, [profile, jobId]);
|
||||
|
||||
const handleNext = useCallback(async () => {
|
||||
setShowBuy(false);
|
||||
try {
|
||||
await postPublishJob(jobId!);
|
||||
await handleClickContact();
|
||||
} catch (e) {
|
||||
Toast.error('通告发布失败');
|
||||
collectEvent(CollectEventName.PUBLISH_JOB_FAILED, e);
|
||||
}
|
||||
}, [handleClickContact, jobId]);
|
||||
const handleClickNoViewTimes = useCallback(() => {
|
||||
setNoTimeDialogVisible(false);
|
||||
navigateBack();
|
||||
@ -127,11 +144,6 @@ export default function MaterialViewPage() {
|
||||
redirectTo(PageUrl.CertificationManage);
|
||||
}, []);
|
||||
|
||||
const handleClickGoCertification = useCallback(() => {
|
||||
setCertificationDialogVisible(false);
|
||||
redirectTo(PageUrl.CertificationStart);
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const callback = (select: JobManageInfo, source: OpenSource) =>
|
||||
source === OpenSource.MaterialViewPage && setJobId(select.id);
|
||||
@ -162,9 +174,7 @@ export default function MaterialViewPage() {
|
||||
const errorCode = e.errorCode;
|
||||
collectEvent(CollectEventName.VIEW_MATERIAL_FAILED, { context, error: e.info?.() || e.message });
|
||||
console.error(e);
|
||||
if (errorCode === RESPONSE_ERROR_CODE.BOSS_NOT_AUTH) {
|
||||
setCertificationDialogVisible(true);
|
||||
} else if (errorCode === RESPONSE_ERROR_CODE.NO_PUBLISHED_JOB) {
|
||||
if (errorCode === RESPONSE_ERROR_CODE.NO_PUBLISHED_JOB) {
|
||||
setPublishDialogVisible(true);
|
||||
} else if (errorCode === RESPONSE_ERROR_CODE.INSUFFICIENT_BALANCE) {
|
||||
setNoTimeDialogVisible(true);
|
||||
@ -179,7 +189,7 @@ export default function MaterialViewPage() {
|
||||
});
|
||||
|
||||
useShareAppMessage(async () => {
|
||||
const shareMessage = await getMaterialShareMessage(profile, true, inviteCode);
|
||||
const shareMessage = await getMaterialShareMessage(profile, true, inviteCode, jobId);
|
||||
return shareMessage as BL.Anything;
|
||||
});
|
||||
|
||||
@ -187,13 +197,6 @@ export default function MaterialViewPage() {
|
||||
return (
|
||||
<>
|
||||
<PageLoading />
|
||||
<CommonDialog
|
||||
content="要查看主播详情,请先完成实人认证"
|
||||
confirm="去认证"
|
||||
visible={certificationDialogVisible}
|
||||
onClose={() => setCertificationDialogVisible(false)}
|
||||
onClick={handleClickGoCertification}
|
||||
/>
|
||||
<CommonDialog
|
||||
content="请先发布一个认证通告"
|
||||
confirm="去发布"
|
||||
@ -260,6 +263,11 @@ export default function MaterialViewPage() {
|
||||
onClose={() => setErrorTips('')}
|
||||
onClick={() => setErrorTips('')}
|
||||
/>
|
||||
<Dialog open={showBuy} onClose={() => setShowBuy(false)}>
|
||||
<Dialog.Content>
|
||||
<CompanyPublishJobBuy onNext={handleNext} />
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user