2014-09-01 13:50:43 +08:00
|
|
|
|
var NoComplete = {
|
|
|
|
|
token: '',
|
|
|
|
|
bankId: '',
|
|
|
|
|
payLoading: null,
|
|
|
|
|
curNo: '',
|
2014-09-02 19:09:24 +08:00
|
|
|
|
loading:null,
|
2014-09-01 13:50:43 +08:00
|
|
|
|
init: function() {
|
|
|
|
|
if ($('#no_complete_page').length == 0) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2014-09-04 17:11:16 +08:00
|
|
|
|
|
|
|
|
|
$('#menu_btn').on('click', function() {
|
2014-09-05 15:19:17 +08:00
|
|
|
|
|
|
|
|
|
var _height;
|
|
|
|
|
|
2014-09-04 17:11:16 +08:00
|
|
|
|
$('#user_menu').toggle();
|
2014-09-05 15:19:17 +08:00
|
|
|
|
if($(window).height() > $('body').height()){
|
|
|
|
|
_height = $(window).height();
|
|
|
|
|
}else{
|
|
|
|
|
_height = $('body').height();
|
|
|
|
|
}
|
|
|
|
|
$('#user_menu').height(_height - 45);
|
2014-09-04 17:11:16 +08:00
|
|
|
|
});
|
|
|
|
|
$('#user_menu').on('click', function(e) {
|
|
|
|
|
if ($(e.target).attr('id') == 'user_menu') {
|
|
|
|
|
$('#user_menu').hide();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#remind_btn').on('click',function(e){
|
|
|
|
|
var url = 'remind.html?',
|
|
|
|
|
from = $('#startStationCode').val(),
|
|
|
|
|
to = $('#endStationCode').val(),
|
|
|
|
|
date = $('#start_date_val').val();
|
|
|
|
|
// url += 'date='+date;
|
|
|
|
|
if(!!from){
|
|
|
|
|
url += '&from='+from;
|
|
|
|
|
}
|
|
|
|
|
if(!!to){
|
|
|
|
|
url += '&to='+to;
|
|
|
|
|
}
|
|
|
|
|
location.href = url;
|
|
|
|
|
});
|
|
|
|
|
|
2014-09-02 19:09:24 +08:00
|
|
|
|
NoComplete.loading = Public.showLoading('正在获取订单信息');
|
|
|
|
|
Public.checkLogin(NoComplete.getToken,NoComplete.noLogin,NoComplete.noLogin);
|
2014-09-01 13:50:43 +08:00
|
|
|
|
|
|
|
|
|
$('[data-no]').live('click', function() {
|
|
|
|
|
NoComplete.curNo = $(this).attr('data-no');
|
|
|
|
|
NoComplete.selectBank();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('[data-fn="close_bank"]').live('click', function() {
|
|
|
|
|
Public.hideInnerPage();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$('#banks [data-bank]').live('click', function() {
|
|
|
|
|
NoComplete.bankId = $(this).attr('data-bank');
|
|
|
|
|
NoComplete.payLoading = Public.showLoading('正在加载');
|
|
|
|
|
NoComplete.pay();
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-02 19:09:24 +08:00
|
|
|
|
noLogin : function(){
|
|
|
|
|
Public.hideLoading();
|
|
|
|
|
Public.alert('请先登录', function() {
|
|
|
|
|
location.href = "login.html?no_commplete";
|
|
|
|
|
});
|
|
|
|
|
},
|
2014-09-04 17:18:45 +08:00
|
|
|
|
loadNum : 0,
|
2014-09-01 13:50:43 +08:00
|
|
|
|
getOrder: function() {
|
2014-09-04 17:18:45 +08:00
|
|
|
|
NoComplete.loadNum++;
|
2014-09-01 13:50:43 +08:00
|
|
|
|
// Referer: https://dynamic.12306.cn/otsweb/loginAction.do?method=init
|
|
|
|
|
bootStrap.get("queryOrder/queryMyOrderNoComplete", "json", null, "queryOrder/initNoComplete").done(function(json) {
|
2014-09-02 19:09:24 +08:00
|
|
|
|
Public.hideLoading();
|
2014-09-02 22:52:30 +08:00
|
|
|
|
if (!!json['status'] && !!json['data']) {
|
|
|
|
|
if(!!json['data']['orderDBList'] && json['data']['orderDBList'].length > 0){
|
|
|
|
|
NoComplete.setHtml(json['data']['orderDBList']);
|
|
|
|
|
}else if(json['data']['orderCacheDTO']){
|
|
|
|
|
// $('#orders').html('<div class="list_tip text_sm">'+ json['data']['orderCacheDTO']['message']['message'] +'</div>');
|
|
|
|
|
var html = '';
|
|
|
|
|
// html += '<div class="orders_title"> </div>';
|
|
|
|
|
// html += '<div class="order_tickets">';
|
|
|
|
|
// html += '<div class="ticket">';
|
|
|
|
|
// html += '<p> </p>';
|
|
|
|
|
// html += '<p><strong class="text_error text_lg">哎呀,出票失败了!</strong></p>';
|
|
|
|
|
// html += '<p> </p>';
|
|
|
|
|
// html += '<p>'+ json['data']['orderCacheDTO']['message']['message'] +'</p>';
|
|
|
|
|
// html += '</div>';
|
|
|
|
|
// html += '</div>';
|
|
|
|
|
// html += '</div>';
|
|
|
|
|
html += '<ul class="order_list"><li><div class="order_info">'
|
|
|
|
|
html += '<div class="order_ticket text_error">哎呀,出票失败了!</div>'
|
|
|
|
|
html += '<p>'+ json['data']['orderCacheDTO']['message']['message'] +'</p>';
|
|
|
|
|
html += '</div></li></ul>';
|
|
|
|
|
|
|
|
|
|
$('#orders').html(html);
|
|
|
|
|
}
|
2014-09-02 19:09:24 +08:00
|
|
|
|
}else{
|
2014-09-04 17:18:45 +08:00
|
|
|
|
|
2014-09-02 19:09:24 +08:00
|
|
|
|
if ($('#no_complete_page').length > 0) {
|
2014-09-04 17:18:45 +08:00
|
|
|
|
if(NoComplete.loadNum < 2){
|
|
|
|
|
Public.showLoading('正在获取订单信息');
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
NoComplete.getOrder();
|
|
|
|
|
},5000);
|
|
|
|
|
}else{
|
|
|
|
|
Public.alert('暂无订单,请到我的订单查看已完成订单',function(){
|
|
|
|
|
location.href = 'order_list.html';
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-09-02 19:09:24 +08:00
|
|
|
|
}
|
2014-09-01 13:50:43 +08:00
|
|
|
|
}
|
|
|
|
|
}).fail(function(xhr, type) {
|
2014-09-02 19:09:24 +08:00
|
|
|
|
if ($('#no_complete_page').length > 0) {
|
|
|
|
|
Public.hideLoading();
|
|
|
|
|
Public.alert('查询失败,请重试。',function(){
|
|
|
|
|
location.href = location.href;
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-09-01 13:50:43 +08:00
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
getToken: function() {
|
|
|
|
|
bootStrap.post('queryOrder/initNoComplete', 'html', null, "payOrder/init").done(function(json) {
|
|
|
|
|
var token = json.match(/\S+\s+globalRepeatSubmitToken\s+=\s+\S+/)[0];
|
|
|
|
|
eval(json.match(/\S+\s+globalRepeatSubmitToken\s+=\s+\S+/)[0]);
|
|
|
|
|
if (globalRepeatSubmitToken) {
|
|
|
|
|
NoComplete.token = globalRepeatSubmitToken;
|
|
|
|
|
}
|
2014-09-02 19:09:24 +08:00
|
|
|
|
NoComplete.getOrder();
|
2014-09-01 13:50:43 +08:00
|
|
|
|
}).fail(function() {
|
2014-09-02 19:09:24 +08:00
|
|
|
|
Public.hideLoading();
|
2014-09-01 13:50:43 +08:00
|
|
|
|
Public.alert("12306不给力啊,唉。出现网络错误了,请重试..");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
setHtml: function(list) {
|
|
|
|
|
var html = "",
|
|
|
|
|
payLimitTime = 0;
|
|
|
|
|
for (var i = 0, len = list.length; i < len; i++) {
|
|
|
|
|
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();
|
2014-09-02 19:09:24 +08:00
|
|
|
|
if(!isNaN(payLimitTime)){
|
|
|
|
|
payLimitTime = new Date(list[i]['order_date'].replace(/\-/gi,'/')).getTime() + 2700000;
|
|
|
|
|
}
|
2014-09-01 13:50:43 +08:00
|
|
|
|
for (var j = 0; j < list[i]['tickets'].length; j++) {
|
|
|
|
|
html += '<div class="ticket">';
|
2014-09-04 22:34:02 +08:00
|
|
|
|
html += '<div class="ticket_title"><span class="pull_right">' + list[i]['train_code_page'] + '</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>';
|
2014-09-01 13:50:43 +08:00
|
|
|
|
html += '<div class="stations_info">';
|
|
|
|
|
html += '<div class="station_info"><strong>' + list[i]['from_station_name_page'][0] + '</strong>' + list[i]['start_time_page'] + '</div>';
|
|
|
|
|
html += '<div class="station_info"><strong>' + list[i]['to_station_name_page'][0] + '</strong>' + list[i]['arrive_time_page'] + '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="ticket_passenger">';
|
|
|
|
|
html += '<strong class="text_lg">' + list[i]['tickets'][j]['passengerDTO']['passenger_name'] + '</strong>';
|
|
|
|
|
html += '<span class="text_gray">' + list[i]['tickets'][j]['passengerDTO']['passenger_id_no'] + '</span>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="ticket_info"><span class="pull_right">' + list[i]['tickets'][j]['str_ticket_price_page'] + '元</span>';
|
|
|
|
|
html += list[i]['tickets'][j]['ticket_type_name'];
|
|
|
|
|
html += ' ' + list[i]['tickets'][j]['seat_type_name'];
|
|
|
|
|
html += ' ' + list[i]['tickets'][j]['coach_name'] + '车';
|
|
|
|
|
html += list[i]['tickets'][j]['seat_name'];
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
// html += '<p>' + list[i]['tickets'][j]['passengerDTO']['passenger_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['ticket_type_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['seat_type_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['seat_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['str_ticket_price_page'] + '</p>';
|
|
|
|
|
// html += '<p><a href="javascript:;" data-no="' + list[i]['sequence_no'] + '">支付</a></p>'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
html += '</div>';
|
|
|
|
|
html += '<div class="order_pay_info">';
|
2014-09-04 21:48:13 +08:00
|
|
|
|
html += '<p>席位已成功锁定,请你在<strong class="pay_time" data-limittime="' + payLimitTime + '" data-orderno="' + list[i]['sequence_no'] + '"></strong>内进行网上支付,否则席位将自动释放给其他旅客。</p>';
|
2014-09-01 13:50:43 +08:00
|
|
|
|
html += '<div class="pay_info clearfix"><a href="javascript:;" class="btn btn_success pull_right" data-no="' + list[i]['sequence_no'] + '">立即支付</a><span class="pay_money">' + list[i]['ticket_total_price_page'] + '元</span></div>'
|
|
|
|
|
html += '</div>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// html += '<p>订单日期:' + list[i]['order_date'] + '</p>';
|
|
|
|
|
// html += '<p>发车时间:' + list[i]['start_train_date_page'] + '</p>';
|
|
|
|
|
// html += '<p>车次:' + list[i]['train_code_page'] + '</p>';
|
|
|
|
|
// html += '<p>发到站:' + list[i]['from_station_name_page'][0] + ' dao ' + list[i]['to_station_name_page'][0] + '</p>';
|
|
|
|
|
// html += '<p>金额:' + list[i]['ticket_total_price_page'] + '</p>';
|
|
|
|
|
|
|
|
|
|
// for (var j = 0; j < list[i]['tickets'].length; j++) {
|
|
|
|
|
// html += '<p>' + list[i]['tickets'][j]['passengerDTO']['passenger_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['ticket_type_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['seat_type_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['seat_name'] +
|
|
|
|
|
// ' ' + list[i]['tickets'][j]['str_ticket_price_page'] + '</p>';
|
|
|
|
|
// html += '<p><a href="javascript:;" data-no="' + list[i]['sequence_no'] + '">支付</a></p>'
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
$('#orders').html(html);
|
|
|
|
|
NoComplete.countdown();
|
|
|
|
|
},
|
|
|
|
|
countdown: function() {
|
|
|
|
|
$('[data-limittime]').each(function(idx, el) {
|
|
|
|
|
var $this = $(el),
|
|
|
|
|
order = $this.attr('data-orderno'),
|
|
|
|
|
time = (new Date(parseInt($this.attr('data-limittime')))).getTime() - (new Date()).getTime();
|
2014-09-02 19:09:24 +08:00
|
|
|
|
if (time <= 0) {
|
2014-09-01 13:50:43 +08:00
|
|
|
|
$this.closest('p').html('订单已过期');
|
|
|
|
|
$('[data-no="' + order + '"').html('订单已过期').addClass('btn_gray');
|
|
|
|
|
} else {
|
|
|
|
|
$this.html(NoComplete.gm(time));
|
2014-09-01 18:09:58 +08:00
|
|
|
|
$('.pay_tip_info .text_warning').html(NoComplete.gm(time));
|
2014-09-01 13:50:43 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
setTimeout(NoComplete.countdown, 1000);
|
|
|
|
|
},
|
|
|
|
|
gm: function(n) {
|
|
|
|
|
var m = parseInt(n / 60000),
|
|
|
|
|
s = parseInt(n % 60000 / 1000);
|
|
|
|
|
if (m < 10) {
|
|
|
|
|
m = '0' + m;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (s < 10) {
|
|
|
|
|
s = '0' + s;
|
|
|
|
|
}
|
|
|
|
|
return m + ':' + s;
|
|
|
|
|
},
|
|
|
|
|
selectBank: function() {
|
|
|
|
|
// $('#banks').show();
|
|
|
|
|
Public.showInnerPage('banks');
|
|
|
|
|
},
|
|
|
|
|
pay: function(no, type) {
|
|
|
|
|
|
|
|
|
|
var data = {
|
|
|
|
|
"sequence_no": NoComplete.curNo,
|
|
|
|
|
"pay_flag": 'pay',
|
|
|
|
|
"_json_att": "",
|
|
|
|
|
"REPEAT_SUBMIT_TOKEN": NoComplete.token
|
|
|
|
|
}
|
|
|
|
|
$('span', NoComplete.payLoading).html('正在获取支付信息');
|
|
|
|
|
bootStrap.post('queryOrder/continuePayNoCompleteMyOrder', 'json', data, "queryOrder/initNoComplete").done(function(response) {
|
|
|
|
|
if (response.status) {
|
|
|
|
|
if (response.data.existError == "Y") {
|
|
|
|
|
Public.alert(response.data.errorMsg);
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
bootStrap.post('payOrder/paycheck', 'json', {
|
|
|
|
|
"_json_att": ""
|
|
|
|
|
}, "payOrder/init").done(function(json) {
|
|
|
|
|
NoComplete.submitPay(json['data']['payForm']);
|
|
|
|
|
|
|
|
|
|
}).fail(function() {
|
|
|
|
|
Public.alert("12306不给力啊,唉。出现网络错误了,请重试..");
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}).fail(function() {
|
|
|
|
|
Public.alert("12306不给力啊,唉。出现网络错误了,请重试..");
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
analyzeFormData: function(text) {
|
|
|
|
|
var data = {};
|
|
|
|
|
var reg = /<input[\s\w\W]*?(name|value)="([\s\w\W]*?)"[\s\w\W]*?(name|value)=['"]([\s\w\W]*?)['"][\s\w\W]*?\/?>/g;
|
|
|
|
|
var m = null;
|
|
|
|
|
while ((m = reg.exec(text)) != null) {
|
|
|
|
|
if (m[1] == "name")
|
|
|
|
|
data[m[2]] = m[4];
|
|
|
|
|
else
|
|
|
|
|
data[m[4]] = m[2];
|
|
|
|
|
}
|
|
|
|
|
return data;
|
|
|
|
|
},
|
|
|
|
|
submitPay: function(formdata) {
|
|
|
|
|
var data = {
|
|
|
|
|
"_json_att": '',
|
|
|
|
|
"interfaceName": formdata['interfaceName'],
|
|
|
|
|
"interfaceVersion": formdata['interfaceVersion'],
|
|
|
|
|
"tranData": formdata["tranData"],
|
|
|
|
|
"merSignMsg": formdata["merSignMsg"],
|
|
|
|
|
"appId": formdata['appId'],
|
|
|
|
|
"transType": formdata['transType']
|
|
|
|
|
}
|
|
|
|
|
$('span', NoComplete.payLoading).html('正在提交支付请求');
|
|
|
|
|
bootStrap.post('https://epay.12306.cn/pay/payGateway', 'html', data, "payOrder/init").done(function(html) {
|
|
|
|
|
var data = NoComplete.analyzeFormData(html);
|
|
|
|
|
data.bankId = NoComplete.bankId;
|
|
|
|
|
bootStrap.post('https://epay.12306.cn/pay/webBusiness', 'html', data, "https://epay.12306.cn/pay/payGateway").done(function(result) {
|
|
|
|
|
var formdata = NoComplete.analyzeFormData(result);
|
|
|
|
|
var htmlbank = result.replace(/[\n\t\r]/gi, '').replace(/>\s+</gi, '><').match(/<form.*\/form>/gi);
|
|
|
|
|
if (htmlbank.length > 0) {
|
|
|
|
|
$('span', NoComplete.payLoading).html('正在向银行提交支付请求');
|
|
|
|
|
$('#hideHtml').html(htmlbank[0]);
|
2014-09-02 19:09:24 +08:00
|
|
|
|
// if(NoComplete.bankId == "03080000"){
|
|
|
|
|
// $('form[name="myform"]').attr('action','https://netpay.cmbchina.com/netpayment/BaseHttp.dll?MB_Pay_FromPC');
|
|
|
|
|
// }
|
2014-09-01 13:50:43 +08:00
|
|
|
|
setTimeout(function() {
|
2014-09-03 19:25:32 +08:00
|
|
|
|
Public.hideLoading(NoComplete.payLoading);
|
2014-09-01 13:50:43 +08:00
|
|
|
|
$('form[name="myform"]').submit();
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
}).fail(function() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}).fail(function() {
|
|
|
|
|
Public.alert("12306不给力啊,唉。出现网络错误了,请重试..");
|
|
|
|
|
});
|
2014-09-02 19:09:24 +08:00
|
|
|
|
},
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
2014-09-01 13:50:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|