登录添加隐私协议弹窗

This commit is contained in:
zhouyanli
2026-06-18 16:40:19 +08:00
parent 9bcbfa8ec5
commit 3bd7809c25
5 changed files with 219 additions and 23 deletions

View File

@@ -67,10 +67,14 @@
<uni-icons type="checkbox" size="24" color="#999" v-else></uni-icons>
</view>
<text class="agreement-text" @click.stop="goToPrivacy"
<!-- <text class="agreement-text" @click.stop="goToPrivacy"
>我已阅读并同意
<text class="agreePrivacy">《用户隐私政策》</text>
</text>
</text> -->
<text class="agreement-text" >我已阅读并同意
<text class="agreePrivacy" @click.stop="">《用户协议》</text>和
<text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text>
</text>
</view>
<!-- 登录按钮 -->
@@ -81,12 +85,16 @@
<navigator class="link-item" url="/pageSubPack/loginSub/pwd-login">账号密码登录</navigator>
<!-- <navigator class="link-item" url="/pageSubPack/loginSub/register-new-user">注册新用户</navigator> -->
</view>
<!-- 隐私协议弹窗 -->
<privacy-popup v-model:show="showPrivacyPopup" @agree="agreePrivacy" @disagree="disagreePrivacy" />
</view>
</template>
<script setup>
import { ref, computed, onUnmounted } from 'vue'
import { getLoginBySms, getSendCode } from '../../api/api.js'
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
// ========== 响应式数据 ==========
// 手机号
@@ -96,6 +104,7 @@ const verifyCode = ref('')
const placeholderStyle = ref('font-size:24rpx')
// 是否同意协议
const agreeAgreement = ref(false) // 默认勾选
const showPrivacyPopup = ref(false)
// 倒计时(秒)
const countDown = ref(0)
// 定时器
@@ -130,13 +139,16 @@ const checkForm = () => {
const toggleAgreement = () => {
agreeAgreement.value = !agreeAgreement.value
}
// 跳转隐私协议
// 打开隐私协议弹窗
const goToPrivacy = () => {
// 点击变色
// isClicked.value = true
uni.navigateTo({
url: '/pageSubPack/loginSub/privacy'
})
showPrivacyPopup.value = true
}
// 不同意隐私协议
const disagreePrivacy = () => {
agreeAgreement.value = false
showPrivacyPopup.value = false
}
// 获取验证码
@@ -201,7 +213,7 @@ const handleLogin = () => {
return
}
if (!agreeAgreement.value) {
uni.showToast({ title: '请勾选协议', icon: 'none' })
showPrivacyPopup.value = true
return
}
uni.showLoading({
@@ -260,6 +272,13 @@ const handleLogin = () => {
})
}
// 同意隐私协议(弹窗中点击同意 → 直接登录)
const agreePrivacy = () => {
agreeAgreement.value = true
showPrivacyPopup.value = false
handleLogin()
}
// ========== 生命周期 ==========
// 页面卸载时清除定时器
onUnmounted(() => {

View File

@@ -45,9 +45,10 @@
<uni-icons type="checkbox-filled" size="24" color="#4D5DFA" v-if="agreeAgreement"></uni-icons>
<uni-icons type="checkbox" size="24" color="#999" v-else></uni-icons>
</view>
<text class="agreement-text" @click.stop="goToPrivacy">我已阅读并同意
<text class="agreePrivacy">《用户隐私政策》</text>
</text>
<text class="agreement-text" >我已阅读并同意
<text class="agreePrivacy" @click.stop="">《用户协议》</text>和
<text class="agreePrivacy" @click.stop="goToPrivacy">《隐私政策》</text>
</text>
</view>
<navigator class="forget-pwd" url="/pageSubPack/loginSub/forget-pwd">忘记密码?</navigator>
</view>
@@ -63,6 +64,8 @@
<!-- <navigator class="link-item" url="/pageSubPack/loginSub/register-new-user">注册新用户</navigator> -->
</view>
</view>
<!-- 隐私协议弹窗 -->
<privacy-popup v-model:show="showPrivacyPopup" @agree="agreePrivacy" @disagree="disagreePrivacy" @close="showPrivacyPopup = false" />
</template>
<script setup>
@@ -76,6 +79,7 @@
import {
getLoginPassword
} from '../../api/api.js'
import PrivacyPopup from '@/components/privacy-popup/privacy-popup.vue'
// 响应式数据
const phoneNumber = ref('');
@@ -83,6 +87,7 @@
const agreeAgreement = ref(false); // 默认勾选
const rememberPwd = ref(false);
const placeholderStyle = ref('font-size:24rpx')
const showPrivacyPopup = ref(false)
// 控制点击变色
// const isClicked = ref(false)
@@ -101,13 +106,16 @@
const toggleRemember = () => {
rememberPwd.value = !rememberPwd.value;
};
// 跳转隐私协议
// 打开隐私协议弹窗
const goToPrivacy = () => {
showPrivacyPopup.value = true
}
// isClicked.value = true
uni.navigateTo({
url:'/pageSubPack/loginSub/privacy',
})
// 不同意隐私协议
const disagreePrivacy = () => {
agreeAgreement.value = false
showPrivacyPopup.value = false
}
// 检查表单
@@ -146,7 +154,7 @@
return;
}
if(!agreeAgreement.value){
uni.showToast({ title: '请勾选协议', icon: 'none' });
showPrivacyPopup.value = true;
return;
}
uni.showLoading({ title: '登录中...', mask: true });
@@ -198,6 +206,13 @@
};
// 同意隐私协议(弹窗中点击同意 → 直接登录)
const agreePrivacy = () => {
agreeAgreement.value = true
showPrivacyPopup.value = false
handleLogin()
}
</script>
<style scoped>
@@ -292,12 +307,15 @@
.agreement-item {
display: flex;
align-items: center;
flex: 1;
min-width: 0;
}
.agreement-text {
font-size: 24rpx;
color: #666;
margin-left: 10rpx;
line-height: 1.5;
}
.agreePrivacy{
color: #4D5DFA;
@@ -310,6 +328,9 @@
font-size: 24rpx;
color: #666;
text-decoration: none;
flex-shrink: 0;
margin-left: 16rpx;
line-height: 1.5;
}
.login-btn {