diff --git a/wwwroot/user/login.ui b/wwwroot/user/login.ui index 53accfb..1b169c1 100644 --- a/wwwroot/user/login.ui +++ b/wwwroot/user/login.ui @@ -55,54 +55,59 @@ "name": "checkcode", "label": "手机验证码", "content": { - "widgettype": "Form", - "options": { - "description": "限中国国内手机", - "fields": [ - { - "name": "cell_no", - "label": "手机号", - "uitype": "str" + "widgettype": "VBox", + "subwidgets": [ + { + "widgettype": "Form", + "id": "phone_form", + "options": { + "description": "限中国国内手机", + "fields": [ + { + "name": "cell_no", + "label": "手机号", + "uitype": "str" + }, + { + "name": "codeid", + "uitype": "hide", + "value": "" + }, + { + "name": "check_code", + "label": "验证码", + "uitype": "str" + } + ] }, - { - "name": "codeid", - "uitype": "hide", - "value": "" - }, - { - "name": "check_code", - "label": "验证码", - "uitype": "str" - } - ], - "toolbar": { - "tools": [ + "binds": [ { - "name": "gen_code", - "label": "发送验证码" + "wid": "self", + "event": "submit", + "actiontype": "urlwidget", + "target": "self", + "options": { + "method": "POST", + "url": "{{entire_url('code_login.dspy')}}" + } } ] - } - }, - "binds": [ - { - "wid": "self", - "event": "gen_code", - "actiontype": "script", - "datawidget": "self", - "datamethod": "getValue", - "target": "self", - "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", - "event": "submit", - "actiontype": "urlwidget", - "target": "self", + "widgettype": "Button", + "id": "gen_code_btn", "options": { - "method": "POST", - "url": "{{entire_url('code_login.dspy')}}" - } + "label": "发送验证码" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "script", + "target": "self", + "script": "var form=bricks.getWidgetById('phone_form',bricks.app);if(!form){alert('form not found');return;}var vals=form.getValue();var cell=vals.cell_no;if(!cell){alert('请输入手机号');return;}this.options.label='发送中...';this.el&&(this.el.disabled=true);fetch(bricks.app.baseUrl+'/rbac/gen_sms_code.dspy?_webbricks_=1&cellphone='+encodeURIComponent(cell)).then(function(r){return r.json()}).then(function(d){var btn=bricks.getWidgetById('gen_code_btn',bricks.app);if(d.status==='ok'){form.setValue({codeid:d.data.key});if(btn){btn.options.label='已发送';btn.el&&(btn.el.disabled=false)}}else{alert(d.data.message);if(btn){btn.options.label='发送验证码';btn.el&&(btn.el.disabled=false)}}}).catch(function(e){alert('发送失败:'+e);var btn=bricks.getWidgetById('gen_code_btn',bricks.app);if(btn){btn.options.label='发送验证码';btn.el&&(btn.el.disabled=false)}})" + } + ] } ] }