fix(登录协议): 协议勾选改用 change 同步 detail.value,修复微信 H5 无法勾选

避免 click 冒泡/取反与原生 checkbox 状态打架,导致 protocol 被来回拨回。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
吴昊天 2026-10-26 10:22:40 +08:00
parent b780491fe4
commit eaedfdd644
3 changed files with 25 additions and 11 deletions

View File

@ -41,9 +41,11 @@
</view>
</view>
<view class="protocol" v-if="pageType == 0 && !canGetPrivacySetting">
<checkbox-group @click.stop='ChangeIsDefault'>
<checkbox :class="inAnimation?'trembling':''" @animationend='inAnimation=false'
:checked="protocol ? true : false" backgroundColor="#ffffff" activeBackgroundColor="var(--view-theme, #E93323)" activeBorderColor="var(--view-theme, #E93323)" iconColor="#ffffff" /> <text @click.stop='ChangeIsDefault'>{{$t(`已阅读并同意`)}}</text>
<!-- 用 @change 同步勾选,避免微信 H5 下 @click 连点/冒泡导致 protocol 被来回拨回 -->
<checkbox-group @change="ChangeIsDefault">
<checkbox value="1" :class="inAnimation?'trembling':''" @animationend='inAnimation=false'
:checked="protocol" backgroundColor="#ffffff" activeBackgroundColor="var(--view-theme, #E93323)" activeBorderColor="var(--view-theme, #E93323)" iconColor="#ffffff" />
<text @click.stop="toggleProtocol">{{$t(`已阅读并同意`)}}</text>
<text class="main-color" @click.stop="privacy(4)">{{$t(`《用户协议》`)}}</text>
{{$t(`与`)}}<text class="main-color" @click.stop="privacy(3)">{{$t(`《隐私协议》`)}}</text>
</checkbox-group>
@ -315,7 +317,11 @@ async function code() {
verifyRef.value.show();
return;
}
function ChangeIsDefault() {
function ChangeIsDefault(e) {
const values = (e && e.detail && e.detail.value) || [];
protocol.value = values.length > 0;
}
function toggleProtocol() {
protocol.value = !protocol.value;
}
function closeEdit() {

View File

@ -82,12 +82,13 @@
</view>
<!-- #endif -->
<view class="protocol">
<!-- 用 detail.value 同步勾选,避免仅取反与原生勾选状态打架 -->
<checkbox-group @change="ChangeIsDefault">
<checkbox :class="inAnimation ? 'trembling' : ''" @animationend="inAnimation = false" :checked="protocol ? true : false" backgroundColor="#ffffff" activeBackgroundColor="var(--view-theme, #E93323)" activeBorderColor="var(--view-theme, #E93323)" iconColor="#ffffff" />
<checkbox value="1" :class="inAnimation ? 'trembling' : ''" @animationend="inAnimation = false" :checked="protocol" backgroundColor="#ffffff" activeBackgroundColor="var(--view-theme, #E93323)" activeBorderColor="var(--view-theme, #E93323)" iconColor="#ffffff" />
{{ $t(`已阅读并同意`) }}
<text class="main-color" @click="privacy(4)">{{ $t(`《用户协议》`) }}</text>
<text class="main-color" @click.stop="privacy(4)">{{ $t(`《用户协议》`) }}</text>
{{ $t(`与`) }}
<text class="main-color" @click="privacy(3)">{{ $t(`《隐私协议》`) }}</text>
<text class="main-color" @click.stop="privacy(3)">{{ $t(`《隐私协议》`) }}</text>
</checkbox-group>
</view>
</view>
@ -181,7 +182,8 @@ onMounted(() => {
// ---------- methods ----------
function ChangeIsDefault(e) {
protocol.value = !protocol.value;
const values = (e && e.detail && e.detail.value) || [];
protocol.value = values.length > 0;
}
function privacy(type) {
uni.navigateTo({

View File

@ -59,17 +59,19 @@
</view>
</view>
<view class="protocol" v-if="!canGetPrivacySetting">
<checkbox-group @click.stop="ChangeIsDefault">
<!-- 用 @change 同步勾选,避免微信 H5 下 @click 连点/冒泡导致 protocol 被来回拨回 -->
<checkbox-group @change="ChangeIsDefault">
<checkbox
value="1"
:class="inAnimation ? 'trembling' : ''"
@animationend="inAnimation = false"
:checked="protocol ? true : false"
:checked="protocol"
backgroundColor="#ffffff"
activeBackgroundColor="var(--view-theme, #E93323)"
activeBorderColor="var(--view-theme, #E93323)"
iconColor="#ffffff"
/>
<text @click.stop="ChangeIsDefault">{{ $t(`已阅读并同意`) }}</text>
<text @click.stop="toggleProtocol">{{ $t(`已阅读并同意`) }}</text>
<text class="main-color" @click.stop="privacy(4)">{{
$t(`《用户协议》`)
}}</text>
@ -328,6 +330,10 @@ function getAuthLogin() {
});
}
function ChangeIsDefault(e) {
const values = (e && e.detail && e.detail.value) || [];
protocol.value = values.length > 0;
}
function toggleProtocol() {
protocol.value = !protocol.value;
}
function editSuccess() {