Commit 881d45d5 authored by mengcuiguang's avatar mengcuiguang

添加抖音广告

parent c18ad65a
...@@ -143,6 +143,40 @@ ...@@ -143,6 +143,40 @@
this.getData() this.getData()
// 创建实例
this.ad = tt.createRewardedVideoAd({
adUnitId: "5owlrx99qby0ephhco",
});
// 监听错误
this.ad.onError((err) => {
tt.hideLoading();
switch (err.errCode) {
case 1004:
// 无合适的广告
break;
default:
// 更多请参考错误码文档
}
});
// 监听视频播放完成
this.ad.onClose((data) => {
tt.hideLoading();
if (data.isEnded) {
console.log("观看了", data.count, "个视频");
} else {
console.log("未观看完视频");
}
});
// do other thing
// 卸载 close 事件监听
this.ad.offClose(closeHandler);
// 预加载资源
this.ad.load();
}, },
onShow() { onShow() {
// 从VIP页面返回关闭弹框 // 从VIP页面返回关闭弹框
...@@ -435,6 +469,9 @@ ...@@ -435,6 +469,9 @@
this.isqp = e.detail.show this.isqp = e.detail.show
}, },
collect(vedioId, index) { collect(vedioId, index) {
tt.showLoading();
this.ad.show();
this.data.collect = 1 this.data.collect = 1
// 收藏 // 收藏
this.post({ this.post({
......
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