Commit ad7b4738 authored by liuxinjun's avatar liuxinjun

视频广告多次注册事件问题

parent f4111a1a
...@@ -9,6 +9,7 @@ var adSdk = { ...@@ -9,6 +9,7 @@ var adSdk = {
bannerAd: null, bannerAd: null,
isOnce:true,
videoAd: null, videoAd: null,
videoAd1: null, videoAd1: null,
videoAd2: null, videoAd2: null,
...@@ -136,31 +137,42 @@ var adSdk = { ...@@ -136,31 +137,42 @@ var adSdk = {
createRewardedVideoAd(index, videoAdUnitId1) { createRewardedVideoAd(index, videoAdUnitId1) {
let self = this; let self = this;
if (cc.sys.platform === cc.sys.WECHAT_GAME) { if (cc.sys.platform === cc.sys.WECHAT_GAME) {
let videoAd = wx.createRewardedVideoAd({ adUnitId: videoAdUnitId1 }) let videoAd = wx.createRewardedVideoAd({ adUnitId: videoAdUnitId1 })
videoAd.onLoad(function (res) {
console.log("sdk VideoAd广告加载事件:", res)
});
var closeFun1 = function (res) {
// 用户点击了【关闭广告】按钮
// 小于 2.1.0 的基础库版本,res 是一个 undefined
if (res && res.isEnded || res === undefined) {
console.log("sdk 看视频成功");
self.videoSuccess();
} else {
console.error("sdk 看视频失败");
self.videoFail();
}
};
videoAd.onClose(closeFun1);
videoAd.onError(function (res) { if(self.isOnce)
if (self.videoError) { {
self.videoError(); self.isOnce=false;
} videoAd.onLoad(function (res) {
}); console.log("sdk VideoAd广告加载事件:", res)
});
var closeFun1 = function (res) {
// 用户点击了【关闭广告】按钮
// 小于 2.1.0 的基础库版本,res 是一个 undefined
if (res && res.isEnded || res === undefined) {
console.log("sdk 看视频成功");
self.videoSuccess();
} else {
console.error("sdk 看视频失败");
self.videoFail();
}
};
videoAd.onClose(closeFun1);
videoAd.onError(function (res) {
wx.showToast({
title: '今日视频已上限,明日再来!',
icon: 'none'
});
if (self.videoError) {
self.videoError();
}
});
}
if (index == 1) { if (index == 1) {
this.videoAd1 = videoAd; this.videoAd1 = videoAd;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment