微信最新更新隐私策略(2023-08-15)

1、manifest.json 配置修改

在mp-weixin: 参数修改(没有就添加)

"__usePrivacyCheck__": true,

***2、注意 微信开发者工具调整

不然一直报错 找不到 getPrivacySetting

废话不多说 上代码

3、 编辑首页 或者用户授权界面

<uni-popup ref="popup">
			<view class="popupWrap">
				<view class="popupTxt">
					在你使用【********】之前,请仔细阅读<text class="blueColor" @click="handleOpenPrivacyContract">《隐私保护指引》</text>。如你同意《******隐私保护指引》,请点击“同意”开始使用【******】。
				</view>
				<view class="popupBot">
					<button id="disagree-btn" type="default" @click="handleDisagree">拒绝</button>
					<button id="agree-btn" type="primary" open-type="agreePrivacyAuthorization" @agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
				</view>
			</view>
</uni-popup>
// onload 代码
// #ifdef MP
		wx.getPrivacySetting({
			success: res => {
			  console.log("是否需要授权:",res, res.needAuthorization, "隐私协议的名称为:", res.privacyContractName)
			   //如果需要授权的话 显示弹窗
			  if(res.needAuthorization){
			this.$refs.popup.open('center') 
			  }
			},
			fail: () => {},
			complete: () => {},
	})
// #endif
methods: {
		// 用户隐私
		handleDisagree(e) {
			  this.$refs.popup.close()
		  },
		handleAgreePrivacyAuthorization(res) {
			  // 用户同意隐私协议事件回调
			  // 用户点击了同意,之后所有已声明过的隐私接口和组件都可以调用了
			  this.$refs.popup.close()
			  console.log(res,"handleAgreePrivacyAuthorization");
			},
		handleOpenPrivacyContract(){
			// 打开隐私协议页面
			wx.openPrivacyContract({
				success: () => {}, // 打开成功
				fail: () => {}, // 打开失败
				complete: (res) => {
					console.log(res,"openPrivacyContract complete");
				}
			})
		},
		// end用户隐私
}

css

.popupWrap{
		  width: 540rpx;
	  	box-sizing: border-box;
	  	padding:42rpx;
	  	background:white;
	  	border-radius: 30rpx;
		.blueColor{
			color: rgba(39, 152, 240, 1);
		}
		.popupTxt{
			line-height: 48rpx;
		}
	  	.popupBot{
	  		display: flex;
			justify-content: space-around;
			align-items: center;
			margin-top: 30rpx;
	  	}
	}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值