Compare commits

...

1 Commits

Author SHA1 Message Date
刘嘉炜 28b407ba21 add privacy test 2 years ago
  1. 12
      src/App.vue
  2. 11
      src/manifest.json
  3. 6
      src/pages.json
  4. 11
      src/pages/index/index.vue
  5. 64
      src/subpackage/common/pages/privacy.vue

12
src/App.vue

@ -3,12 +3,20 @@
import util from './utils/util';
export default {
onLaunch: function() {
// #ifndef H5
this.updateManager();
// #endif
wx?.onNeedPrivacyAuthorization?.((resolve, eventInfo) => {
console.log('触发本次事件的接口是:' + eventInfo.referrer)
//
//
this.globalData.resolvePrivacyAuthorization = resolve;
// resolve({ buttonId: 'agree-btn', event:'agree' })
uni.navigateTo({ url: `/subpackage/common/pages/privacy`});
})
},
methods: {
isLogin(){
return !!uni.getStorageSync('token');
},
updateManager(){

11
src/manifest.json

@ -60,7 +60,16 @@
"urlCheck" : false,
"minified" : true
},
"usingComponents" : true
"usingComponents" : true,
"permission" : {
"scope.userLocation" : {
"desc" : "你的位置信息将用于小程序位置接口的效果展示"
}
},
"requiredPrivateInfos": [
"getLocation"
],
"__usePrivacyCheck__": true
},
"mp-alipay" : {
"usingComponents" : true

6
src/pages.json

@ -703,6 +703,12 @@
"style" : {
"navigationBarTitleText": "支付订单"
}
},
{
"path": "pages/privacy",
"style" : {
"navigationBarTitleText": "隐私授权"
}
}
]
}

11
src/pages/index/index.vue

@ -173,6 +173,17 @@
}
},
async onLoad(options) {
uni.getLocation({
type: 'gcj02',
success: function (res) {
console.log('当前位置的经度:' + res.longitude);
console.log('当前位置的纬度:' + res.latitude);
},
fail: function (err) {
console.log('获取位置失败:' + JSON.stringify(err));
}
});
try{
util.showLoad();
// 20230829

64
src/subpackage/common/pages/privacy.vue

@ -0,0 +1,64 @@
<template>
<view class="privacy">
<view class="p-text" @click="openPrivacy"><text>{{ privacyContractName }}</text></view>
<button
id="agree-btn"
open-type="agreePrivacyAuthorization"
@agreeprivacyauthorization="handleAgreePrivacyAuthorization(0)"
>不同意</button>
<button
id="agree-btn"
open-type="agreePrivacyAuthorization"
@agreeprivacyauthorization="handleAgreePrivacyAuthorization(1)"
>同意</button>
</view>
</template>
<script>
const app = getApp();
import util from '../../../utils/util';
export default {
data() {
return {
privacyContractName: ''
}
},
onShow(){
wx.hideHomeButton();
wx?.getPrivacySetting?.({
success: (res) => {
this.privacyContractName = res?.privacyContractName || '查看隐私协议'
console.log('隐私设置', res)
}
})
},
methods: {
handleAgreePrivacyAuthorization(type){
// app.globalData.resolvePrivacyAuthorization({ buttonId: 'agree-btn', event: 'exposureAuthorization' });
if(type === 1)app?.globalData?.resolvePrivacyAuthorization({ buttonId: 'agree-btn', event: 'agree' });
if(type === 0)app.globalData.resolvePrivacyAuthorization({ buttonId: 'agree-btn', event: 'disagree' });
util.routeTo();
},
openPrivacy(){
//
wx.openPrivacyContract({
success: () => {}, //
fail: () => {}, //
complete: () => {}
})
}
}
}
</script>
<style lang="scss">
.p-text{
margin: 50upx 0;
text-align: center;
color: skyblue;
>text{
text-decoration: underline;
}
}
</style>
Loading…
Cancel
Save