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

新功能示例补充注释

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