var Register = function () { this.Startup = function () { this.InitOrgList(); //$('#select').on('click', this.OnSelectChange.bind(this)); $('#register-button').on('click', this.OnRegisterButtonClick.bind(this)); }; this.InitOrgList = function () { $.ajax({ type: "POST", dataType: 'text', url: '/OrgManagement/Query', data: { page: 1, rows: 10000 }, success: function (result) { $('#org-list').combobox({ valueField: 'Id', textField: 'Name', editable: false, panelHeight: 'auto', data: JSON.parse(result).rows }); }.bind(this) }); }; this.OnRegisterButtonClick = function () { this.validation(); }; this.validation = function () { if ($("#username").val().trim() === '' || $("#username").val().trim === null) { alert('请输入用户名'); return } else if ($('#org-list').combobox('getValue') === '') { alert('请选择机构'); return; } else if ($("#login-account").val().trim() === '' || $("#login-account").val().trim === null) { alert('请输入登录账户'); return } else if ($("#password").val().trim() === '' || $("#password").val().trim === null) { alert('请输入密码'); return } else if ($("#password").val().length < 6) { alert('密码长度至少为6位'); return } else { this.RegisterUser(); } }; this.RegisterUser = function () { $.ajax({ type: "POST", dataType: 'text', url: '/UserManagement/Add', data: { OrgId: $('#org-list').combobox('getValue'), //Gender: parseInt($('#add-dialog-sex-select span.active').attr('gender')), RealName: $("#username").val().trim(), LoginName: $("#login-account").val().trim(), LoginPassword: $("#password").val().trim() }, success: function () { alert('注册成功,即将跳转到登录页。'); window.location.href = '/User/Login'; }.bind(this) }); }; }; $(document).ready(function () { var register = new Register(); register.Startup(); });