vesh-cli
Version:
码农村nodejs版本VESH框架脚手架搭建器
163 lines (158 loc) • 6.51 kB
JavaScript
(function(V, W, $) {
V.registScript('../../Part/home/login.css', function(path, vm) {
var _ = this,
__ = {}; {
V.inherit.apply(_, [W.Control, [path || '../../Part/home/login.htm', vm || {
data: {}
}]]);
__.onLoad = _.onLoad;
__.render = _.render;
}
_.onLoad = function(node) {
V.forC(_.events, function(k, v) {
switch (k.toLowerCase()) {
case "save":
break;
default:
_.bindEvent(_.node, k, v);
break;
}
}, function() {
__.onLoad(node);
});
_.imgCode = _.node.find("#imgCode");
_.name = _.node.find('#name');
_.code = _.node.find('#code');
_.pwd = _.node.find('#pwd');
_.imgCode.attr('src', '../../Module/admin/GetCheckCode.x?_=' + V.random());
_.submit = _.node.find('#submit');
_.cancel = _.node.find('#cancel');
// _.nameInfo = _.node.find('#nameInfo');
// _.pwdInfo = _.node.find('#pwdInfo');
_.codeInfo = _.node.find('#codeInfo');
_.name.on('focus', function() {
// _.codeInfo.html('*限6-16个字符,支持中英文、数字、减号、下划线')
_.codeInfo.html('');
})
// _.name.on('blur', function() {
// var _this = $(this),
// val = _this.val();
// if ($.trim(val) != '') {
// var reg = /^[a-zA-Z0-9_-]{6,16}$/;
// val = $.trim(val);
// reg.test(val) ? null : _.codeInfo.html('*用户名格式不匹配,请重新输入');
// } else {
// _.codeInfo.html('用户名必填');
// }
// })
_.pwd.on('focus', function() {
_.codeInfo.html('');
})
// _.pwd.on('blur', function() {
// var _this = $(this),
// val = _this.val();
// if ($.trim(val) != '') {
// var reg = /^(\w){6,20}$/;
// val = $.trim(val);
// reg.test(val) ? null : _.codeInfo.html('*密码格式不匹配,请重新输入');
// } else {
// _.codeInfo.html('密码必填');
// }
// })
_.code.on('focus', function() {
_.codeInfo.html('');
});
_.code.on('keyup', function(e) {
if ((e.keyCode || e.charCode || e.which) == 13)
_.submit.trigger('click');
})
// _.code.on('blur', function() {
// var _this = $(this);
// val = _this.val();
// $.trim(val) == '' ? _.codeInfo.html('验证码必填') : null;
// })
_.imgCode.on('click', function() {
var _this = $(this);
_this.attr('src', '../../Module/admin/GetCheckCode.x?_=' + V.random());
})
_.submit.on('click', function() {
var name = $.trim(_.name.val()),
pwd = $.trim(_.pwd.val()),
code = $.trim(_.code.val());
if (name == '') {
_.codeInfo.html('用户名不能为空');
return;
}
if (!(/^[a-zA-Z0-9_-]{6,16}$/).test(name)) {
_.codeInfo.html('用户名不匹配,限6-16个字符,支持中英文、数字、减号、下划线');
return;
}
if (pwd == '') {
_.codeInfo.html('密码不能为空');
return;
}
if (!(/^(\w){6,20}$/).test(pwd)) {
_.codeInfo.html('密码格式不匹配,支持6-20 位,字母、数字、下划线');
return;
}
if (code == '') {
_.codeInfo.html('验证码不能为空');
return;
}
_.ni.excute('template', 'home.login', {
name: name,
pwd: pwd,
code: code
}, function(res) {
var ret = res.last()[0][0];
// console.log('111111111111', ret.menu)
// 成功
if (ret["success"] == '0') {
_.call('login', {
value: {
isSuccess: true,
menu: ret.menu
}
})
return;
}
if (ret['success'] != '0') {
_.call('login', {
value: {
isSuccess: false,
menu: ''
}
})
_.imgCode.attr('src', '../../Module/admin/GetCheckCode.x?_=' + V.random());
var status = ret['success'];
switch (status) {
case '10004':
_.codeInfo.html('用户名或者密码错误');
break;
case '10001':
_.codeInfo.html('验证码错误');
break;
}
}
})
})
_.cancel.on('click', function() {
_.name.val('');
_.pwd.val('');
_.code.val('');
_.codeInfo.html('');
})
};
_.render = function(data) {
data = __.render(data);
V.forC(data, function(k, v) {
switch (k.toLowerCase()) {
case 'active':
break;
case 'title':
break;
}
});
};
});
})(VJ, VJ.view, jQuery);