广告修改参数

This commit is contained in:
GaoHao
2024-12-24 14:45:32 +08:00
parent c11ccf9e6b
commit d312b614d7

View File

@@ -81,7 +81,7 @@
</view> </view>
<!-- 激励视频广告 --> <!-- 激励视频广告 -->
<ad-rewarded-video ref="adRewardedVideo" adpid="1531580352" :preload="false" :loadnext="false" <ad-rewarded-video ref="adRewardedVideo" adpid="1531580352" :preload="false" :loadnext="false"
:disabled="true" v-slot:default="{loading, error}" @load="onadload" @close="onadclose" :disabled="true" v-slot:default="{loading, error}" :url-callback="urlCallback" @load="onadload" @close="onadclose"
@error="onaderror"> @error="onaderror">
<view class="ad-error" v-if="error">{{error}}</view> <view class="ad-error" v-if="error">{{error}}</view>
</ad-rewarded-video> </ad-rewarded-video>
@@ -129,6 +129,7 @@
isIos: false, isIos: false,
isLoading: false, isLoading: false,
isAndroid: false, isAndroid: false,
urlCallback: null,
} }
}, },
onShow() { onShow() {
@@ -148,18 +149,23 @@
this.isShowMoneyPay = !(res.data.value == '1' && isIos) this.isShowMoneyPay = !(res.data.value == '1' && isIos)
} }
}); });
}, },
async onReady() { async onReady() {
this.urlCallback = {
userId: uni.getStorageSync('userId'),
extra: uni.getStorageSync('userId')+""+new Date().getTime(),
}
this.isLoading = true; this.isLoading = true;
console.log(1) // 首次加载广告
// 首次加载广告
setTimeout(() => { setTimeout(() => {
this.$refs.adRewardedVideo.load(); this.$refs.adRewardedVideo.load();
}, 1000) }, 1000)
}, },
methods: { methods: {
showAd() { showAd() {
console.log(this.isLoading)
if (this.isLoading) { if (this.isLoading) {
return return
} }
@@ -167,7 +173,6 @@
}, },
onadload(e) { onadload(e) {
this.isLoading = false; this.isLoading = false;
console.log(2)
console.log('广告数据加载成功'); console.log('广告数据加载成功');
}, },
async onadclose(e) { async onadclose(e) {
@@ -175,8 +180,9 @@
if (detail && detail.isEnded) { if (detail && detail.isEnded) {
// 正常播放结束 // 正常播放结束
// /sqx_fast/app/ad/state // /sqx_fast/app/ad/state
console.log(this.urlCallback.extra)
let res = await this.$Request.getT('app/ad/state', { let res = await this.$Request.getT('app/ad/state', {
extraKey: 1 extraKey: this.urlCallback.extra
}) })
this.$Request.getT('/app/common/type/921').then(res => { this.$Request.getT('/app/common/type/921').then(res => {
if (res.code == 0) { if (res.code == 0) {