用来展示鲸鸿动能原生模板广告内容的组件。
有限制地支持 通用样式 (不支持background和background-image,不支持padding,padding-left,padding-right,padding-top,padding-bottom,不支持opacity样式,不支持transform:scale,transform:scaleX,transform:scaleY动画样式),受限制的通用样式如下:
名称 | 类型 | 默认值 | 是否必填 | 描述 |
|---|---|---|---|---|
background-color | <color> | 无 | 否 | 组件背景颜色,当设置成rgba或者hsla类型颜色值时,透明度通道设置无效,指定为不透明。 |
height | <length> | 无 | 否 | 组件高度,取值范围:不小于590px。 |
width | <length> | 无 | 否 | 组件宽度,取值范围:不小于650px。 |
border-radius(1118+) | <length> | 33.5px | 否 | 组件圆角,建议设置为33.5px。 |
建议宽高:
广告类型 | 样式 | 建议宽高 |
|---|---|---|
原生模板 | 原生插屏 | width:650px ; height:590px。 |
原生模板 | 原生插页 | width:650px ; height:933px。 |
除了支持 通用事件以外,还支持如下事件。
名称 | 参数 | 描述 |
|---|---|---|
error | {code:codeInteger,description:descriptionString} | 广告加载失败。 |
render | - | 广告加载成功。 |
feedback | {eventName: ""} | 用户点击了广告反馈按钮。 like:用户喜欢。 dislike:用户不喜欢。 close:关闭。 其中dislike与close强行清除广告对应的广告内容,广告组件交给开发者进行处理。 |
downloadStatus | {packageName:packageNameValue,status:statusValue,progress:progressValue} | adid:广告标识;status:下载状态;progress:下载进度,范围0~100。 |
adclick(1116+) | {adid:""} | 广告点击事件 |
adimpression(1117+) | {adid:""} | 广告曝光事件 |
<template>
<!-- Only one root node is allowed in template. -->
<div class="container">
<div class="item-container">
<input type="button" class="btn" value="加载并展示原生模板广告" onclick="showNativeAd()" />
<div class="abc">
<ad-template class="adtemplate" adid="{{adId1}}" onerror = "showErr()" onfeedback="feedback()" onrender="render()" ondownloadstatus="downloadstatus()" onclick="click()"></ad-template>
</div>
<input type="button" class="btn" value="click" onclick="touchClick()" />
<input type="button" class="btn" value="reportAdShow" onclick="reportAdShow11()" />
<input type="button" class="btn" value="destroy" onclick="showdestroy()" />
<input type="button" class="btn" value="showAppDetailPage" onclick="showAppDetail()" />
</div>
</div>
</template>
<style>
.container {
flex: 1;
flex-direction: column;
}
.abc {
width: 750px;
height: 690px;
}
.adbutton {
height: 50px;
width: 600px;
text-align: center;
margin-top: 300px;
margin-right: 60px;
margin-left: 60px;
margin-bottom: 50px;
color: #dd6522;
font-size: 30px;
border-radius: 50;
}
.btn {
height: 80px;
width: 600px;
text-align: center;
margin-top: 20px;
margin-right: 60px;
margin-left: 60px;
margin-bottom: 50px;
color: #dd6522;
font-size: 30px;
border-radius: 50;
}
.item-container {
margin-top: 50px;
flex-direction: column;
}
.adtemplate {
background-color:#dd6522;
}
.adtemplate1 {
}
</style>
<script>
import ad from '@service.ad'
import device from '@system.device'
import router from '@system.router'
let nativeAd
export default {
componentName: 'ad',
provider: '',
data: {
adId1: "",
hcztransparent: "transparent",
native: {
adUnitId:'e04osddcd4',
channel: 'this is channel',
errStr: '',
adIcon: '',
},
},
onInit: function () {
this.$page.setStatusBar({ immersive: true, textStyle: 'dark', backgroundColor: '#FFFFFF', backgroundOpacity: 0, visible: true });
var queryString = JSON.stringify(this.$page.query)
console.log("query result: " + queryString);
},
feedback(Object) {
console.log("feedback: " + JSON.stringify(Object));
console.log("feedback111: " + Object);
},
render() {
console.log("render succ");
},
showErr() {
console.log("render err");
},
click(){
console.log("click");
},
downloadstatus(Object) {
console.log("downloadstatus: " + JSON.stringify(Object));
},
showNativeAd() {
let that = this;
device.host({
success: function (ret) {
console.log("handling success: " + JSON.stringify(ret));
},
fail: function (erromsg, errocode) {
console.log("handling success: " + errocode + ': ' + erromsg)
},
});
nativeAd = ad.createNativeAd({
adUnitId: this.native.adUnitId,
channel: this.native.channel
})
nativeAd.onLoad((data) => {
console.info('ad data loaded: ' + JSON.stringify(data))
this.native.adData = data.adList[0]
if (this.adidList === '') {
this.adidList = this.native.adData.adId
}
this.adId1 = data.adList[0].adId
})
nativeAd.onError((e) => {
console.error('load ad error:' + JSON.stringify(e))
})
nativeAd.load({
supportTemplate: true
})
},
touchClick() {
console.error('load click:' + this.adId1)
nativeAd.reportAdClick({
adId: this.adId1,
clickInfo: {
clickX: 10,
clickY: 10,
creativeSize: "1080*600",
density: "",
upX: 0,
upY: 0,
sld: 0,
}})
},
reportAdShow11() {
nativeAd.reportAdShow({adId: this.adId1})
},
showdestroy() {
nativeAd.destroy()
},
showAppDetail() {
nativeAd.showAppDetailPage({adId: this.adId1})
},
}
</script>