Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 
 

182 linhas
5.6 KiB

  1. //Author:zhangsq
  2. //Date:20160907
  3. //Description:订单详情、
  4. var order_id = '';
  5. //倒计时
  6. var intDiff = '';
  7. //detail html()
  8. var detailHTML = '';
  9. window.onload = function(){
  10. $("#loadingToast").show();
  11. detailHTML = $('#detail_order').html();
  12. order_id = getPar('order_id');
  13. httpData(order_id);
  14. }
  15. //请求数据
  16. function httpData(order_id){
  17. var url=base_api+"./application/custom_made/control.php";
  18. var parm={
  19. type:"order_orderdetailinfo",
  20. order_id:order_id
  21. }
  22. ZZLog(parm);
  23. $.post(url,parm,function(data){
  24. $("#loadingToast").hide();
  25. data=JSON.parse(data);
  26. ZZLog(data);
  27. if (data.code == 0) {
  28. intDiff = data.go_list.time_left > 0? data.go_list.time_left : 0;
  29. reloadData(data);
  30. }
  31. });
  32. }
  33. //加载数据
  34. function reloadData(data){
  35. var newHTML = '';
  36. var list = data.go_list;
  37. var tempHTML = detailHTML;
  38. tempHTML=tempHTML.replace('[185518]',list.order_id);
  39. tempHTML=tempHTML.replace('[59]',list.total_price);
  40. if (list.order_status == "145") {
  41. $('#title_div_go').removeClass('ui_hide');
  42. timer(intDiff,'minute_show_go','second_show_go');
  43. tempHTML=tempHTML.replace('[待支付]',list.order_status_info);
  44. 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>';
  45. tempHTML=tempHTML.replace('<div class="replace ui_hide" id="repalace"></div>',cstr);
  46. }else if (list.order_status == "146") {
  47. tempHTML=tempHTML.replace('[待支付]',list.order_status_info);
  48. if (list.can_do == "0") {
  49. $('#repalace').addClass('ui_hide');
  50. $('#title_div_go').removeClass('ui_hide');
  51. $('#title_content_go').html('订单超时已取消')
  52. 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>';
  53. tempHTML=tempHTML.replace('<div class="replace ui_hide" id="repalace"></div>',cstr);
  54. }else{
  55. 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>';
  56. tempHTML=tempHTML.replace('<div class="replace ui_hide" id="repalace"></div>',cstr);
  57. }
  58. }else{
  59. tempHTML=tempHTML.replace('[待支付]',list.order_status_info);
  60. $('#repalace').addClass('ui_hide');
  61. }
  62. tempHTML=tempHTML.replace(/\[order_id]/g,list.order_id);
  63. tempHTML=tempHTML.replace('[南京]',list.start_area_name);
  64. tempHTML=tempHTML.replace('[南通]',list.end_area_name);
  65. tempHTML=tempHTML.replace('[出发站点]',list.start_res_name);
  66. tempHTML=tempHTML.replace('[目的站点]',list.end_res_name);
  67. tempHTML=tempHTML.replace('[n]',list.seat_num);
  68. var datestr = list.start_date;
  69. var nowdate = getDateTime(0);
  70. var year = getMonthAndDayByDate(datestr,'year');
  71. var month = getMonthAndDayByDate(datestr,'month');
  72. var day = getMonthAndDayByDate(datestr,'day');
  73. if (datestr == nowdate) {
  74. tempHTML=tempHTML.replace('[8月24日]',month+'月'+day+'日');
  75. $('#todayweek').html('今天');
  76. } else{
  77. tempHTML=tempHTML.replace('[8月24日]',month+'月'+day+'日');
  78. var newdate = year+'/'+month+'/'+day;
  79. var week = getWeekDay(newdate);
  80. $('#todayweek').html(week);
  81. }
  82. tempHTML=tempHTML.replace('[07:45]',list.start_time);
  83. tempHTML=tempHTML.replace('[毛东东]',list.contact_name);
  84. tempHTML=tempHTML.replace('[18621904917]',list.contact_mobile);
  85. newHTML+=tempHTML;
  86. $('#detail_order').html(newHTML);
  87. $('#detail_order').removeClass('ui_hide');
  88. if (datestr == nowdate) {
  89. $('#todayweek').html('今天');
  90. } else{
  91. var newdate = year+'/'+month+'/'+day;
  92. var week = getWeekDay(newdate);
  93. $('#todayweek').html(week);
  94. }
  95. }
  96. //倒计时
  97. function timer(intDiff,minstr,secstr){
  98. window.setInterval(function(){
  99. var day=0,
  100. hour=0,
  101. minute=0,
  102. second=0;//时间默认值
  103. if(intDiff > 0){
  104. day = Math.floor(intDiff / (60 * 60 * 24));
  105. hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
  106. minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
  107. second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
  108. }
  109. if (minute <= 9) minute = '0' + minute;
  110. if (second <= 9) second = '0' + second;
  111. $('#'+minstr).html(minute+'分');
  112. $('#'+secstr).html(second+'秒');
  113. intDiff--;
  114. }, 1000);
  115. }
  116. //重新预订
  117. function bookAway(){
  118. window.location.href = './index.html';
  119. }
  120. //支付
  121. function goToPay(order_id){
  122. var minute = $('#minute_show_go').html();;
  123. var second = $('#second_show_go').html();
  124. if (minute == '00分' && second == '00秒') {
  125. alert('支付已超时,请重新购票!');
  126. return false;
  127. }else{
  128. window.location.href = 'http://xmwx.zhizhuchuxing.cn/wechat/WxPay/realpay/onlinePay.php?orderid='+order_id+'&fx=11&code2=dzbs';
  129. }
  130. }
  131. //退票
  132. function refundTicket(order_id){
  133. var r=confirm("确定要退票吗?");
  134. if (r==true){
  135. $("#loadingToast").show();
  136. $.ajax({
  137. url:base_api+'application/custom_made/control.php', //请求地址
  138. type: "post",
  139. data:{
  140. type:"order_refund",
  141. order_id:order_id
  142. },//请求方式
  143. async:false,
  144. dataType: "json",
  145. success: function (data) {
  146. console.log(data);
  147. if(data.code == 0){
  148. $("#loadingToast").hide();
  149. alert('退票成功!');
  150. window.location.href = "./order_list.html";
  151. }else{
  152. $("#loadingToast").hide();
  153. alert(data.info);
  154. }
  155. }
  156. });
  157. }
  158. else{
  159. return;
  160. }
  161. }