feat(miniapp): add privacy consent and legal pages

Show privacy popup on launch, gate login on legal consent, and link
user agreement and privacy policy pages in the mini program.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-07-12 12:18:54 +08:00
parent 8928827291
commit 048f25f580
29 changed files with 817 additions and 8 deletions
+45
View File
@@ -0,0 +1,45 @@
const { openPrivacyContract } = require('../../utils/privacy');
Component({
data: {
show: false,
privacyContractName: '《用户隐私保护指引》',
},
lifetimes: {
attached() {
if (typeof wx.onNeedPrivacyAuthorization !== 'function') {
return;
}
wx.onNeedPrivacyAuthorization((resolve) => {
this._privacyResolve = resolve;
this.setData({ show: true });
});
},
},
methods: {
openPrivacyContract() {
openPrivacyContract();
},
handleDisagree() {
this.setData({ show: false });
if (this._privacyResolve) {
this._privacyResolve({ event: 'disagree' });
this._privacyResolve = null;
}
},
handleAgree() {
this.setData({ show: false });
if (this._privacyResolve) {
this._privacyResolve({
buttonId: 'agree-privacy-btn',
event: 'agree',
});
this._privacyResolve = null;
}
},
},
});
@@ -0,0 +1,4 @@
{
"component": true,
"usingComponents": {}
}
@@ -0,0 +1,21 @@
<view wx:if="{{show}}" class="privacy-mask">
<view class="privacy-panel">
<text class="privacy-title">用户隐私保护提示</text>
<view class="privacy-body">
<text>在使用 TKMind 前,请阅读</text>
<text class="privacy-link" bindtap="openPrivacyContract">{{privacyContractName}}</text>
<text>。点击「同意」即表示你已阅读并同意该指引。</text>
</view>
<view class="privacy-actions">
<button class="privacy-decline" bindtap="handleDisagree">拒绝</button>
<button
id="agree-privacy-btn"
class="privacy-accept"
open-type="agreePrivacyAuthorization"
bindagreeprivacyauthorization="handleAgree"
>
同意
</button>
</view>
</view>
</view>
@@ -0,0 +1,65 @@
.privacy-mask {
position: fixed;
inset: 0;
z-index: 2000;
display: flex;
align-items: center;
justify-content: center;
padding: 40rpx;
background: rgba(15, 23, 42, 0.55);
box-sizing: border-box;
}
.privacy-panel {
width: 100%;
max-width: 640rpx;
padding: 36rpx;
border-radius: 16rpx;
background: #ffffff;
box-shadow: 0 10rpx 30rpx rgba(15, 23, 42, 0.12);
}
.privacy-title {
display: block;
font-size: 34rpx;
font-weight: 800;
color: #101820;
}
.privacy-body {
margin-top: 24rpx;
font-size: 26rpx;
color: #334155;
line-height: 1.8;
}
.privacy-link {
color: #0f766e;
font-weight: 600;
}
.privacy-actions {
display: flex;
gap: 16rpx;
margin-top: 32rpx;
}
.privacy-decline,
.privacy-accept {
flex: 1;
height: 80rpx;
border-radius: 12rpx;
font-size: 28rpx;
font-weight: 700;
line-height: 80rpx;
}
.privacy-decline {
background: #f1f5f9;
color: #475569;
}
.privacy-accept {
background: #0f766e;
color: #ffffff;
}