From 041b04bc828d794e2f540300bad6470d0e835d8c Mon Sep 17 00:00:00 2001 From: GaoHao <1210693421@qq.com> Date: Tue, 14 Jan 2025 11:28:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E5=B9=BF=E5=91=8A=E6=9B=B4?= =?UTF-8?q?=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/task/index.vue | 83 ++++++++++++++++++++++++++++++++------------ 1 file changed, 60 insertions(+), 23 deletions(-) diff --git a/pages/task/index.vue b/pages/task/index.vue index 6fca8ff..72abbe6 100644 --- a/pages/task/index.vue +++ b/pages/task/index.vue @@ -60,11 +60,12 @@ - + + + + + @@ -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()