|
- //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 = '<div class="main_color text_middle white_color ulev2" id="pay" style="padding-top: 0.11rem;padding-bottom: 0.11rem;" onclick="goToPay('+list.order_id+')">去支付</div>';
-
- tempHTML=tempHTML.replace('<div class="replace ui_hide" id="repalace"></div>',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='<div class="ub" id="bookAway"><div class="ub-f1"></div><div style="border: 1px solid #5cc4bb;color: #5cc4bb;border-radius: 0.03rem;padding: 0.06rem 0.27rem;margin-top: 0.07rem;margin-bottom: 0.06rem;" class="ulev1 ui_m_r15" onclick="bookAway()">重新购票</div></div>';
-
- tempHTML=tempHTML.replace('<div class="replace ui_hide" id="repalace"></div>',cstr);
-
- }else{
- var cstr='<div class="ub" id="refund"><div class="ub-f1"></div><div style="border: 1px solid #3d434f;color: #3d434f;border-radius: 0.03rem;padding: 0.06rem 0.27rem;margin-top: 0.07rem;margin-bottom: 0.06rem;" class="ulev1 ui_m_r15" onclick="refundTicket('+list.order_id+')">退票</div></div>';
-
- tempHTML=tempHTML.replace('<div class="replace ui_hide" id="repalace"></div>',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://xmwx.zhizhuchuxing.cn/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;
- }
- }
|