//Author:zhangsq
//Date:20160907
//Description:订单详情、
var order_id = '';
//倒计时
var intDiff = '';
//detail html()
var detailHTML = '';
window.onload = function(){
$("#loadingToast").show();
detailHTML = $('#detail_order').html();
order_id = getPar('order_id');
httpData(order_id);
}
//请求数据
function httpData(order_id){
var url=base_api+"./application/custom_made/control.php";
var parm={
type:"order_orderdetailinfo",
order_id:order_id
}
ZZLog(parm);
$.post(url,parm,function(data){
$("#loadingToast").hide();
data=JSON.parse(data);
ZZLog(data);
if (data.code == 0) {
intDiff = data.go_list.time_left > 0? data.go_list.time_left : 0;
reloadData(data);
}
});
}
//加载数据
function reloadData(data){
var newHTML = '';
var list = data.go_list;
var tempHTML = detailHTML;
tempHTML=tempHTML.replace('[185518]',list.order_id);
tempHTML=tempHTML.replace('[59]',list.total_price);
if (list.order_status == "145") {
$('#title_div_go').removeClass('ui_hide');
timer(intDiff,'minute_show_go','second_show_go');
tempHTML=tempHTML.replace('[待支付]',list.order_status_info);
var cstr = '
去支付
';
tempHTML=tempHTML.replace('',cstr);
}else if (list.order_status == "146") {
tempHTML=tempHTML.replace('[待支付]',list.order_status_info);
if (list.can_do == "0") {
$('#repalace').addClass('ui_hide');
$('#title_div_go').removeClass('ui_hide');
$('#title_content_go').html('订单超时已取消')
var cstr='';
tempHTML=tempHTML.replace('',cstr);
}else{
var cstr='';
tempHTML=tempHTML.replace('',cstr);
}
}else{
tempHTML=tempHTML.replace('[待支付]',list.order_status_info);
$('#repalace').addClass('ui_hide');
}
tempHTML=tempHTML.replace(/\[order_id]/g,list.order_id);
tempHTML=tempHTML.replace('[南京]',list.start_area_name);
tempHTML=tempHTML.replace('[南通]',list.end_area_name);
tempHTML=tempHTML.replace('[出发站点]',list.start_res_name);
tempHTML=tempHTML.replace('[目的站点]',list.end_res_name);
tempHTML=tempHTML.replace('[n]',list.seat_num);
var datestr = list.start_date;
var nowdate = getDateTime(0);
var year = getMonthAndDayByDate(datestr,'year');
var month = getMonthAndDayByDate(datestr,'month');
var day = getMonthAndDayByDate(datestr,'day');
if (datestr == nowdate) {
tempHTML=tempHTML.replace('[8月24日]',month+'月'+day+'日');
$('#todayweek').html('今天');
} else{
tempHTML=tempHTML.replace('[8月24日]',month+'月'+day+'日');
var newdate = year+'/'+month+'/'+day;
var week = getWeekDay(newdate);
$('#todayweek').html(week);
}
tempHTML=tempHTML.replace('[07:45]',list.start_time);
tempHTML=tempHTML.replace('[毛东东]',list.contact_name);
tempHTML=tempHTML.replace('[18621904917]',list.contact_mobile);
newHTML+=tempHTML;
$('#detail_order').html(newHTML);
$('#detail_order').removeClass('ui_hide');
if (datestr == nowdate) {
$('#todayweek').html('今天');
} else{
var newdate = year+'/'+month+'/'+day;
var week = getWeekDay(newdate);
$('#todayweek').html(week);
}
}
//倒计时
function timer(intDiff,minstr,secstr){
window.setInterval(function(){
var day=0,
hour=0,
minute=0,
second=0;//时间默认值
if(intDiff > 0){
day = Math.floor(intDiff / (60 * 60 * 24));
hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
$('#'+minstr).html(minute+'分');
$('#'+secstr).html(second+'秒');
intDiff--;
}, 1000);
}
//重新预订
function bookAway(){
window.location.href = './index.html';
}
//支付
function goToPay(order_id){
var minute = $('#minute_show_go').html();;
var second = $('#second_show_go').html();
if (minute == '00分' && second == '00秒') {
alert('支付已超时,请重新购票!');
return false;
}else{
window.location.href = 'http://wx.zhizhuchuxing.com/wechat/WxPay/realpay/onlinePay.php?orderid='+order_id+'&fx=11&code2=dzbs';
}
}
//退票
function refundTicket(order_id){
var r=confirm("确定要退票吗?");
if (r==true){
$("#loadingToast").show();
$.ajax({
url:base_api+'application/custom_made/control.php', //请求地址
type: "post",
data:{
type:"order_refund",
order_id:order_id
},//请求方式
async:false,
dataType: "json",
success: function (data) {
console.log(data);
if(data.code == 0){
$("#loadingToast").hide();
alert('退票成功!');
window.location.href = "./order_list.html";
}else{
$("#loadingToast").hide();
alert(data.info);
}
}
});
}
else{
return;
}
}