diff --git a/miniapp/pages/profile/edit.vue b/miniapp/pages/profile/edit.vue index 626b83c..b2cfdcd 100644 --- a/miniapp/pages/profile/edit.vue +++ b/miniapp/pages/profile/edit.vue @@ -104,8 +104,9 @@ @@ -1119,12 +1120,28 @@ const handleExpectMarryChange = (e) => { } const handleSurnameBlur = () => { + // 姓氏超过2个字时截断 + if (formData.surname.length > 2) { + formData.surname = formData.surname.slice(0, 2) + } // 姓氏输入完成后触发昵称生成 if (formData.relationship && formData.surname) { formData.nickname = generateNickname(formData.relationship, formData.surname, formData.childGender || 1) } } +/** + * 姓氏输入事件 - 在中文输入法确认后限制长度 + * iOS中文输入法拼音组合阶段不截断,只在确认汉字后检查 + */ +const handleSurnameInput = (e) => { + const value = e.detail.value || '' + // 只在确认的文字超过2个字符时截断 + if (value.length > 2) { + formData.surname = value.slice(0, 2) + } +} + // 择偶要求处理 const handleAgeMinChange = (e) => { const val = ageRangeOptions.value[e.detail.value]