var page = "https://dynamic.12306.cn/otsweb/loginAction.do?method=init";
var url = "https://dynamic.12306.cn/otsweb/loginAction.do?method=login";
var queryurl = "https://dynamic.12306.cn/otsweb/order/querySingleAction.do?method=init";
function submitForm() {
var _ifrMain = document.getElementById('main');
var userName = _ifrMain.contentWindow.document.getElementById('UserName');
var password = _ifrMain.contentWindow.document.getElementById('password');
var randCode = _ifrMain.contentWindow.document.getElementById('randCode');
var submitUrl = url;
$.ajax({
type: "POST",
url: submitUrl,
data: {
"loginUser.user_name": userName.value
, "user.password": password.value
, "randCode": randCode.value
},
timeout: 30000,
success: function (msg) {
if (msg.indexOf('请输入正确的验证码') > -1) {
alert('请输入正确的验证码!');
};
if (msg.indexOf('当前访问用户过多') > -1) {
reLogin('回调结果:当前访问用户过多');
}
else {
location.replace(queryurl);
};
},
error: function (msg) {
reLogin('回调结果:错误');
},
beforeSend: function (XHR) {
;
}
});
}
var count = 1;
function reLogin(msg) {
count++;
skm_LockScreen("(" + count + ")次登录中..." + msg);
setTimeout(submitForm, 500);
}
function skm_LockScreen(str) {
scroll(0, 0);
var back = document.getElementById('skm_LockBackground');
var pane = document.getElementById('skm_LockPane');
var text = document.getElementById('skm_LockPaneText');
var LockBackgroundCssString = "position: absolute;top: 0px;left: 0px;visibility: visible;display: block;width: 105%;height: 105%;background-color: #666;z-index: 999;filter: alpha(opacity=75);opacity:0.75;padding-top: 20%;";
var LockPaneCssString = "z-index: 1000;position: absolute;top: 0px;left: 0px;padding-top: 25%;visibility: visible;display: block;text-align: center;width: 100%;";
var textCssString = "width: 55%;background-color: #969;color: White;font-size: large;border: dotted 1px White;padding: 9px;margin-left: auto;margin-right: auto;";
if (back)
back.style.cssText = LockBackgroundCssString;
if (pane)
pane.style.cssText = LockPaneCssString;
if (text) {
text.innerHTML = str;
text.style.cssText = textCssString;
}
}
var loginoutElement = document.getElementById('login_out');
loginoutElement.innerHTML = "<div id='skm_LockBackground' style='display: none;visibility: hidden;position: absolute;top: -100px;left: -100px;'></div><div id='skm_LockPane' style='display: none;visibility: hidden;position: absolute;top: -100px;left: -100px;'><div id='skm_LockPaneText'> </div></div>";
submitForm();