From 7200ee43a09f2d567ac5e119b238ad7539559bcd Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 28 May 2026 14:10:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=8B=E6=9C=BA=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E7=A0=81gen=5Fcode=E6=8C=89=E9=92=AE=E7=94=A8datawidget/datame?= =?UTF-8?q?thod=E4=BC=A0=E8=A1=A8=E5=8D=95=E5=80=BC=E7=BB=99script?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 原script中this.getValue()在toolbar tool事件上下文中拿不到表单数据, 改用datawidget/datamethod机制将表单值通过params传入script。 回写codeid用.bind(this)保持Form引用。 --- wwwroot/user/login.ui | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wwwroot/user/login.ui b/wwwroot/user/login.ui index 3a5c1f2..53accfb 100644 --- a/wwwroot/user/login.ui +++ b/wwwroot/user/login.ui @@ -89,8 +89,10 @@ "wid": "self", "event": "gen_code", "actiontype": "script", + "datawidget": "self", + "datamethod": "getValue", "target": "self", - "script": "var form=this;var vals=form.getValue();if(!vals.cell_no){alert('请输入手机号');return;}fetch(form.app.baseUrl+'/rbac/gen_sms_code.dspy?cellphone='+encodeURIComponent(vals.cell_no)).then(function(r){return r.json()}).then(function(d){if(d.status==='ok'){form.setValue({codeid:d.data.key});alert('验证码已发送')}else{alert(d.data.message)}}).catch(function(e){alert('发送失败:'+e)})" + "script": "var cell=params.cell_no;if(!cell){alert('请输入手机号');return;}fetch(bricks.app.baseUrl+'/rbac/gen_sms_code.dspy?cellphone='+encodeURIComponent(cell)).then(function(r){return r.json()}).then(function(d){if(d.status==='ok'){this.setValue({codeid:d.data.key});alert('验证码已发送')}else{alert(d.data.message)}}.bind(this)).catch(function(e){alert('发送失败:'+e)})" }, { "wid": "self",