fix: show toast when clicking login without agreeing to privacy terms

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
yuzhiran
2026-06-18 18:54:44 +08:00
parent bed9dce943
commit 7e1bf669ab
+12 -7
View File
@@ -33,7 +33,7 @@
<text class="field-label">密码</text> <text class="field-label">密码</text>
<input class="input" type="password" v-model="password" placeholder="请输入密码" @confirm="doPasswordLogin" /> <input class="input" type="password" v-model="password" placeholder="请输入密码" @confirm="doPasswordLogin" />
</view> </view>
<button class="login-btn" :disabled="!canPasswordLogin || pwdLoading || !agreed" @click="doPasswordLogin"> <button class="login-btn" :disabled="!canPasswordLogin || pwdLoading" @click="doPasswordLogin">
{{ pwdLoading ? '登录中...' : '登录' }} {{ pwdLoading ? '登录中...' : '登录' }}
</button> </button>
<view class="switch-hint" @click="loginMode='code'">忘记密码使用验证码登录</view> <view class="switch-hint" @click="loginMode='code'">忘记密码使用验证码登录</view>
@@ -54,7 +54,7 @@
<text class="field-label">验证码</text> <text class="field-label">验证码</text>
<input class="input" type="number" maxlength="6" v-model="emailCode" placeholder="请输入6位验证码" /> <input class="input" type="number" maxlength="6" v-model="emailCode" placeholder="请输入6位验证码" />
</view> </view>
<button class="login-btn" :disabled="!emailSent || !emailCode || emailLoading || !agreed" @click="doEmailLogin"> <button class="login-btn" :disabled="!emailSent || !emailCode || emailLoading" @click="doEmailLogin">
{{ emailLoading ? '登录中...' : '登录' }} {{ emailLoading ? '登录中...' : '登录' }}
</button> </button>
<view class="switch-hint" @click="loginMode='password'">已有密码使用密码登录</view> <view class="switch-hint" @click="loginMode='password'">已有密码使用密码登录</view>
@@ -77,7 +77,7 @@
<text class="field-label">确认密码</text> <text class="field-label">确认密码</text>
<input class="input" type="password" v-model="confirmPassword" placeholder="再次输入密码" @confirm="doRegister" /> <input class="input" type="password" v-model="confirmPassword" placeholder="再次输入密码" @confirm="doRegister" />
</view> </view>
<button class="login-btn" :disabled="!canRegister || regLoading || !agreed" @click="doRegister"> <button class="login-btn" :disabled="!canRegister || regLoading" @click="doRegister">
{{ regLoading ? '注册中...' : '注册' }} {{ regLoading ? '注册中...' : '注册' }}
</button> </button>
<view class="switch-hint" @click="mainTab='login'">已有账号去登录</view> <view class="switch-hint" @click="mainTab='login'">已有账号去登录</view>
@@ -87,7 +87,7 @@
<view class="card" v-if="mainTab === 'wechat' && isMp"> <view class="card" v-if="mainTab === 'wechat' && isMp">
<text class="card-title">微信一键登录</text> <text class="card-title">微信一键登录</text>
<text class="card-sub">授权后自动创建账号</text> <text class="card-sub">授权后自动创建账号</text>
<button class="login-btn wx-btn" :disabled="wxLoading || !agreed" @click="doWxLogin">{{ wxLoading ? '登录中...' : '微信一键登录' }}</button> <button class="login-btn wx-btn" :disabled="wxLoading" @click="doWxLogin">{{ wxLoading ? '登录中...' : '微信一键登录' }}</button>
</view> </view>
<!-- 法律声明 - 用户自主勾选同意 --> <!-- 法律声明 - 用户自主勾选同意 -->
@@ -156,6 +156,10 @@ onBeforeUnmount(() => { if (timer) { clearTimeout(timer); timer = null } })
// 辅助 // 辅助
const showToast = (title, icon = 'none') => uni.showToast({ title, icon }) const showToast = (title, icon = 'none') => uni.showToast({ title, icon })
const checkAgreed = () => {
if (!agreed.value) { showToast('请阅读并同意《用户服务协议》和《隐私政策》'); return false }
return true
}
const loginSuccess = (data) => { const loginSuccess = (data) => {
uni.setStorageSync('token', data.token) uni.setStorageSync('token', data.token)
if (data.user) uni.setStorageSync('userInfo', JSON.stringify(data.user)) if (data.user) uni.setStorageSync('userInfo', JSON.stringify(data.user))
@@ -165,7 +169,7 @@ const loginSuccess = (data) => {
// ====== 密码登录 ====== // ====== 密码登录 ======
const doPasswordLogin = async () => { const doPasswordLogin = async () => {
if (!canPasswordLogin.value) return if (!canPasswordLogin.value || !checkAgreed()) return
pwdLoading.value = true pwdLoading.value = true
try { try {
const res = await uni.request({ const res = await uni.request({
@@ -227,7 +231,7 @@ const startCooldown = () => {
} }
const doEmailLogin = async () => { const doEmailLogin = async () => {
if (!emailCode.value) return if (!emailCode.value || !checkAgreed()) return
emailLoading.value = true emailLoading.value = true
try { try {
const res = await uni.request({ const res = await uni.request({
@@ -250,7 +254,7 @@ const doEmailLogin = async () => {
// ====== 注册 ====== // ====== 注册 ======
const doRegister = async () => { const doRegister = async () => {
if (!canRegister.value) return if (!canRegister.value || !checkAgreed()) return
regLoading.value = true regLoading.value = true
try { try {
const res = await uni.request({ const res = await uni.request({
@@ -292,6 +296,7 @@ const skipSetPwd = () => { showSetPwd.value = false }
// ====== 微信登录 ====== // ====== 微信登录 ======
const doWxLogin = async () => { const doWxLogin = async () => {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
if (!checkAgreed()) { wxLoading.value = false; return }
wxLoading.value = true wxLoading.value = true
try { try {
const wxResp = await uni.login() const wxResp = await uni.login()