提交 7149086d 编写于 作者: W wanganxp 提交者: 雪洛

新功能示例补充注释

上级 08bcbd1a
......@@ -37,6 +37,8 @@
watchPermissionRRequest() {
this.permissionListener = uni.createRequestPermissionListener()
this.permissionListener!.onConfirm((_) => {
// TODO 目前onConfirm监听实现的在时间上不够精确,暂时需要延迟弹框,后续修复
// TODO 这里的弹框仅为演示,实际开发中监听权限申请的代码应该在app.uvue中,弹框应全局处理,可参考https://gitcode.net/dcloud/uni-api/-/tree/master/uni_modules/uni-prompt/utssdk/app-android 代码自行封装一个uts的全局弹框
this.timeoutId = setTimeout(() => {
this.isPermissionAlertShow = true
}, 100)
......
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1">
<!-- #endif -->
<page-head title="激励视频广告"></page-head>
<button :type="btnType" style="margin: 10px;" :disabled="btnDisable" @click="showAd()">{{btnText}}</button>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
......@@ -17,7 +11,7 @@
btnType: "primary",
btnDisable: false,
rewardAd: null as RewardedVideoAd | null,
isAdLoadSuccess:false
isAdLoadSuccess: false
}
},
onReady() {
......@@ -32,7 +26,7 @@
this.btnType = "primary"
if (this.rewardAd == null) {
this.rewardAd = uni.createRewardedVideoAd({
adpid: "1507000689"
adpid: "1507000689" //此处为测试广告位,实际开发中请在uni-ad后台申请自己的广告位后替换
})
this.rewardAd!.onError((_) => {
this.btnType = "warn"
......@@ -46,6 +40,7 @@
this.isAdLoadSuccess = true
})
this.rewardAd!.onClose((e) => {
// 测试广告位无法通过服务器回调。实际开发中,使用自己的广告位后,需参考uni-ad文档编写服务器回调的代码,在服务端发放奖励
this.isAdLoadSuccess = false
uni.showToast({
title: "激励视频" + (e.isEnded ? "" : "未") + "播放完毕",
......@@ -56,8 +51,8 @@
}
this.rewardAd!.load()
},
showAd(){
if(this.isAdLoadSuccess) {
showAd() {
if (this.isAdLoadSuccess) {
this.rewardAd!.show()
} else {
this.loadAd()
......
......@@ -41,7 +41,7 @@
type Page = {
name : string
enable ?: boolean
url ?: string
url ?: string.PageURIString
}
type ListItem = {
id : string
......@@ -269,9 +269,9 @@
] as Page[],
}
] as ListItem[],
arrowUpIcon: '/static/icons/arrow-up.png',
arrowDownIcon: '/static/icons/arrow-down.png',
arrowRightIcon: '/static/icons/arrow-right.png',
arrowUpIcon: '/static/icons/arrow-up.png' as string.ImageURIString,
arrowDownIcon: '/static/icons/arrow-down.png' as string.ImageURIString,
arrowRightIcon: '/static/icons/arrow-right.png' as string.ImageURIString,
pageHiden: false
}
},
......@@ -280,7 +280,7 @@
if (e.enable == false) {
uni.showToast({
title: '暂不支持',
icon: 'none',
icon: 'none'
})
return
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册