任务广告更新

This commit is contained in:
GaoHao 2025-01-14 11:28:54 +08:00
parent 33e99d91a5
commit 041b04bc82
1 changed files with 60 additions and 23 deletions

View File

@ -60,11 +60,12 @@
</view>
</view>
<!-- 激励视频广告 -->
<!-- <ad-rewarded-video v-if="adRewardedVideo" ref="adRewardedVideo" adpid="1531580352" :loadnext="true"
v-slot:default="{ loading, error }" :url-callback="datas.urlCallback" @load="onadload" @close="onadclose"
@error="onaderror">
<view class="ad-error" v-if="error">{{ error }}</view>
</ad-rewarded-video> -->
<view style="width: 0;height: 0;overflow: hidden;">
<!-- 激励视频广告 -->
<ad-rewarded-video v-if="datas.adRewardedShow" ref="adRewarded" adpid="1507000689" :loadnext="true"
:url-callback="datas.urlCallback" @load="onadload" @close="onadclose" @error="onaderror">
</ad-rewarded-video>
</view>
</view>
</template>
@ -73,6 +74,7 @@ import {
useCommonStore
} from '@/store/common.js'
const $common = useCommonStore()
import { selectUserMoney, selectPayDetails, canCash, state, withdraw } from '@/api/me/withdraw.js';
import {
reactive,
getCurrentInstance,
@ -80,6 +82,7 @@ import {
} from "vue";
import {
onShow,
onReady,
onReachBottom
} from '@dcloudio/uni-app'
import {
@ -95,9 +98,11 @@ import {
// ios
isExamine: $common.isExamine,
urlCallback: {},
adRewardedVideo: true,
adRewardedShow: true,
adRewardedVideoloadNum: 0,
})
const adRewarded = ref(null);
onShow(() => {
getTaskdata()
getsignIn()
@ -106,24 +111,59 @@ import {
// currentInstance.ctx.$refs.adRewardedVideo.load();
// })
})
//广
onReady(() => {
nextTick(()=>{
data.adRewardedVideoloadNum = 0
adRewarded.value.load();
})
getCanCash()
})
/**
* 获取看广告状态
*/
async function getCanCash() {
canCash().then(res => {
data.isWithdraw = !res;
})
}
/**
* 广告加载失败回调
* @param {Object} e
*/
function onaderror(e) {
if ( data.adRewardedVideoloadNum >=3 ) {
data.adRewardedShow = false;
return
}
data.adRewardedVideoloadNum++
setTimeout(() => {
adRewarded.value.load();
}, 1000); // 10
console.log("广告加载失败")
}
/**
* 广告数据加载成功回调
* @param {Object} e
*/
function onadload(e) {
data.adRewardedShow = true;
console.log('广告数据加载成功');
}
/**
* 广告播放成功回调
* @param {Object} e
*/
async function onadclose(e) {
const detail = e.detail
if (detail && detail.isEnded) {
//
// /sqx_fast/app/ad/state
let res = await this.$Request.getT('app/ad/state', {
extraKey: this.urlCallback.extra
})
this.$Request.getT('/app/common/type/921').then(res => {
if (res.code == 0) {
console.log(res)
uni.showToast({
title: '获得' + res.data.value + '分钟免费时长',
icon: 'none'
})
}
let res = await state({
extraKey: data.urlCallback.extra
})
getCanCash()
} else {
// 退
}
@ -169,7 +209,7 @@ import {
userId: uni.getStorageSync('userId'),
extra: uni.getStorageSync('userId') + "" + new Date().getTime(),
}
currentInstance.ctx.$refs.adRewardedVideo.show();
adRewarded.value.show();
} else {
uni.switchTab({
url: "/pages/index/index"
@ -202,9 +242,6 @@ import {
}
function onadload(e) {
datas.adRewardedVideo = true;
}
//
async function getsignIn() {
let res = await getUserSignData()