revert ad
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { Map, MapProps, Text, Image, Button } from '@tarojs/components';
|
||||
import Taro, { useLoad, useShareAppMessage } from '@tarojs/taro';
|
||||
|
||||
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
||||
import React, { useCallback, useEffect, useState } from 'react';
|
||||
|
||||
import { CertificationStatusIcon } from '@/components/certification-status';
|
||||
import CommonDialog from '@/components/common-dialog';
|
||||
@ -183,7 +183,6 @@ export default function JobDetail() {
|
||||
const roleType = useRoleType();
|
||||
const userInfo = useUserInfo();
|
||||
const [data, setData] = useState<JobDetails | null>(null);
|
||||
const videoRef = useRef<Taro.RewardedVideoAd | null>(null);
|
||||
const isOwner = roleType === RoleType.Company && userInfo.userId === data?.userId;
|
||||
const inviteCode = useInviteCode();
|
||||
|
||||
@ -220,56 +219,6 @@ export default function JobDetail() {
|
||||
};
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const handleLoad = () => {
|
||||
log('视频奖励加载成功');
|
||||
};
|
||||
const handleError = err => {
|
||||
Taro.eventCenter.trigger(EventName.PRE_ACTION_VIDEO_ERROR);
|
||||
log('视频奖励加载失败', err);
|
||||
};
|
||||
const handleClose = res => {
|
||||
if (res.isEnded) {
|
||||
Taro.eventCenter.trigger(EventName.PRE_ACTION_VIDEO_SUCCESS);
|
||||
} else {
|
||||
Toast.info('请完整观看广告以获得奖励');
|
||||
}
|
||||
};
|
||||
const handleShowVideo = async () => {
|
||||
if (videoRef.current) {
|
||||
try {
|
||||
await videoRef.current.show();
|
||||
} catch (error) {
|
||||
Taro.eventCenter.trigger(EventName.PRE_ACTION_VIDEO_ERROR);
|
||||
Toast.info('广告奖励加载失败,请重试');
|
||||
log('激励视频显示失败');
|
||||
}
|
||||
} else {
|
||||
Taro.eventCenter.trigger(EventName.PRE_ACTION_VIDEO_ERROR);
|
||||
Toast.info('广告奖励加载失败,请重试');
|
||||
log('激励视频加载&显示失败');
|
||||
}
|
||||
};
|
||||
videoRef.current = Taro.createRewardedVideoAd({
|
||||
adUnitId: 'adunit-ca879f574edfeb33',
|
||||
});
|
||||
videoRef.current.onLoad(handleLoad);
|
||||
videoRef.current.onClose(handleClose);
|
||||
videoRef.current.onError(handleError);
|
||||
|
||||
videoRef.current.load();
|
||||
Taro.eventCenter.on(EventName.SHOW_VIDEO_REWARD, handleShowVideo);
|
||||
|
||||
return () => {
|
||||
if (videoRef.current) {
|
||||
videoRef.current.offLoad(handleLoad);
|
||||
videoRef.current.offError(handleError);
|
||||
videoRef.current.offClose(handleClose);
|
||||
}
|
||||
Taro.eventCenter.off(EventName.SHOW_VIDEO_REWARD);
|
||||
};
|
||||
}, []);
|
||||
|
||||
useLoad(async () => {
|
||||
const query = getPageQuery<Pick<JobDetails, 'id'> & { c: string; share: string }>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user