广告加载失败触发提醒

This commit is contained in:
GaoHao 2025-01-15 17:50:53 +08:00
parent d255512ade
commit a0f899c3cd
2 changed files with 19 additions and 8 deletions

View File

@ -83,7 +83,7 @@
<view style="width: 0;height: 0;overflow: hidden;">
<!-- 激励视频广告 -->
<ad-rewarded-video v-if="data.adRewardedShow" ref="adRewarded" :adpid="data.adpid" :loadnext="true"
<ad-rewarded-video ref="adRewarded" :adpid="data.adpid" :loadnext="true"
:url-callback="data.urlCallback" @load="onadload" @close="onadclose" @error="onaderror">
</ad-rewarded-video>
</view>
@ -113,7 +113,7 @@
cashMoney: 0,
urlCallback: {},
adpid: null,
adRewardedShow: true,
adRewardedShow: false,
adRewardedVideoloadNum: 0,
isWithdraw: false,
userInfo: null,
@ -227,14 +227,13 @@
*/
function onaderror(e) {
if ( data.adRewardedVideoloadNum >=3 ) {
data.adRewardedShow = false;
return
}
data.adRewardedVideoloadNum++
setTimeout(() => {
adRewarded.value.load();
}, 1000); // 10
console.log("广告加载失败")
console.log("广告加载失败",e)
}
/**
@ -263,8 +262,14 @@
* 提现触发
*/
function goWithdraw() {
if ( !data.isWithdraw ) {
if(!data.adRewardedShow){
uni.showToast({
icon: 'none',
title: '广告加载失败,请稍后重试'
});
return
}
data.urlCallback = {
userId: uni.getStorageSync('userInfo').userId,
extra: 'cash:'+uni.getStorageSync('userInfo').userId + "" + new Date().getTime(),

View File

@ -62,7 +62,7 @@
<!-- 激励视频广告 -->
<view style="width: 0;height: 0;overflow: hidden;">
<!-- 激励视频广告 -->
<ad-rewarded-video v-if="datas.adRewardedShow" ref="adRewarded" :adpid="datas.adpid" :loadnext="true"
<ad-rewarded-video ref="adRewarded" :adpid="datas.adpid" :loadnext="true"
:url-callback="datas.urlCallback" @load="onadload" @close="onadclose" @error="onaderror">
</ad-rewarded-video>
</view>
@ -104,7 +104,7 @@
list: [],
urlCallback: {},
adpid: null,
adRewardedShow: true,
adRewardedShow: false,
adRewardedVideoloadNum: 0,
})
@ -247,7 +247,6 @@
*/
function onaderror(e) {
if (datas.adRewardedVideoloadNum >= 3) {
datas.adRewardedShow = false;
return
}
datas.adRewardedVideoloadNum++
@ -316,6 +315,13 @@
}
} else if (item.buttonTitle.indexOf("观看视频") != -1) {
// 广
if(!datas.adRewardedShow){
uni.showToast({
icon: 'none',
title: '广告加载失败,请稍后重试'
});
return
}
datas.urlCallback = {
userId: uni.getStorageSync('userId'),
extra: uni.getStorageSync('userId') + "" + new Date().getTime(),