From e0f201f15cd9ca317714fd6bf6c386ceffb2a722 Mon Sep 17 00:00:00 2001 From: 17792275749 <812100002@qq.com> Date: Wed, 2 Sep 2026 19:44:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(supplementPersonal):=20=E8=BA=AB=E9=AB=98?= =?UTF-8?q?=E4=BD=93=E9=87=8D=E8=8C=83=E5=9B=B4=E6=A0=A1=E9=AA=8C=E5=B9=B6?= =?UTF-8?q?=E5=A4=B1=E7=84=A6=E6=B8=85=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.7 --- .../supplementPersonal/supplementPersonal.ts | 30 +++++++++++++++++-- .../supplementPersonal.wxml | 6 ++-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/miniprogram/pages/supplementPersonal/supplementPersonal.ts b/miniprogram/pages/supplementPersonal/supplementPersonal.ts index 9312de9..628fc8e 100644 --- a/miniprogram/pages/supplementPersonal/supplementPersonal.ts +++ b/miniprogram/pages/supplementPersonal/supplementPersonal.ts @@ -123,6 +123,28 @@ Page({ this.setData({ weight: e.detail.value }) }, + /** 身高失焦校验:不在 50-250 则清空 */ + onHeightBlur() { + const height = this.data.height.trim() + if (!height) return + const h = parseFloat(height) + if (isNaN(h) || h < 50 || h > 250) { + wx.showToast({ title: '身高需在50-250cm之间', icon: 'none' }) + this.setData({ height: '' }) + } + }, + + /** 体重失焦校验:不在 20-300 则清空 */ + onWeightBlur() { + const weight = this.data.weight.trim() + if (!weight) return + const w = parseFloat(weight) + if (isNaN(w) || w < 20 || w > 300) { + wx.showToast({ title: '体重需在20-300kg之间', icon: 'none' }) + this.setData({ weight: '' }) + } + }, + async onSubmit() { const { name, idCard, height, weight } = this.data const heightNum = parseFloat(height) @@ -136,8 +158,12 @@ Page({ wx.showToast({ title: '请填写正确的身份证号', icon: 'none' }) return } - if (!height || isNaN(heightNum) || heightNum <= 0) { - wx.showToast({ title: '请填写身高', icon: 'none' }) + if (!height || isNaN(heightNum) || heightNum < 50 || heightNum > 250) { + wx.showToast({ title: '身高需在50-250cm之间', icon: 'none' }) + return + } + if (weight && (isNaN(weightNum) || weightNum < 20 || weightNum > 300)) { + wx.showToast({ title: '体重需在20-300kg之间', icon: 'none' }) return } diff --git a/miniprogram/pages/supplementPersonal/supplementPersonal.wxml b/miniprogram/pages/supplementPersonal/supplementPersonal.wxml index 8bde356..5a793bd 100644 --- a/miniprogram/pages/supplementPersonal/supplementPersonal.wxml +++ b/miniprogram/pages/supplementPersonal/supplementPersonal.wxml @@ -80,7 +80,8 @@ placeholder-class="form-placeholder" value="{{ height }}" disabled="{{ readonly }}" - bind:input="onHeightInput" /> + bind:input="onHeightInput" + bind:blur="onHeightBlur" /> cm @@ -99,7 +100,8 @@ placeholder-class="form-placeholder" value="{{ weight }}" disabled="{{ readonly }}" - bind:input="onWeightInput" /> + bind:input="onWeightInput" + bind:blur="onWeightBlur" /> kg