796b6df0 by simon

默认提交

1 parent daf3eb67
......@@ -41,6 +41,10 @@ Page({
let title = detailData && detailData.videoName || "";
let path = `pages/detail/detail?c=${detailData.videoCode}`;
let imageUrl = detailData && detailData.thumbnail || "";
if (app.globalData.adConfigure && app.globalData.adConfigure.ad_config_01 == 1) {
this.showInterstitialAd();
}
return {
title,
path,
......@@ -70,43 +74,72 @@ Page({
'页面名字': '视频详情页'
});
if (wx.createRewardedVideoAd) {
rewardedVideoAd = wx.createRewardedVideoAd({
adUnitId: 'adunit-3e849f70e28e6c21'
})
rewardedVideoAd.onLoad(() => {
console.log('onLoad event emit');
})
rewardedVideoAd.onError((err) => {
console.log('onError event emit', err)
this.checkPlayTimes().then((result) => {
if (wx.createRewardedVideoAd) {
rewardedVideoAd = wx.createRewardedVideoAd({
adUnitId: 'adunit-3e849f70e28e6c21'
})
rewardedVideoAd.onLoad(() => {
console.log('onLoad event emit');
})
rewardedVideoAd.onError((err) => {
console.log('onError event emit', err)
})
rewardedVideoAd.onClose((res) => {
console.log('onClose event emit', res)
})
}
this.showVideoAd();
});
this.addInterstitialAd();
},
addInterstitialAd() {
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-1ffb5a60bc3f7f55'
})
rewardedVideoAd.onClose((res) => {
console.log('onClose event emit', res)
interstitialAd.onLoad(() => {})
interstitialAd.onError((err) => {})
interstitialAd.onClose(() => {})
}
},
showInterstitialAd() {
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
this.checkShowVideoAd();
},
checkShowVideoAd() {
if (app.globalData.adConfigure && app.globalData.adConfigure.configureN > 0) {
if (app.globalData.videoPlayTimes >= app.globalData.adConfigure.configureN) {
console.log("app.globalData.videoPlayTimes:", app.globalData.videoPlayTimes);
// if (app.globalData.videoPlayTimes > 1) {
app.globalData.videoPlayTimes = 0;
rewardedVideoAd.show()
// 用户触发广告后,显示激励视频广告
if (rewardedVideoAd) {
rewardedVideoAd.show().catch(() => {
// 失败重试
rewardedVideoAd.load()
.then(() => rewardedVideoAd.show())
.catch(err => {
console.log('激励视频 广告显示失败')
})
})
checkPlayTimes() {
return new Promise((resolve, reject) => {
if (app.globalData.adConfigure && app.globalData.adConfigure.configureN > 0) {
if (app.globalData.videoPlayTimes >= app.globalData.adConfigure.configureN) {
app.globalData.videoPlayTimes = 0;
resolve();
}
}
})
},
showVideoAd() {
app.globalData.videoPlayTimes = 0;
rewardedVideoAd.show()
// 用户触发广告后,显示激励视频广告
if (rewardedVideoAd) {
rewardedVideoAd.show().catch(() => {
// 失败重试
rewardedVideoAd.load()
.then(() => rewardedVideoAd.show())
.catch(err => {
console.log('激励视频 广告显示失败')
})
})
}
},
......@@ -260,11 +293,60 @@ Page({
size: this.data.size,
},
}).then((result) => {
let {
adConfigure,
} = this.data;
let dataList = result.list;
dataList = this.data.dataList.concat(dataList);
// console.log("dataList:", dataList);
// 带广告的格式
let dataListResult = [];
// 广告步进
let adStep = adConfigure.configureM || 0;
// 视频广告第一次出现条目
let firstAdIndex = adConfigure.configureX || 0;
// 视频广告第一条是否已经出现
let isFirstAdshow = false;
// 广告步数
let adStepIndex = 0;
// 洗列表格式
dataList.forEach((element, idx) => {
// 视频
if (isFirstAdshow) {
// 第一个视频出现过
if (adStepIndex > adStep && adStep != 0) {
adStepIndex = 0;
dataListResult.push({
type: "ad",
adType: "banner"
})
}
} else {
// 第一个视频出现
if (adStepIndex == firstAdIndex && firstAdIndex > 0) {
isFirstAdshow = true;
adStepIndex = 0;
dataListResult.push({
type: "ad",
adType: "video"
})
}
}
adStepIndex++;
dataListResult.push(element);
// console.log("dataListResult:", dataListResult);
});
this.setData({
dataList: dataList,
dataListResult: dataListResult,
total: result.total
})
resolve();
......@@ -273,8 +355,8 @@ Page({
},
/**广告配置 */
queryAdConfigure() {
/**广告配置 */
queryAdConfigure() {
return new Promise((resolve, reject) => {
app.post({
sid: false,
......
......@@ -2,7 +2,7 @@ import {
getBindtapData
} from '../../utils/util'
let interstitialAd = null
let app = getApp();
......@@ -48,6 +48,10 @@ Page({
primaryCode: this.data.curTab.tabCode,
});
}
if (app.globalData.adConfigure && app.globalData.adConfigure.ad_config_01 == 1) {
this.showInterstitialAd();
}
},
showAuth() {
this.setData({
......@@ -67,8 +71,32 @@ Page({
wx.aldstat.sendEvent('进入页面', {
'页面名字': '首页'
});
this.addInterstitialAd();
if (app.globalData.adConfigure && app.globalData.adConfigure.ad_config_02 == 1) {
this.showInterstitialAd();
}
},
addInterstitialAd() {
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-1ffb5a60bc3f7f55'
})
interstitialAd.onLoad(() => {})
interstitialAd.onError((err) => {})
interstitialAd.onClose(() => {})
}
},
showInterstitialAd() {
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
},
initData() {
this.queryAdConfigure().then((result) => {
this.queryTabList().then((result) => {
......
......@@ -26,10 +26,12 @@ Page({
primaryCode: this.data.options.c,
});
}
let opts = this.data.options;
let path = `pages/personal-list/personal-list?c=${opts.c}`;
if (app.globalData.adConfigure && app.globalData.adConfigure.ad_config_01 == 1) {
this.showInterstitialAd();
}
return {
path,
}
......@@ -49,7 +51,28 @@ Page({
wx.aldstat.sendEvent('进入页面', {
'页面名字': '个人列表页'
});
this.addInterstitialAd();
},
addInterstitialAd() {
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-1ffb5a60bc3f7f55'
})
interstitialAd.onLoad(() => {})
interstitialAd.onError((err) => {})
interstitialAd.onClose(() => {})
}
},
showInterstitialAd() {
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
},
initData() {
this.resetPage();
this.queryAccountDetail();
......
......@@ -39,6 +39,11 @@ Page({
let title = detailData && detailData.videoName || "";
let path = `pages/detail/detail?c=${detailData.videoCode}`;
let imageUrl = detailData && detailData.thumbnail || "";
if (app.globalData.adConfigure && app.globalData.adConfigure.ad_config_01 == 1) {
this.showInterstitialAd();
}
return {
title,
path,
......@@ -59,6 +64,26 @@ Page({
wx.aldstat.sendEvent('进入页面', {
'页面名字': '隐藏视频页'
});
this.addInterstitialAd();
},
addInterstitialAd() {
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: 'adunit-1ffb5a60bc3f7f55'
})
interstitialAd.onLoad(() => {})
interstitialAd.onError((err) => {})
interstitialAd.onClose(() => {})
}
},
showInterstitialAd() {
if (interstitialAd) {
interstitialAd.show().catch((err) => {
console.error(err)
})
}
},
/**
......