合并master

This commit is contained in:
luolei 2014-09-02 21:41:32 +08:00
parent 878a13e5ce
commit 4cb2ea3c5f

View File

@ -3421,7 +3421,14 @@ DOC.addEventListener("mobileSupportInitialized", function() {
var Public = {
init: function() {
console.log('asdf');
window.onbeforeunload = function(){
Client.refreshEnd();
}
window.onunload = function(){
Client.refreshEnd();
}
Public.setHis();
cn12306.getLocalTrainNos();
// 刷新验证码
@ -3465,7 +3472,19 @@ var Public = {
}
}
})
});
$('.loginout').live('click',function(){
var url = $(this).attr('data-url');
// alert(url);
if(Public.isLogin){
cn12306.loginOut(function(){
location.href = url;
})
}else{
location.href = url;
}
});
},
user: '',
isLogin: false,
@ -3476,6 +3495,8 @@ var Public = {
Public.isLogin = true;
$('.loginout').show();
if (sessionStorage.getItem('user')) {
Public.user = sessionStorage.getItem('user');
} else if (localStorage.getItem('useraccount')) {
@ -3495,6 +3516,8 @@ var Public = {
Public.isLogin = false;
$('.loginout').hide();
$('body').addClass('nologin');
$('#login_tip').show();
@ -3504,6 +3527,8 @@ var Public = {
}, function() {
Public.isLogin = false;
$('.loginout').hide();
$('body').addClass('nologin');
$('#login_tip').show();
@ -4478,12 +4503,21 @@ var cn12306 = {
});
},
loginOut: function(success, error) {
var loading = Public.showLoading('正在退出');
bootStrap.post('login/loginOut', 'html', null, 'login/init').done(function() {
loading.html('退出成功');
setTimeout(function(){
Public.hideLoading(loading);
},1000);
if (success) {
sessionStorage.clear();
success();
}
}).fail(function(e) {
loading.html('退出失败');
setTimeout(function(){
Public.hideLoading(loading);
},1000);
if (error) {
error(e);
}
@ -5028,22 +5062,32 @@ var CheckStaion = {
CheckStaion.hotList = WIN["favorite_names"].substr(1).split('@');
},
setHtml: function() {
var html = '<div class="fixed_box" id="search_station"><header class="header"><div class="search_box"><a href="javascript:;" class="search_cancel" id="station_cancel">取消</a><div class="search_ipt"><input type="search" name="" placeholder="搜索北京可以输入bj、beijing、北京" id="station_search" class="search_input" autocomplete="off"><i class="icon_remove_s"></i></div></div></header>';
getHisHmtl : function(){
var his = JSON.parse(localStorage.getItem('stationHis')),
sp = [];
if(!!his && his.length > 0){
html += '<div class="form_title">最近查找</div>'
html += '<div class="box_insert">';
html += '<ul class="station_list">';
for (var i = 0; i < his.length; i++) {
sp = his[i].split('|');
html += '<li><a href="javascript:;" title="'+sp[1]+'" data-code="'+sp[0]+'">'+sp[1]+'</a></li>';
};
html += '</ul></div>';
sp = [],
html = '';
if(!his || his.length == 0){
return '';
}
html += '<div class="form_title"><a href="javascript:;" class="title_right" data-fn="remove_his"><i class="icon_remove_b"></i></a>最近查找</div>'
html += '<div class="box_insert">';
html += '<ul class="station_list">';
for (var i = 0; i < his.length; i++) {
sp = his[i].split('|');
html += '<li><a href="javascript:;" title="'+sp[1]+'" data-code="'+sp[0]+'">'+sp[1]+'</a></li>';
};
html += '</ul></div>';
return html;
},
setHtml: function() {
var html = '<div class="fixed_box" id="search_station"><header class="header"><div class="search_box"><a href="javascript:;" class="search_cancel" id="station_cancel">取消</a><div class="search_ipt"><input type="search" name="" placeholder="搜索车站" id="station_search" class="search_input" autocomplete="off"><i class="icon_remove_s"></i></div></div></header>';
html += '<div id="station_hisbox">';
html += CheckStaion.getHisHmtl();
html += '</div>';
// <li><a href="javascript:;" title="上海" data-code="SHH">上海</a></li>\
// <li><a href="javascript:;" title="天津" data-code="TJP">天津</a></li>\
if (CheckStaion.hotList.length > 0) {
@ -5110,10 +5154,17 @@ var CheckStaion = {
localStorage.setItem('stationHis',JSON.stringify(stationHis));
$('#station_hisbox').html(CheckStaion.getHisHmtl());
$('#station_suggest ul').html('');
$('#station_suggest').hide();
$('#station_search').val('');
});
$('[data-fn="remove_his"]').live('click',function(){
$('#station_hisbox').html('');
localStorage.removeItem('stationHis');
});
},
showSuggest: function(list) {
if (!list || list.length == 0) {
@ -5371,6 +5422,12 @@ var Login = {
}
location.href = 'run_query.html?t='+urlData['t'];
break;
case 'order_list':
location.href = 'order_list.html';
break;
case 'no_commplete':
location.href = 'no_complete_order.html';
break;
}
}
}
@ -5911,7 +5968,7 @@ var RunQuery = {
};
cn12306.queryTicket(data, function(json) {
Public.hideLoading(loading);
Public.hideLoading();
if (json["status"] == true && json["httpstatus"] == 200) {
if (json['data'].length > 0) {
RunQuery.trainData = RunQuery.formatJson(json);
@ -5934,7 +5991,7 @@ var RunQuery = {
}
}, function(xhr, type) {
console.log(xhr, type);
Public.hideLoading(loading);
Public.hideLoading();
});
},
getHtml: function(lists) {
@ -7078,12 +7135,13 @@ var NoComplete = {
bankId: '',
payLoading: null,
curNo: '',
loading:null,
init: function() {
if ($('#no_complete_page').length == 0) {
return false;
}
Public.checkLogin(NoComplete.getOrder);
NoComplete.getToken();
NoComplete.loading = Public.showLoading('正在获取订单信息');
Public.checkLogin(NoComplete.getToken,NoComplete.noLogin,NoComplete.noLogin);
$('[data-no]').live('click', function() {
NoComplete.curNo = $(this).attr('data-no');
@ -7100,14 +7158,32 @@ var NoComplete = {
NoComplete.pay();
});
},
noLogin : function(){
Public.hideLoading();
Public.alert('请先登录', function() {
location.href = "login.html?no_commplete";
});
},
getOrder: function() {
// Referer: https://dynamic.12306.cn/otsweb/loginAction.do?method=init
bootStrap.get("queryOrder/queryMyOrderNoComplete", "json", null, "queryOrder/initNoComplete").done(function(json) {
if (!!json['status'] && !!json['data'] && !!json['data']['orderDBList'] && json['data']['orderDBList'].length > 0) {
Public.hideLoading();
if (!!json['status'] && !!json['data'] && !!json['data']['orderDBList']&&json['data']['orderDBList'].length > 0) {
NoComplete.setHtml(json['data']['orderDBList']);
}else{
if ($('#no_complete_page').length > 0) {
Public.alert('暂无订单,请到我的订单查看已完成订单',function(){
location.href = 'order_list.html';
});
}
}
}).fail(function(xhr, type) {
console.log(xhr, type);
if ($('#no_complete_page').length > 0) {
Public.hideLoading();
Public.alert('查询失败,请重试。',function(){
location.href = location.href;
});
}
});
},
getToken: function() {
@ -7117,7 +7193,9 @@ var NoComplete = {
if (globalRepeatSubmitToken) {
NoComplete.token = globalRepeatSubmitToken;
}
NoComplete.getOrder();
}).fail(function() {
Public.hideLoading();
Public.alert("12306不给力啊唉。出现网络错误了请重试..");
});
},
@ -7128,6 +7206,9 @@ var NoComplete = {
html += '<div class="orders_title">订单号:' + list[i]['sequence_no'] + '</div>';
html += '<div class="order_tickets">';
payLimitTime = new Date(list[i]['tickets'][0]['pay_limit_time'].replace(/\-/gi,'/')).getTime();
if(!isNaN(payLimitTime)){
payLimitTime = new Date(list[i]['order_date'].replace(/\-/gi,'/')).getTime() + 2700000;
}
for (var j = 0; j < list[i]['tickets'].length; j++) {
html += '<div class="ticket">';
html += '<div class="ticket_title"><span class="pull_right">K2341</span>' + (new Date(list[i]['start_train_date_page'].replace(/\-/gi, '/'))).format('yyyy-M-d') + ' ' + (new Date(list[i]['start_train_date_page'].replace(/\-/gi, '/'))).day(3) + '</div>';
@ -7186,7 +7267,7 @@ var NoComplete = {
var $this = $(el),
order = $this.attr('data-orderno'),
time = (new Date(parseInt($this.attr('data-limittime')))).getTime() - (new Date()).getTime();
if (time > 2700000) {
if (time <= 0) {
$this.closest('p').html('订单已过期');
$('[data-no="' + order + '"').html('订单已过期').addClass('btn_gray');
} else {
@ -7272,7 +7353,11 @@ var NoComplete = {
var htmlbank = result.replace(/[\n\t\r]/gi, '').replace(/>\s+</gi, '><').match(/<form.*\/form>/gi);
if (htmlbank.length > 0) {
$('span', NoComplete.payLoading).html('正在向银行提交支付请求');
// console.log(htmlbank[0])
$('#hideHtml').html(htmlbank[0]);
// if(NoComplete.bankId == "03080000"){
// $('form[name="myform"]').attr('action','https://netpay.cmbchina.com/netpayment/BaseHttp.dll?MB_Pay_FromPC');
// }
setTimeout(function() {
$('form[name="myform"]').submit();
}, 1000);
@ -7285,6 +7370,48 @@ var NoComplete = {
}).fail(function() {
Public.alert("12306不给力啊唉。出现网络错误了请重试..");
});
},
cancelOrder:function(order,success,error){
var cancel_loading = Public.showLoading('正在取消订单...'),
data = {
'sequence_no':order,
'cancel_flag':'cancel_order',
'_json_att':''
};
bootStrap.post('queryOrder/cancelNoCompleteMyOrder', 'json', data, "queryOrder/initNoComplete").done(function(json) {
Public.hideLoading(cancel_loading);
if(json['status'] && json['data']['existError'] == "N"){
Public.alert('取消订单成功!',function(){
if(typeof success == "function"){
success();
}
});
}else{
var text = '';
if(json['messages'].length > 0){
text = json['messages'][0];
}
if(!text){
text = '取消订单失败,请重试!';
}
Public.alert(text,function(){
if(typeof error == "function"){
error();
}
});
}
}).fail(function() {
Public.hideLoading(cancel_loading);
Public.alert('网络连接失败,请重试!',function(){
if(typeof error == "function"){
error();
}
});
});
}
}
var Remind = {
@ -7654,6 +7781,7 @@ var MyRemind = {
}
},
error: function() {
$('.list_tip').html('获取信息失败');
Public.alert('获取信息失败');
}
});
@ -8247,7 +8375,7 @@ var bootStrap = (function() {
});
}
headers["Fish-RawUrl"] = url;
url = "/proxy.php";
url = "/12306/proxy.php";
$.ajax({
url: url,
@ -8258,6 +8386,7 @@ var bootStrap = (function() {
refer: refer,
headers: headers
}).done(function(result, xhr) {
console.log(result, xhr)
ad.resolve(result, {
headers: xhr.getAllResponseHeaders(),
statusCode: xhr.statusCode,
@ -8284,7 +8413,7 @@ var bootStrap = (function() {
headers["Origin"] = /(https?:\/\/[^\/]+\/)/.exec(url)[1];
headers["User-Agent"] = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
headers["Referer"] = refer || "";
url = "/proxy.php";
url = "/12306/proxy.php";
xhr.open(method, url, true);
$.each(headers, function(k, v) {
@ -8401,4 +8530,5 @@ bootStrap.done(function() {
NoComplete.init();
MyRemind.init();
Remind.init();
OrderList.init();
});