English
code | message |
---|---|
-5001 | The advertising slot identifier adpid is empty, please pass in a valid adpid |
-5002 | Invalid ad slot identifier adpid, please use the correct adpid |
-5003 | The advertisement has not been activated, please apply on the advertising platform and ensure that it has been approved |
-5004 | No advertising module, please configure the advertising module to be used when packaging |
-5005 | Ad failed to load, please reload after a while, otherwise system policies may be triggered and traffic revenue may decrease |
-5006 | Ads are not loaded and cannot be played. Please adjust show after loading. |
-5007 | Could not get ad configuration data, please try again |
-5008 | Ad has expired, please reload data |
-5100 | Other errors, Aggregate Advertiser Internal Error |
-5005即广告没有填充,尤其是激励视频较为常见。
使用视频模拟广告示例
<!-- pages/index/index.nvue -->
<template>
<view class="content">
<ad-rewarded-video adpid="1507000689" :loadnext="true" v-slot:default="{loading, error}" @error="onaderror">
<button :disabled="loading" :loading="loading">显示广告</button>
<view v-if="error">{{error}}</view>
</ad-rewarded-video>
</view>
</template>
<script>
export default {
data() {
return {}
},
methods: {
onaderror(e) {
// 广告加载失败
console.log("onaderror: ", e.detail);
if (e.detail.errCode == -5005) {
uni.navigateTo({
url: '/pages/adVideo/adVideo',
events: {
// 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据
onVideoClosed: function(data) {
console.log(data);
}
}
})
}
}
}
}
</script>
<!-- pages/adVideo/adVideo.nvue -->
<template>
<view class="container">
<video id="myVideo" :src="src" :autoplay="true" :controls="false" @ended="onfinish" @click="toLandVideo"
@timeupdate="onTimeUpdate" class="video"></video>
<view class="close-box">
<text v-if="countdown>0" class="close">{{countdown}}s</text>
<text v-if="showClose" class="close" @click="closeVideo">X</text>
</view>
<text class="ad-tip">广告</text>
</view>
</template>
<script>
export default {
data() {
return {
src: "", //视频地址
showClose: false,
countdown: '',
}
},
onReady() {
this.videoContext = uni.createVideoContext('myVideo')
},
onLoad() {
this.isFinish = false
this.isPalying = false
},
onShow() {
if (!this.isFinish && this.videoContext) this.videoContext.play()
},
onBackPress() {
return !this.isFinish
},
methods: {
onfinish(e) {
// console.log("onfinish:" + JSON.stringify(e));
this.showClose = true
this.isFinish = true
},
closeVideo() {
const eventChannel = this.getOpenerEventChannel();
eventChannel.emit('onVideoClosed', {
data: ''
});
uni.navigateBack()
},
toLandVideo() {
this.videoContext.pause()
uni.navigateTo({
url: "/pages/landVideo/landVideo"
})
},
onTimeUpdate(e) {
this.countdown = parseInt(e.detail.duration - e.detail.currentTime)
}
}
}
</script>
<style>
.container {
flex: 1;
position: relative;
}
.video {
flex: 1;
}
.close-box {
top: 10rpx;
right: 50rpx;
position: absolute;
flex-direction: row;
}
.close {
color: #808080;
font-size: 50rpx;
width: 100rpx;
text-align: center;
}
.ad-tip {
bottom: 20rpx;
right: 50rpx;
position: absolute;
color: #666;
font-size: 28rpx;
}
</style>
<!-- pages/landVideo/landVideo.vue -->
<template>
<view>
<web-view src="广告落地页url"></web-view>
</view>
</template>
<script>
export default {
data() {
return {}
},
methods: {}
}
</script>
提示:-5005 时,包含二级错误码,可在下面广告商错误码中找到具体原因
code | message |
---|---|
40001 | No Network |
40002 | Data parsing failed |
40003 | The ad data is empty |
40004 | The cached video resource is missing |
100001 | Incorrect parameter |
100002 | Server Error |
100003 | Operation not allowed |
100004 | Service unavailable |
310001 | appId not registered |
310002 | Invalid appId |
310003 | appId has been banned |
310004 | packageName is inconsistent with the registered packageName |
310005 | The operating system is inconsistent with the registration |
320002 | The account corresponding to the appId is invalid |
320003 | The account corresponding to the appId has been banned |
330001 | posId not registered |
330002 | posId is invalid |
330003 | posId has been banned |
330004 | posid is inconsistent with the registered appId information |