文档管理中心
我的
API参考快应用组件ad-template(1113+)

ad-template(1113+)

概述

用来展示鲸鸿动能原生模板广告内容的组件。

注意
  1. 开发需要先基于ad.createNativeAd创建并load(必须设置新增的参数supportTemplate为true)成功后再去创建ad-template组件,且在onLoad中返回的广告类型为99(creativeType为99)时创建,否则无法渲染对应的广告。且一个adId只应绑定一个ad-template组件,此处可参考广告接口文档中的原生广告接口。
  2. 原生广告creativeType为99时,该广告对象只能用于绑定模板广告,请勿调用nativeAd.reportAdShow()、nativeAd.reportAdClick()、nativeAd.showAppDetailPage()和nativeAd.destroy()接口或绑定ad-button和ad-native-view组件,以免影响您的计费。

子组件

不支持。

属性

除了支持 通用属性以外,还支持如下属性。

展开

名称

类型

默认值

是否必填

描述

adid

string

-

是

广告信息标识,由onload回调返回。

样式

有限制地支持 通用样式 (不支持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。

注意
  1. 该组件必须完整对用户可见,不应被任何元素覆盖或遮挡(包括透明元素),否则可能影响计费。
  2. 请设置组件宽高为建议宽高,如果未设置宽高,当广告内容填充时,ad-template组件宽高会填充为父组件的宽高。
  3. 该组件必须完全在屏幕范围内。

事件

除了支持 通用事件以外,还支持如下事件。

展开

名称

参数

描述

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:""}

广告曝光事件

示例代码

收起
自动换行
深色代码主题
复制
  1. <template>
  2. <!-- Only one root node is allowed in template. -->
  3. <div class="container">
  4. <div class="item-container">
  5. <input type="button" class="btn" value="加载并展示原生模板广告" onclick="showNativeAd()" />
  6. <div class="abc">
  7. <ad-template class="adtemplate" adid="{{adId1}}" onerror = "showErr()" onfeedback="feedback()" onrender="render()" ondownloadstatus="downloadstatus()" onclick="click()"></ad-template>
  8. </div>
  9. <input type="button" class="btn" value="click" onclick="touchClick()" />
  10. <input type="button" class="btn" value="reportAdShow" onclick="reportAdShow11()" />
  11. <input type="button" class="btn" value="destroy" onclick="showdestroy()" />
  12. <input type="button" class="btn" value="showAppDetailPage" onclick="showAppDetail()" />
  13. </div>
  14. </div>
  15. </template>
  16. <style>
  17. .container {
  18. flex: 1;
  19. flex-direction: column;
  20. }
  21. .abc {
  22. width: 750px;
  23. height: 690px;
  24. }
  25. .adbutton {
  26. height: 50px;
  27. width: 600px;
  28. text-align: center;
  29. margin-top: 300px;
  30. margin-right: 60px;
  31. margin-left: 60px;
  32. margin-bottom: 50px;
  33. color: #dd6522;
  34. font-size: 30px;
  35. border-radius: 50;
  36. }
  37. .btn {
  38. height: 80px;
  39. width: 600px;
  40. text-align: center;
  41. margin-top: 20px;
  42. margin-right: 60px;
  43. margin-left: 60px;
  44. margin-bottom: 50px;
  45. color: #dd6522;
  46. font-size: 30px;
  47. border-radius: 50;
  48. }
  49. .item-container {
  50. margin-top: 50px;
  51. flex-direction: column;
  52. }
  53. .adtemplate {
  54. background-color:#dd6522;
  55. }
  56. .adtemplate1 {
  57. }
  58. </style>
  59. <script>
  60. import ad from '@service.ad'
  61. import device from '@system.device'
  62. import router from '@system.router'
  63. let nativeAd
  64. export default {
  65. componentName: 'ad',
  66. provider: '',
  67. data: {
  68. adId1: "",
  69. hcztransparent: "transparent",
  70. native: {
  71. adUnitId:'e04osddcd4',
  72. channel: 'this is channel',
  73. errStr: '',
  74. adIcon: '',
  75. },
  76. },
  77. onInit: function () {
  78. this.$page.setStatusBar({ immersive: true, textStyle: 'dark', backgroundColor: '#FFFFFF', backgroundOpacity: 0, visible: true });
  79. var queryString = JSON.stringify(this.$page.query)
  80. console.log("query result: " + queryString);
  81. },
  82. feedback(Object) {
  83. console.log("feedback: " + JSON.stringify(Object));
  84. console.log("feedback111: " + Object);
  85. },
  86. render() {
  87. console.log("render succ");
  88. },
  89. showErr() {
  90. console.log("render err");
  91. },
  92. click(){
  93. console.log("click");
  94. },
  95. downloadstatus(Object) {
  96. console.log("downloadstatus: " + JSON.stringify(Object));
  97. },
  98. showNativeAd() {
  99. let that = this;
  100. device.host({
  101. success: function (ret) {
  102. console.log("handling success: " + JSON.stringify(ret));
  103. },
  104. fail: function (erromsg, errocode) {
  105. console.log("handling success: " + errocode + ': ' + erromsg)
  106. },
  107. });
  108. nativeAd = ad.createNativeAd({
  109. adUnitId: this.native.adUnitId,
  110. channel: this.native.channel
  111. })
  112. nativeAd.onLoad((data) => {
  113. console.info('ad data loaded: ' + JSON.stringify(data))
  114. this.native.adData = data.adList[0]
  115. if (this.adidList === '') {
  116. this.adidList = this.native.adData.adId
  117. }
  118. this.adId1 = data.adList[0].adId
  119. })
  120. nativeAd.onError((e) => {
  121. console.error('load ad error:' + JSON.stringify(e))
  122. })
  123. nativeAd.load({
  124. supportTemplate: true
  125. })
  126. },
  127. touchClick() {
  128. console.error('load click:' + this.adId1)
  129. nativeAd.reportAdClick({
  130. adId: this.adId1,
  131. clickInfo: {
  132. clickX: 10,
  133. clickY: 10,
  134. creativeSize: "1080*600",
  135. density: "",
  136. upX: 0,
  137. upY: 0,
  138. sld: 0,
  139. }})
  140. },
  141. reportAdShow11() {
  142. nativeAd.reportAdShow({adId: this.adId1})
  143. },
  144. showdestroy() {
  145. nativeAd.destroy()
  146. },
  147. showAppDetail() {
  148. nativeAd.showAppDetailPage({adId: this.adId1})
  149. },
  150. }
  151. </script>

版本更新说明

展开

版本

发布日期

描述

1113

2024-04-28

第一次正式发布。