提交 e684f869 编写于 作者: H hdx

uni-ad: 将以前的API文档迁移至新地址

上级 9fb51bb9
......@@ -23,66 +23,4 @@
[开通广告步骤详情](https://uniapp.dcloud.net.cn/uni-ad.html#start)
### 语法
`plus.ad.showContentPage(options, success, fail)`
### 参数说明
`options` 为 object 类型,属性如下:
|属性名 |类型 |必填 |描述 |
|:-:|:-:|:-:|:-:|
|adpid |string | 是|广告位 id |
|background |string | 否|背景颜色,不支持透明度 |
`success` 为 function 类型,加载成功后的回调
`fail` 为 function 类型,加载失败后的回调
HBuilder 基座的测试广告位 `adpid``1111111112`
示例代码
```html
<template>
<view>
<button :loading="loading" :disabled="loading" type="primary" class="btn" @click="showAd">显示广告</button>
</view>
</template>
<script>
export default {
data() {
return {
loading: false
}
},
onLoad() {
// HBuilderX 标准基座真机运行测试内容联盟广告位标识(adpid)为:1111111112
// adpid: 1111111112 仅用于测试,发布时需要改为广告后台(https://uniad.dcloud.net.cn/)申请的 adpid
// 广告后台申请的广告位(adpid)需要自定义基座/云打包/本地打包后生效
this.adOptions = {
adpid: 1111111112
}
},
methods: {
showAd() {
if (this.loading == true) {
return;
}
this.loading = true;
plus.ad.showContentPage(this.adOptions, (res) => {
this.loading = false;
}, (err) => {
this.loading = false;
console.log(err);
});
}
}
}
</script>
```
文档已迁移至 [短视频内容联盟广告](https://uniapp.dcloud.net.cn/uni-ad/ad-content-page.html)
......@@ -13,115 +13,4 @@
[开通广告步骤详情](https://uniapp.dcloud.net.cn/uni-ad.html#start)
uni.createFullScreenVideoAd(Object)
|属性|类型|必填|说明|
|:-:|:-:|:-:|:-:|
|adpid|string|是|广告位 id|
#### 方法
加载全屏视频广告。
`Promise FullScreenVideoAd.load()`
显示全屏视频广告。
`Promise FullScreenVideoAd.show()`
销毁全屏视频广告实例。
`FullScreenVideoAd.destroy()`
监听全屏视频广告加载事件。
`FullScreenVideoAd.onLoad(function callback)`
监听全屏视频错误事件。
`FullScreenVideoAd.onError(function callback)`
监听全屏视频广告关闭事件。
`FullScreenVideoAd.onClose(function callback)`
示例代码
```html
<template>
<view>
<button :loading="loading" :disabled="loading" type="primary" @click="showFullScreenVideoAd">显示广告</button>
</view>
</template>
<script>
export default {
data() {
return {
title: '全屏视频广告',
loading: false
}
},
onReady() {
// HBuilderX标准基座真机运行测试全屏视频广告位标识(adpid)为:1507000611
// adpid: 1507000611 仅用于测试,发布时需要改为广告后台(https://uniad.dcloud.net.cn/)申请的 adpid
// 广告后台申请的广告位(adpid)需要自定义基座/云打包/本地打包后生效
this.adOption = {
adpid: '1507000611'
};
// 创建广告实例
this.createFullScreenVideoAd();
},
methods: {
createFullScreenVideoAd() {
var fullScreenVideoAd = this.fullScreenVideoAd = uni.createFullScreenVideoAd(this.adOption);
fullScreenVideoAd.onLoad(() => {
// 广告数据加载成功
this.loading = false;
console.log("onLoad");
});
fullScreenVideoAd.onClose((e) => {
// 用户点击了关闭或返回键(仅Android有返回键)
console.log("onClose " + e.isEnded);
});
fullScreenVideoAd.onError((err) => {
console.log("onError", JSON.stringify(err));
// 广告数据加载失败
this.loading = false;
uni.showToast({
title: `${err.code} : ${err.errMsg}`
})
});
},
showFullScreenVideoAd() {
// 调用 fullScreenVideoAd.show(),如果数据正在加载中不会显示广告,加载成功后才显示
// 在数据没有加载成功时,需要防止用户频繁点击显示广告
if (this.loading == true) {
return
}
this.loading = true;
this.fullScreenVideoAd.show().then(() => {
this.loading = false;
}).catch((err) => {
console.log(err.message);
this.loading = false;
uni.showToast({
title: `${err.code} : ${err.errMsg}`
})
});
}
},
onUnload() {
this.fullScreenVideoAd.destroy()
}
}
</script>
```
文档已迁移至 [全屏视频](https://uniapp.dcloud.net.cn/uni-ad/ad-fullscreen-video.html)
......@@ -136,278 +136,4 @@
[开通广告步骤详情](https://uniapp.dcloud.net.cn/uni-ad.html#start)
注意:打包时必须选择要集成的广告SDK互动游戏(变现猫),优量汇、穿山甲、快手至少选择其中一个。
### 语法
`uni.createInteractiveAd(options)`
### 参数说明
`options` 为 object 类型,属性如下:
|属性名 |类型 |必填 |描述 |
|:-:|:-:|:-:|:-:|
|adpid |string | 是 |广告位 id |
|provider |string | 是 |服务商标识,即插件id|
|userData |object | 否 |对接App积分系统参数 |
`provider` 值:
|值 |描述 |
|:-:|:-:|
|BXM-AD |互动游戏变现猫|
### 广告创建
广告组件默认是隐藏的,因此可以提前创建,以提前初始化组件。开发者可以在页面的 onReady 事件回调中创建广告实例,并在该页面的生命周期内重复调用该广告实例。
### 显示/隐藏
广告组件默认是隐藏的,开发者需要调用 CreateInteractiveAd.show() 进行显示。如果广告拉取失败或触发频率限制,CreateInteractiveAd.show() 方法会返回一个rejected Promise,开发者可自行监听错误信息
```js
CreateInteractiveAd.show().catch((err) => {
console.error(err)
})
```
用户可以主动关闭广告。开发者不可控制广告组件的隐藏。
### 监听广告加载成功事件
如果广告加载成功,通过 CreateInteractiveAd.onLoad() 注册的回调函数会执行,回调函数返回广告素材参数。
|属性名 |类型 |描述 |
|:-:|:-:|:-:|
|imgUrl |string | 广告素材图片的url地址 |
```js
CreateInteractiveAd.onLoad(res => {
console.log('图片素材地址', res.imgUrl);
console.log('广告加载成功');
})
```
HBuilder基座的测试广告位 adpid: `1042956255` (游戏); `1620839118` (抽奖); `1064042976` (养成)
示例代码
```html
<template>
<view>
<image class="ad-icon" v-if="imgUrl" :src="imgUrl" @click="showInteractiveAd"></image>
</view>
</template>
<script>
export default {
data() {
return {
title: '互动游戏',
loading: false,
imgUrl: ""
}
},
onReady() {
this.adOption = {
adpid: '1042956255',
provider: 'BXM-AD'
};
// 创建广告实例
this.createInteractiveAd();
},
methods: {
createInteractiveAd() {
var interactiveAd = this.interactiveAd = uni.createInteractiveAd(this.adOption);
interactiveAd.onLoad((e) => {
this.loading = false;
this.imgUrl = e.imgUrl;
console.log("广告加载成功");
// 如果有广告图片素材, 通过 e.imgUrl 获取
});
interactiveAd.onClose(() => {
// 用户点击了关闭或返回键(仅Android有返回键)
console.log("广告关闭");
});
interactiveAd.onError((err) => {
this.loading = false;
console.log("广告加载失败");
});
// 广告实例创建成功后默认会执行一次 load,加载广告数据
// 如果界面有 "显示广告" 按钮,需要先禁用掉,防止用户点击,等待广告数据加载成功后在放开
this.loading = true;
},
showInteractiveAd() {
// 调用 interactiveAd.show(),如果数据正在加载中不会显示广告,加载成功后才显示
// 在数据没有加载成功时,需要防止用户频繁点击显示广告
if (this.loading == true) {
return
}
this.loading = true;
this.interactiveAd.show().then(() => {
this.loading = false;
});
}
},
onUnload() {
// 页面关闭后销毁实例
this.interactiveAd.destroy();
}
}
</script>
<style>
.ad-icon {
display: block;
width: 80px;
height: 80px;
margin: 10px;
}
</style>
```
#### 方法
`Promise CreateInteractiveAd.load()`
加载广告。
`Promise CreateInteractiveAd.show()`
显示广告。
`CreateInteractiveAd.reportExposure()`
场景入口曝光打点。
`CreateInteractiveAd.destroy()`
销毁广告实例。
`CreateInteractiveAd.onLoad(function callback)`
监听广告加载事件。
`CreateInteractiveAd.offLoad(function callback)`
取消监听广告加载事件
`CreateInteractiveAd.onError(function callback)`
监听错误事件。
`CreateInteractiveAd.offError(function callback)`
取消监听错误事件
### 积分对接
### 开通
1. 开发者需要提供广告位 `adpid`
2. 开发者需要提供服务器接口
1. 获取积分接口
2. 操作积分接口
4. 三方服务商需要提供 `secretKey` 让开发者来验签请求来源
### 获取积分
简要描述:
该接口用于获取用户总积分数量;
开发者提供url用户查询积分
请求方式 `GET`
参数:
|参数名|必选|类型|说明|
|:-:|:-:|:-:|:-:|
|appUserId|是|String|app用户Id|
|appId|是|String|SSP后台注册的appId|
|timestamp|是|String|时间戳(自1970年起,精确到毫秒)|
|sign|是|String|签名,用于验证身份。按照按 secretKey + timestamp 的进行MD5加密(注意加密后字符串要转大写,不要加上“+”号)|
返回参数说明
|参数名|类型|说明|
|:-:|:-:|:-:|
|appUserId|String|app用户Id|
|avatar|String|用户头像|
|nickname|String|用户昵称|
|amount|Long|用户总积分|
示例
```json
{
"appUserId" : "dcloud",
"avatar": "https://xxx.yyy.com/xxxx.jpg",
"nickname": "jack",
"amount": 100
}
```
### 操作积分
简要描述:
此接口用于操作用户积分数量,如增加、扣除;
请求参数放在body里,以JSON格式提交;
考虑到接口的安全,建议开发者采用IP白名单+签名的方式校验来源,以防备被第三方利用。
失败情况:
- URL存在特殊字符或无法通过外网访问;
- 没有按照响应格式要求返回的内容;
- 接口返回状态码非`200`的情况;
- 接口响应时间超过`3`秒。
开发者提供url用户查询积分
请求方式 `POST`
参数:
|参数名|必选|类型|说明|
|:-:|:-:|:-:|:-:|
|appUserId|是|String|App用户Id(唯一标识)|
|appId|是|String|SSP后台注册的appId|
|operateType|是|Long|操作类型:1.增加 2.扣除|
|amount|是|Long|本次操作的积分值|
|timestamp|是|String|时间戳(自1970年起,精确到毫秒)|
|sign|是|String|签名,用于验证身份。按照按 secretKey + timestamp 进行MD5加密(注意加密后字符串要转大写,不要加上“+”号)|
返回参数说明
|参数名|类型|说明|
|:-:|:-:|:-:|
|appUserId|String|App用户Id(唯一标识)|
|status|int|状态码:0. 处理失败 1. 处理成功|
|message|String|失败原因|
|amount|Long|操作后的用户总积分|
返回结果示例
```json
{
"appUserId": "dcloud",
"status": 1,
"amount": 100
}
```
文档已迁移至 [互动游戏](https://uniapp.dcloud.net.cn/uni-ad/interactive.html)
......@@ -13,159 +13,4 @@
[开通广告步骤详情](https://uniapp.dcloud.net.cn/uni-ad.html#start)
### 语法
`uni.createInterstitialAd(options)`
### 参数说明
`options` 为 object 类型,属性如下:
|属性名 |类型 |必填 |描述 |最低支持版本 |
|:-:|:-:|:-:|:-:|:-:|
|adpid |string | 是|广告位 id |App 3.1.10+|
|adUnitId |string | 是|广告位 id |微信小程序2.6.0+, QQ0.1.26+|
HBuilder 基座的测试广告位 `adpid``1111111113`
### 广告创建
插屏广告组件默认是隐藏的,因此可以提前创建,以提前初始化组件。开发者可以在页面的 onReady 事件回调中创建广告实例,并在该页面的生命周期内重复调用该广告实例。
### 显示/隐藏
插屏广告组件默认是隐藏的,开发者需要调用 InterstitialAd.show() 进行显示。如果广告拉取失败或触发频率限制,InterstitialAd.show() 方法会返回一个rejected Promise,开发者可自行监听错误信息
```js
interstitialAd.show().catch((err) => {
console.error(err)
})
```
用户可以主动关闭插屏广告。开发者不可控制插屏广告组件的隐藏。
### 监听用户关闭广告
如果广告被关闭,通过 InterstitialAd.onClose() 注册的回调函数会执行,回调函数没有参数传递。
```js
interstitialAd.onClose(res => {
console.log('插屏 广告关闭')
})
```
示例代码
```html
<template>
<view>
<view>
<button :loading="loading" :disabled="loading" type="primary" @click="showInterstitialAd">显示广告</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '插屏广告',
loading: false
}
},
onReady() {
this.adOption = {
adpid: '1111111113' // HBuilder基座的测试广告位
};
// 创建广告实例
this.createInterstitialAd();
},
methods: {
createInterstitialAd() {
var interstitialAd = this.interstitialAd = uni.createInterstitialAd(this.adOption);
interstitialAd.onLoad(() => {
this.loading = false;
console.log("插屏 广告加载成功");
});
interstitialAd.onClose(() => {
// 用户点击了关闭或返回键(仅Android有返回键)
console.log("插屏 广告关闭");
});
interstitialAd.onError((err) => {
this.loading = false;
console.log("插屏 广告加载失败");
});
// 广告实例创建成功后默认会执行一次 load,加载广告数据
// 如果界面有 "显示广告" 按钮,需要先禁用掉,防止用户点击,等待广告数据加载成功后在放开
this.loading = true;
},
showInterstitialAd() {
// 调用 interstitialAd.show(),如果数据正在加载中不会显示广告,加载成功后才显示
// 在数据没有加载成功时,需要防止用户频繁点击显示广告
if (this.loading == true) {
return
}
this.loading = true;
this.interstitialAd.show().then(() => {
this.loading = false;
});
}
},
onUnload() {
// 页面关闭后销毁实例
this.interstitialAd.destroy()
}
}
</script>
```
#### 方法
`Promise InterstitialAd.load()`
加载插屏广告。
`Promise InterstitialAd.show()`
显示插屏广告。
`InterstitialAd.destroy()`
销毁插屏广告实例。
`InterstitialAd.onLoad(function callback)`
监听插屏广告加载事件。
`InterstitialAd.offLoad(function callback)`
取消监听插屏广告加载事件
`InterstitialAd.onError(function callback)`
监听插屏错误事件。
`InterstitialAd.offError(function callback)`
取消监听插屏错误事件
`InterstitialAd.onClose(function callback)`
监听插屏广告关闭事件。
`InterstitialAd.offClose(function callback)`
取消监听插屏广告关闭事件
### 注意事项
在插屏广告展示过程中如果快速切换页面,可能会出现插屏广告展示在非调用页面的情况,如有需要请在页面切换完成后进行插屏广告展示。
文档已迁移至 [插屏视频](https://uniapp.dcloud.net.cn/uni-ad/ad-interstitial.html)
......@@ -15,4 +15,4 @@
[开通广告步骤详情](https://uniapp.dcloud.net.cn/uni-ad.html#start)
文档已迁移至 [Grid 广告](https://uniapp.dcloud.net.cn/uni-ad/ad-grid.md)
文档已迁移至 [Grid 广告](https://uniapp.dcloud.net.cn/uni-ad/ad-grid.html)
......@@ -17,4 +17,4 @@
[开通广告步骤详情](https://uniapp.dcloud.net.cn/uni-ad.html#start)
文档已迁移至 [互动游戏](https://uniapp.dcloud.net.cn/uni-ad/interactive.md)
文档已迁移至 [互动游戏](https://uniapp.dcloud.net.cn/uni-ad/interactive.html)
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册