1,在manifest.json文件中的mp-weixin 節(jié)點下,添加:"__usePrivacyCheck__": true
2,在需要的頁面配置隱私保護彈窗,或者直接寫到首頁也可以
<uni-popup ref="popusAuthorization" type="center" :maskClick="false">
<view class="contentview">
<view class="title">隱私保護指引</view>
<view class="des" @click="openPrivacyContract">
在使用當(dāng)前小程序服務(wù)之前,請仔細閱讀<text style="color: #07c160;">{{privacyContractName}}</text>。如你同意{{privacyContractName}},請點擊“同意”開始使用。
</view>
<view class="btns">
<button class="item reject" @click="exitMiniProgram">拒絕</button>
<button id="agree-btn" class="item agree" open-type="agreePrivacyAuthorization"
@agreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
</view>
</view>
</uni-popup>
在下方data中定義:privacyContractName:''
3,在頁面的onLoad中,添加查詢是否需要授權(quán)的檢測(小程序中用即可,其他端不需要)
// #ifdef MP-WEIXIN
wx.getPrivacySetting({
success: res => {
console.log("是否需要授權(quán):", res.needAuthorization, "隱私協(xié)議的名稱為:", res.privacyContractName)
if (res.needAuthorization) {
this.privacyContractName = res.privacyContractName;
this.$refs.popusAuthorization.open();
}文章來源地址http://www.zghlxwxcb.cn/news/detail-701592.html
},
fail: () => {},
complete: () => {},
})
// #endif
4,然后在methods中添加對應(yīng)的方法
// 打開隱私協(xié)議頁面
openPrivacyContract() {
let that = this;
wx.openPrivacyContract({
fail: () => {
that.$queue.showToast('遇到錯誤無法打開!');
}
})
},
// 拒絕隱私協(xié)議
exitMiniProgram() {
// 直接退出小程序
wx.exitMiniProgram()
},
// 同意隱私協(xié)議
handleAgreePrivacyAuthorization() {
this.$refs.popusAuthorization.close();
},
下方是彈框的樣式,有需要直接拷貝即可
.privacy {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0, 0, 0, .5);
z-index: 9999999;
display: flex;
align-items: center;
justify-content: center;
}
.contentview {
width: 632rpx;
padding: 48rpx;
box-sizing: border-box;
background: #fff;
border-radius: 16rpx;
}
.contentview .title {
text-align: center;
color: #333;
font-weight: bold;
font-size: 32rpx;
}
.contentview .des {
font-size: 26rpx;
color: #666;
margin-top: 40rpx;
text-align: justify;
line-height: 1.6;
}
.contentview .des .link {
color: #07c160;
text-decoration: underline;
}
button::after {
border: none;
}
.btns {
margin-top: 48rpx;
display: flex;
}
.btns .item {
justify-content: space-between;
width: 244rpx;
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
border-radius: 16rpx;
box-sizing: border-box;
border: none;
}
.btns .reject {
background: #f4f4f5;
color: #909399;
}
.btns .agree {
background: #07c160;
color: #fff;文章來源:http://www.zghlxwxcb.cn/news/detail-701592.html
}
若出現(xiàn)確認隱私后無法登錄情況,請使用微信開發(fā)者工具推送低版本調(diào)試基礎(chǔ)庫降低到2.32.3以下?
到了這里,關(guān)于uniapp 微信小程序最新隱私彈窗更新方案,更新后無法登錄問題解決方案的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!