合肥装修公司哪家口碑最好,网站优化时间,湖北省建设厅网站查询,免费建站系统软件【关键词】 快应用、激励视频广告、广告接入 【介绍】 一、关于激励视频广告 定义#xff1a;用户通过观看完整的视频广告#xff0c;获得应用内相关的奖励。适用场景#xff1a;游戏/快游戏的通关、继续机会、道具获取、积分等场景中#xff0c;阅读、影音等应用的权益体系…【关键词】 快应用、激励视频广告、广告接入 【介绍】 一、关于激励视频广告 定义用户通过观看完整的视频广告获得应用内相关的奖励。适用场景游戏/快游戏的通关、继续机会、道具获取、积分等场景中阅读、影音等应用的权益体系也有相关使用。支持格式横版视频、竖版视频。
二、实现流程
调用ad.getProvider()判断是否支持广告服务如果返回空字符串则无法使用广告服务。通过 const rewardedVideoAdad.createRewardedVideoAd()创建广告。调用rewardedVideoAd.load()拉取广告数据成功拉取广告数据后再显示广告的播放入口。成功执行rewardedVideoAd.onLoad()回调。失败执行rewardedVideoAd.onError回调。调用rewardedVideoAd.show()上报广告曝光。调用rewardedVideoAd.onClose()监听激励视频广告的关闭。关闭广告前调用rewardedVideoAd.load()获取下一次广告的数据。当应用页面销毁时调用rewardedVideoAd.destory()销毁激励视频广告。
【代码实现】
这里通过一个简单的在阅读中通过观看激励视频广告解锁章节的demo来加深一下对这块的掌握。
template!-- Only one root node is allowed in template. --div classcontainerdivtext classtitle第{{titleNum}}章/texttext classtitle{{title}}/text/divdiv classcontdiv styleflex-direction: column show{{!nextSection}}text classcontent这一段写啥我想写啥就写啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥啥/texttext classcontent这一段写设什么?我也不知道写啥那怎么办写一颗菠菜吧菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜菜/texttext classcontent我是一个苹果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果/texttext classcontent我是一个栗子栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗栗/text/divdiv styleflex-direction: column show{{nextSection}}text classcontent我是一个有信仰的梨子梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨梨/texttext classcontent最后一段了来个水果大集合吧果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果果/text/div/divdiv stylewidth: 100%; display: flex; justify-content: space-between; margin: 0 20pxtext classtitle show{{nextSection}} onclickbackClick上一章/texttext classtitle next onclicknextClick show{{!nextSection}}下一章/text/div/div
/templatestyle.container {flex-direction: column;}.clickStyle {height: 100px;width: 100%;background-color: #00bfff;color: #4b0082;font-size: 50px;font-weight: 500;}.img {width: 100%;height: 300px;}.title {font-size: 36px;font-weight: bold;margin-right: 20px;color: #4a90e2;}.next {left: 550;}.content {font-size: 36px;letter-spacing: 2px;text-indent: 2em;}.cont {width: 100%;}
/stylescriptimport ad from service.adimport prompt from system.prompt;let rewardedVideoAdmodule.exports {data: {componentName: ad,provider: ,title: 我是一个有信仰的水果,titleNum: 1,imgSrc: /Common/logo.png,componentData: {},nextSection: false,adStyle: {backgroundColor: #4A90E2},rewarded: {adUnitId: testx9dtjwj8hp,errStr: }},onInit() {// this.$page.setNavigationBar({visible: false})this.$page.setTitleBar({text: adExample,textColor: #ffffff,backgroundColor: #007DFF,backgroundOpacity: 0.5,menu: true})},onReady(options) {this.loadRewardAd();},loadRewardAd() {// 判断是否支持广告服务如果返回空字符串则无法使用广告服务this.provider ad.getProvider(); console.log(getProvider : this.provider)if (this.provider ! huawei) {console.info(the device does not support ad.);return;}// 创建广告rewardedVideoAd ad.createRewardedVideoAd({adUnitId: this.rewarded.adUnitId});// 拉取广告成功rewardedVideoAd.onLoad(() {this.rewarded.errStr ;console.log(onRewardedLoaded)});// 拉取广告失败rewardedVideoAd.onError(e {console.error(load rewarded video ad error: JSON.stringify(e));this.rewarded.errStr JSON.stringify(e);});// 监听激励视频广告的关闭rewardedVideoAd.onClose(res {console.log(rewarded ad onClose is watch end: res.isEnded);if (res.isEnded) {var that thisthat.titleNum that.titleNum 1that.title 民族有希望this.nextSection trueprompt.showToast({message: 成功解锁章节,duration: 2000,gravity: center});}//下一次广告预加载rewardedVideoAd.load();});// 拉取广告数据rewardedVideoAd.load();},backClick() {this.nextSection false},nextClick(e) {console.log(e, ----)if (!this.nextSection) {prompt.showDialog({title: 观看视频免费解锁下一章节,message: 当前免费章节已试读完毕观看视频免费解锁下一章节,buttons: [{text: 确定,color: #4a90e2},{text: 取消,color: red}],success: function (data) {console.log(handling callback, data.index, data.index 0);if (data.index 0) {// 上报广告曝光rewardedVideoAd.show();} else {console.log(rewardedVideoAd)// 销毁激励视频广告rewardedVideoAd rewardedVideoAd.destroy();}}})return}}}
/script 【效果展示】