diff --git a/zhiyin-app/src/pages/login/login.vue b/zhiyin-app/src/pages/login/login.vue index bcea2b6..7862dfc 100644 --- a/zhiyin-app/src/pages/login/login.vue +++ b/zhiyin-app/src/pages/login/login.vue @@ -33,7 +33,7 @@ 密码 - + {{ pwdLoading ? '登录中...' : '登录' }} 忘记密码?使用验证码登录 @@ -54,7 +54,7 @@ 验证码 - + {{ emailLoading ? '登录中...' : '登录' }} 已有密码?使用密码登录 @@ -77,7 +77,7 @@ 确认密码 - + {{ regLoading ? '注册中...' : '注册' }} 已有账号?去登录 @@ -87,7 +87,7 @@ 微信一键登录 授权后自动创建账号 - {{ wxLoading ? '登录中...' : '微信一键登录' }} + {{ wxLoading ? '登录中...' : '微信一键登录' }} @@ -156,6 +156,10 @@ onBeforeUnmount(() => { if (timer) { clearTimeout(timer); timer = null } }) // 辅助 const showToast = (title, icon = 'none') => uni.showToast({ title, icon }) +const checkAgreed = () => { + if (!agreed.value) { showToast('请阅读并同意《用户服务协议》和《隐私政策》'); return false } + return true +} const loginSuccess = (data) => { uni.setStorageSync('token', data.token) if (data.user) uni.setStorageSync('userInfo', JSON.stringify(data.user)) @@ -165,7 +169,7 @@ const loginSuccess = (data) => { // ====== 密码登录 ====== const doPasswordLogin = async () => { - if (!canPasswordLogin.value) return + if (!canPasswordLogin.value || !checkAgreed()) return pwdLoading.value = true try { const res = await uni.request({ @@ -227,7 +231,7 @@ const startCooldown = () => { } const doEmailLogin = async () => { - if (!emailCode.value) return + if (!emailCode.value || !checkAgreed()) return emailLoading.value = true try { const res = await uni.request({ @@ -250,7 +254,7 @@ const doEmailLogin = async () => { // ====== 注册 ====== const doRegister = async () => { - if (!canRegister.value) return + if (!canRegister.value || !checkAgreed()) return regLoading.value = true try { const res = await uni.request({ @@ -292,6 +296,7 @@ const skipSetPwd = () => { showSetPwd.value = false } // ====== 微信登录 ====== const doWxLogin = async () => { // #ifdef MP-WEIXIN + if (!checkAgreed()) { wxLoading.value = false; return } wxLoading.value = true try { const wxResp = await uni.login()