微信小程序获取隐私授权一直显示false

提示:反复摸索


前言

查询了众多资料文档,都是说的

  • 在 2023年9月15号之前,在 app.json 中配置 __usePrivacyCheck__: true 后,会启用隐私相关功能,如果不配置或者配置为 false 则不会启用。

  • 在 2023年9月15号之后,不论 app.json 中是否有配置 __usePrivacyCheck__,隐私相关功能都会启用。


我这都是2024年了啊,我查了我用的基础库是3.5.3

在mainfest.json里面也添加了__usePrivacyCheck__: true

但是在调用时候一直返回false

wx.getPrivacySetting({
		      success(res) {
		       // console.log('是否需要授权:', res.needAuthorization, '隐私协议的名称为:', res.privacyContractName);
		       if (res.needAuthorization) {
		        that.privacyVisible = true;
				that.$refs.showPrivacy.init()
		       } else {
		        that.privacyVisible = false;
		       }
		      }
		     });

一、益得助手

 

二、使用步骤

着急啊,没有隐私指引,审核不过啊

通过微信开发工具查看app.json

没有 __usePrivacyCheck__: true

没有怎么办,那就手工添加一个吧,

添加后再次尝试,运行前先把缓存清理一下

哎~~~

可以了

益得助手的隐私弹窗能够弹出来了

运用的组件

showPrivacyAgreement.vue

<template>
	<uni-popup ref="privacyPopup" type="center" :is-mask-click="false">
		<view class="privacyPopup">
			<view class="title">
				<!-- <view class="title_circle"></view> -->
				<view>益得助手</view>
			</view>
			<view class="content_pri">
				<text>在你使用【益得助手】服务之前,请仔细阅读</text>
				<text style="color: #1793ee;" @click="goToPrivacy">《益得助手小程序隐私保护指引》</text>。
				<text>如你同意益得助手小程序隐私保护指引,请点击“同意”开始使用【益得助手】。</text>
			</view>
			<view class="pri_btn">
				<button class="confuse_btn" @click="confusePrivacy">拒绝</button>
				<button class="confirm_btn" id="agree-btn" open-type="agreePrivacyAuthorization" @agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
			</view>
		</view>
	</uni-popup>
</template>
<script>
	export default {
		data(){
			return{
				
			}
		},
		methods:{
			init(resolve){
				this.$refs.privacyPopup.open()
				this.resolvePrivacyAuthorization = resolve
			},
			// 打开隐私协议
			goToPrivacy(){
				wx.openPrivacyContract({
				  success: () => {
						console.log('打开成功');
					}, // 打开成功
				  fail: () => {
						uni.showToast({
							title:'打开失败,稍后重试',
							icon: 'none'
						})
					} // 打开失败
				})
			},
			// 拒绝
			confusePrivacy(){
				const that = this;
				uni.showModal({
					content: '如果拒绝,我们将无法获取您的信息, 包括手机号、位置信息、相册等该小程序十分重要的功能,您确定要拒绝吗?',
					success: res => {
					if (res.confirm) {
						that.$emit('disagree')
						that.showPrivacy = false;
						uni.navigateBack({
							delta: 1
						})
						// uni.exitMiniProgram({
						// 	success: () => {
						// 		console.log('退出小程序成功');
						// 	}
						// });
					}
					}
							});
				// this.$refs.privacyPopup.close()
				// this.resolvePrivacyAuthorization({ event:'disagree' })
				
			},
			// 同意
			handleAgreePrivacyAuthorization(){
				const that = this;
				// 告知平台用户已经同意,参数传同意按钮的id
				wx.requirePrivacyAuthorize({
					success: res => {
						that.$emit('agree')
						that.$refs.privacyPopup.close()
					},
					fail: () => {console.log("111")}, // 用户拒绝授权
					complete: () => {console.log("2222")}
							});
				// this.resolvePrivacyAuthorization({ buttonId: 'agree-btn', event: 'agree' })
				
			}
		}
	}
</script>
<style>
	*{
		box-sizing: border-box;
	}
	.privacyPopup{
		width: 520rpx;
		/* height: 500rpx; */
		background-color: #fff;
		border-radius: 50rpx;
		padding: 20rpx 40rpx;
	}
	.title{
		display: flex;
		align-items: center;
		justify-content: start;
		margin: 20rpx 0;
		font-size: 38rpx;
		font-weight: 600;
	}
	.title .title_circle{
		width: 60rpx;
		height: 60rpx;
		background-color: #efefef;
		border-radius: 50%;
		margin-right: 20rpx;
	}
	.content_pri{
		width: 480rpx;
		margin: 0 auto;
		font-size: 34rpx;
		line-height: 1.5;
	}
	.pri_btn{
		width: 100%;
		height: 158rpx;
		display: flex;
		align-items: center;
		justify-content: space-evenly;
	}
	.pri_btn .confuse_btn,.pri_btn .confirm_btn{
		width: 200rpx;
		height: 90rpx;
		border-radius: 20rpx;
		font-size: 34rpx;
	}
	.pri_btn .confuse_btn{
		background-color: #eee;
		color: #52bf6b;
	}
	.pri_btn .confirm_btn{
		background-color: #52bf6b;
		color: #fff;
	}
</style>

页面使用

<template>
<view>	
<showPrivacyAgreement ref="showPrivacy" v-if="privacyVisible"></showPrivacyAgreement>
  </view>
</template>
import showPrivacyAgreement from '@/components/showPrivacyAgreement.vue'
  export default {
	components:{showPrivacyAgreement},
 onLoad() {
	  const that = this;
	   wx.getPrivacySetting({
	    success(res) {
	     // console.log('是否需要授权:', res.needAuthorization, '隐私协议的名称为:', res.privacyContractName);
	     if (res.needAuthorization) {
	      that.privacyVisible = true;
	  	setTimeout(()=>{
	  		that.$refs.showPrivacy.init()
	  	},50)
	     } else {
	      that.privacyVisible = false;
	     }
	    }
	   });
    },

总结

点击蓝色链接能正常跳转到小程序审核的隐私文档

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

益得助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值