目录

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

广告曝光事件

示例代码

<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>

版本更新说明

版本

发布日期

描述

1113

2024-04-28

第一次正式发布。