提交 | 用户 | 时间
|
58d006
|
1 |
//author: neeler date: 151218 |
A |
2 |
|
|
3 |
/**********TEST DATA START**********************************/ |
|
4 |
// var data_ = Mock.mock("", {}) |
|
5 |
// var data_ntypeahead = Mock.mock("/admin/admincon/login.htm", {code: 0, errmsg: "用户名或密码错误!"}) |
|
6 |
/**********TEST DATA END************************************/ |
|
7 |
|
|
8 |
window.I = { |
|
9 |
un: $("#username"), |
|
10 |
pw: $("#password"), |
|
11 |
c: $("#code"), |
|
12 |
e: $("#err"), |
|
13 |
l: $("#login"), |
|
14 |
ric: $("#reICode"), |
|
15 |
ci: $("#codeImg"), |
|
16 |
err: { |
|
17 |
unerr: "用户名为空", |
|
18 |
pwerr: "密码为空", |
|
19 |
cerr: "验证码为空" |
|
20 |
}, |
|
21 |
isPosting: false |
|
22 |
} |
|
23 |
|
|
24 |
$(function(){ |
|
25 |
I.un.focus(); |
|
26 |
if(self != top){ |
|
27 |
parent.window.location.replace(window.location.href); |
|
28 |
} |
|
29 |
autoHeight(); |
|
30 |
setErr(); |
|
31 |
pageInit(); |
|
32 |
}); |
|
33 |
|
|
34 |
function pageInit(){ |
|
35 |
I.un.keydown(function(event) { |
|
36 |
if (event.keyCode == 13){ |
|
37 |
if (!isNull($(this))) { |
|
38 |
I.e.empty(); |
|
39 |
I.pw.focus(); |
|
40 |
} |
|
41 |
} |
|
42 |
}); |
|
43 |
I.pw.keydown(function(event) { |
|
44 |
if (event.keyCode == 13){ |
|
45 |
if (!isNull($(this))) { |
|
46 |
I.e.empty(); |
|
47 |
login(); |
|
48 |
// I.c.focus(); |
|
49 |
} |
|
50 |
} |
|
51 |
}); |
|
52 |
I.c.keydown(function(event) { |
|
53 |
if (event.keyCode == 13){ |
|
54 |
login(); |
|
55 |
} |
|
56 |
}); |
|
57 |
I.l.click(function(event){ |
|
58 |
login(); |
|
59 |
}) |
|
60 |
I.ric.click(function(event) { |
|
61 |
I.ci.attr("src", "/kaptcha/kaptcha/kaptcha.ktc?tttiid=" + Math.random()); |
|
62 |
}); |
|
63 |
} |
|
64 |
|
|
65 |
//登录 |
|
66 |
function login() { |
|
67 |
if (I.isPosting) { |
|
68 |
return; |
|
69 |
} |
|
70 |
if (!(isNull(I.un) || isNull(I.pw)||isNull(I.c) )) {//|| isNull(I.c) |
|
71 |
I.e.empty(); |
|
72 |
var o = {}; |
|
73 |
o.username = I.un.val(); |
|
74 |
o.password = I.pw.val(); |
|
75 |
o.valicode = I.c.val(); |
|
76 |
// console.log(o); |
|
77 |
I.isPosting = true; |
|
78 |
$.post("/system/login.htm", o, function(data, textStatus, xhr) { |
|
79 |
I.isPosting = false; |
|
80 |
if (data.code >= 1) { |
|
81 |
I.ci.attr("src", "/kaptcha/kaptcha/kaptcha.ktc?tttiid=" + Math.random()); |
|
82 |
I.e.text(data.errmsg); |
|
83 |
} |
|
84 |
if (data.code == 0) { |
|
85 |
window.open(data.bb != null && data.bb !== "" ? data.bb : "/index.jsf", "_self"); |
|
86 |
} |
|
87 |
}, "json"); |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
//验证 |
|
92 |
function isNull(jObj) { |
|
93 |
var v = $.trim(jObj.val()); |
|
94 |
var b = (v == "" || v == null) ? true : false; |
|
95 |
if (b) { |
|
96 |
jObj.focus(); |
|
97 |
I.e.text(jObj.err).show(); |
|
98 |
} |
|
99 |
return b; |
|
100 |
} |
|
101 |
|
|
102 |
//设置错误信息 |
|
103 |
function setErr(){ |
|
104 |
I.un.err = I.err.unerr; |
|
105 |
I.pw.err = I.err.pwerr; |
|
106 |
I.c.err = I.err.cerr; |
|
107 |
} |
|
108 |
|
|
109 |
function autoHeight() { |
|
110 |
var height = $(window).height(); |
|
111 |
$('.bg').css('min-height', height - 185); |
|
112 |
$('.xbga img').css('margin-top', (height - 330) / 2 - 200); |
|
113 |
$('.contbox').css('margin-top', (height - 330) / 2 - 230); |
|
114 |
$('.n-dcode').css('left', $(window).width() * 0.1 - 60); |
|
115 |
} |