提交 23ab35f9 编写于 作者: d-u-a's avatar d-u-a

ad: 增加全屏视频示例

上级 65c4c43a
...@@ -622,6 +622,14 @@ ...@@ -622,6 +622,14 @@
"navigationBarTitleText": "激励视频广告" "navigationBarTitleText": "激励视频广告"
} }
}, },
// #endif
// #ifdef APP-PLUS
{
"path": "full-screen-video-ad/full-screen-video-ad",
"style": {
"navigationBarTitleText": "全屏视频广告"
}
},
// #endif // #endif
// #ifndef H5 // #ifndef H5
{ {
......
<template>
<view>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button :loading="loading" :disabled="loading" type="primary" class="btn" @click="showAd">显示广告</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '全屏视频广告',
loading: false,
loadError: false
}
},
onReady() {
// #ifdef APP-PLUS
this.adOption = {
adpid: '1507000611'
};
// #endif
this.createAd();
},
methods: {
createAd() {
var _ad = this._ad = uni.createFullScreenVideoAd(this.adOption);
_ad.onLoad(() => {
this.loading = false;
this.loadError = false;
_ad.show();
console.log('onLoad event')
});
_ad.onClose((res) => {
// 用户点击了【关闭广告】按钮
if (res && res.isEnded) {
// 正常播放结束
console.log("onClose " + res.isEnded);
} else {
// 播放中途退出
console.log("onClose " + res.isEnded);
}
setTimeout(() => {
uni.showToast({
title: "全屏视频" + (res.isEnded ? "成功" : "") + "播放完毕",
duration: 10000,
position: 'bottom'
})
}, 500)
});
_ad.onError((err) => {
this.loading = false;
if (err.code) {
this.loadError = true;
}
console.log('onError event', err)
uni.showToast({
title: err.errMsg,
position: 'bottom'
})
});
},
showAd() {
this.loading = true;
this._ad.load();
}
}
}
</script>
<style>
.btn {
margin-bottom: 20px;
}
.ad-tips {
color: #999;
padding: 30px 0;
text-align: center;
}
</style>
...@@ -310,6 +310,11 @@ ...@@ -310,6 +310,11 @@
name: '激励视频广告', name: '激励视频广告',
open: false open: false
}, },
{
url: 'full-screen-video-ad',
name: '全屏视频广告',
open: false
},
// #endif // #endif
// #ifndef H5 || QUICKAPP-WEBVIEW // #ifndef H5 || QUICKAPP-WEBVIEW
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册