From d49c73f77965a94d86b0f58993d2a2df07d3e99d Mon Sep 17 00:00:00 2001 From: mahaifeng Date: Thu, 26 Sep 2024 11:13:42 +0800 Subject: [PATCH] =?UTF-8?q?[privacy]=E6=B7=BB=E5=8A=A0=E9=9A=90=E7=A7=81?= =?UTF-8?q?=E6=94=BF=E7=AD=96=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.uvue | 29 +++++++++++++++++-- pages.json | 7 +++++ pages/API/dialog-page/dialog-privacytest.uvue | 29 ++++++++++--------- pages/component/open-type/open-type.uvue | 21 +++++++------- 4 files changed, 59 insertions(+), 27 deletions(-) diff --git a/App.uvue b/App.uvue index 831d2ac3..bd361ebd 100644 --- a/App.uvue +++ b/App.uvue @@ -28,7 +28,8 @@ path: '' } as OnShowOptions }, - onLaunch: function (res : OnLaunchOptions) { + onLaunch: function (res : OnLaunchOptions) { + this.globalData.launchOptions = res // 自动化测试 @@ -55,7 +56,31 @@ }, fail(err) { console.log(err); } - }) + }) + // #ifdef APP + if (process.env.NODE_ENV === 'development') { + //真机运行可以去掉此注释 + // uni.getPrivacySetting({ + // success(res){ + // if(res.needAuthorization){ + // uni.openDialogPage({ + // url: '/pages/API/dialog-page/dialog-privacytest', + // }) + // } + // } + // }) + }else { + uni.getPrivacySetting({ + success(res1){ + if(res1.needAuthorization){ + uni.openDialogPage({ + url: '/pages/API/dialog-page/dialog-privacytest', + }) + } + } + }) + } + // #endif }, onShow: function (res : OnShowOptions) { this.globalData.onShowOption = res diff --git a/pages.json b/pages.json index 165a2d8f..c22aa3eb 100644 --- a/pages.json +++ b/pages.json @@ -1861,6 +1861,13 @@ "navigationBarTitleText": "", "backgroundColorContent": "#fffae8" } + }, + { + "path" : "pages/API/dialog-page/dialog-privacytest", + "style" : + { + "navigationBarTitleText" : "" + } } ], "globalStyle": { diff --git a/pages/API/dialog-page/dialog-privacytest.uvue b/pages/API/dialog-page/dialog-privacytest.uvue index 582097f4..18dc793b 100644 --- a/pages/API/dialog-page/dialog-privacytest.uvue +++ b/pages/API/dialog-page/dialog-privacytest.uvue @@ -1,10 +1,14 @@ @@ -15,27 +19,24 @@ } }, - methods: { - agree() { - // #ifdef APP-ANDROID + onLoad() { + uni.onPrivacyAuthorizationChange((callback) => { uni.showToast({ - title: 'isPrivacyAgree:' + UTSAndroid.isPrivacyAgree() + title: 'isPrivacyAgree:' + !callback.needAuthorization }) + }) + }, + methods: { + agree() { uni.closeDialogPage({ dialogPage: this.$page as UniDialogPage }) - // #endif }, reject() { - // #ifdef APP-ANDROID - UTSAndroid.setPrivacyAgree(false) - uni.showToast({ - title: 'isPrivacyAgree:' + UTSAndroid.isPrivacyAgree() - }) + uni.resetPrivacyAuthorization() uni.closeDialogPage({ dialogPage: this.$page as UniDialogPage }) - // #endif } } } diff --git a/pages/component/open-type/open-type.uvue b/pages/component/open-type/open-type.uvue index e043d57b..9ff2f4be 100644 --- a/pages/component/open-type/open-type.uvue +++ b/pages/component/open-type/open-type.uvue @@ -2,7 +2,8 @@ - + @@ -16,17 +17,15 @@ log: "", } }, + onLoad() { + uni.onPrivacyAuthorizationChange((callback) => { + this.isAgreeRes = !callback.needAuthorization + uni.showToast({ + title: 'isPrivacyAgree:' + this.isAgreeRes + }) + }) + }, methods: { - agree() { - // #ifdef APP-ANDROID - - let res = UTSAndroid.isPrivacyAgree() - this.isAgreeRes = res - uni.showToast({ - title:'isPrivacyAgree:'+res - }) - // #endif - } } } -- GitLab