You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

274 lines
11 KiB

  1. var order_status = '';
  2. var order_id = '';
  3. var goHTML = '';
  4. var backHTML = '';
  5. //记录是否是返程
  6. var ifback = '';
  7. var intDiff = '';//倒计时总秒数量
  8. window.onload = function(){
  9. goHTML = $('#go').html();
  10. backHTML = $('#goback').html();
  11. order_id = getPar('order_id');
  12. httpData(order_id);
  13. }
  14. //请求数据
  15. function httpData(order_id){
  16. $.ajax({
  17. url:'./zz_wxsct/Model/order/order_detail_info.php', //请求地址
  18. type: "post", //请求方式
  19. async:false,
  20. data:{
  21. order_id:order_id
  22. },
  23. dataType: "json",
  24. success: function (data) {
  25. console.log(data);
  26. if(data.code == 0){
  27. intDiff = data.time_left > 0? data.time_left : 0;
  28. reloadData(data);
  29. }else{
  30. alert(data.info);
  31. }
  32. }
  33. });
  34. }
  35. //加载数据
  36. function reloadData(data){
  37. ifback = data.is_back;
  38. if (data.is_back == 0) {
  39. $('#go').removeClass('ui_hide');
  40. $('#goback').addClass('ui_hide');
  41. //判断展示
  42. var golist = data.go_list;
  43. var status=golist.order_status;
  44. var passenger = data.go_list.customer_info;
  45. //去程
  46. var tempHTML = goHTML;
  47. tempHTML=tempHTML.replace('[185518]',data.order_id);
  48. tempHTML=tempHTML.replace('[待支付]',golist.order_status_info);
  49. // tempHTML=tempHTML.replace('[order_id]',golist.start_area_name);
  50. tempHTML=tempHTML.replace('[出发地]',golist.start_area_name);
  51. tempHTML=tempHTML.replace('[出发地站点]',golist.start_res_name);
  52. tempHTML=tempHTML.replace('[去程时间]',golist.start_time);
  53. tempHTML=tempHTML.replace('[去程日期]',golist.start_date);
  54. tempHTML=tempHTML.replace('[目的地]',golist.end_area_name);
  55. tempHTML=tempHTML.replace('[目的地站点]',golist.end_res_name);
  56. tempHTML=tempHTML.replace('[去程人数]',golist.seat_num+'人');
  57. tempHTML=tempHTML.replace('[去程座位]',golist.seat_type);
  58. tempHTML=tempHTML.replace('[联系人]',golist.contact_name);
  59. tempHTML=tempHTML.replace('[联系人手机号]',golist.contact_mobile);
  60. tempHTML=tempHTML.replace('[50]',golist.total_price);
  61. var passHTML = $('#passenger_go').html();
  62. var passtemp = '';
  63. if (passenger.length > 0) {
  64. for (var i = 0; i < passenger.length; i++) {
  65. var p_html=passHTML;
  66. p_html = p_html.replace('[乘车人]',passenger[i].name);
  67. p_html = p_html.replace('[身份证信息]',passenger[i].id_num_encrypt);
  68. passtemp += p_html;
  69. }
  70. // $('#passenger').html(passtemp);
  71. }
  72. if (golist.order_status == "145") {
  73. tempHTML=tempHTML.replace('[payred_color]','payred_color');
  74. tempHTML=tempHTML.replace('<div style="display: none;" class="noneback"></div>','<div class="ub-f1 darkgreen_color white_color text_middle ulev1 " style="padding:0.12rem 0;width:1%;" onclick="goToPay('+data.order_id+')">去支付</div>');
  75. tempHTML=tempHTML.replace('<div style="display: none;"></div>','<div class="ub-f1 darkgreen_color white_color text_middle ulev1 " style="padding:0.13rem 0;font-size:0.15rem;width:1%;" onclick="goToPay('+data.order_id+')">去支付</div>');
  76. }else if (golist.order_status == "146") {
  77. tempHTML=tempHTML.replace('[payred_color]','yellow_color');
  78. if (golist.can_do == '0') {
  79. //不能退票
  80. tempHTML=tempHTML.replace('class="ulev4 fontgreen_color" id="price"','class="ulev4 lightgray_color" id="price"');
  81. tempHTML=tempHTML.replace('<div style="display: none;"></div>','<div class="text_middle ui_radiu_all ui_m_r25 ui_m_t05 ui_m_b05" style="display:inline-block; padding:0.04rem 0.2rem; border: 1px solid white;font-size:0.15rem; color:white;margin-top: 0.08rem;margin-bottom: 0.08rem;">退票</div>');
  82. } else{
  83. tempHTML=tempHTML.replace('<div style="display: none;"></div>','<div class="text_middle ui_radiu_all ui_m_r25 ui_m_t05 ui_m_b05" style="display:inline-block;padding:0.04rem 0.2rem; border: 1px solid #3d434f;font-size:0.15rem;margin-top: 0.08rem;margin-bottom: 0.08rem;" onclick="rufundTicket('+data.order_id+')">退票</div>');
  84. }
  85. // $('#title_div_go').addClass('ui_hide');
  86. }else if(golist.order_status == "148"){
  87. tempHTML=tempHTML.replace('[payred_color]','lightgray_color');
  88. tempHTML=tempHTML.replace('<div style="display: none;"></div>','<div class="text_middle ui_radiu_all ui_m_r25 ui_m_t05 ui_m_b05 fontgreen_color" style="display:inline-block;padding:0.04rem 0; border: 1px solid #5cc4bb;font-size:0.15rem;margin-top: 0.08rem;margin-bottom: 0.08rem;" onclick="buyAgain()">重新购票</div>');
  89. // $('#title_content_go').html('订单超时已取消')
  90. }else if(golist.order_status == "147"){
  91. tempHTML=tempHTML.replace('[payred_color]','lightgray_color');
  92. tempHTML=tempHTML.replace('<div style="display: none;"></div>','<div class="ub-f1 text_middle ui_radiu_all ui_m_r25 ui_m_t05 ui_m_b05" style="padding:0.07rem 0; border: 1px solid white;color:white">隐藏</div>');
  93. }
  94. $('#go').html(tempHTML);
  95. $('#passenger_go').html(passtemp);
  96. if(status=="146"){
  97. $('#title_div_go').addClass('ui_hide');
  98. }else if(status=="148"){
  99. $('#title_content_go').html('订单已取消')
  100. }else if(status == "145"){
  101. timer(intDiff,'minute_show_go','second_show_go');
  102. }
  103. } else{
  104. var golist = data.go_list;
  105. var status=golist.order_status;
  106. var backlist = data.back_list;
  107. var passenger = data.go_list.customer_info;
  108. $('#go').addClass('ui_hide');
  109. $('#goback').removeClass('ui_hide');
  110. //去程
  111. var tempHTML = backHTML;
  112. tempHTML=tempHTML.replace('[185518]',data.order_id);
  113. tempHTML=tempHTML.replace('[待支付]',golist.order_status_info);
  114. // tempHTML=tempHTML.replace('[order_id]',golist.start_area_name);
  115. tempHTML=tempHTML.replace('[出发地]',golist.start_area_name);
  116. tempHTML=tempHTML.replace('[出发地站点]',golist.start_res_name);
  117. tempHTML=tempHTML.replace('[去程时间]',golist.start_time);
  118. tempHTML=tempHTML.replace('[去程日期]',golist.start_date);
  119. tempHTML=tempHTML.replace('[目的地]',golist.end_area_name);
  120. tempHTML=tempHTML.replace('[目的地站点]',golist.end_res_name);
  121. tempHTML=tempHTML.replace('[去程人数]',golist.seat_num);
  122. tempHTML=tempHTML.replace('[去程座位]',golist.seat_type);
  123. tempHTML=tempHTML.replace('[联系人]',golist.contact_name);
  124. tempHTML=tempHTML.replace('[联系人手机号]',golist.contact_mobile);
  125. //返程
  126. tempHTML=tempHTML.replace('[返程出发地]',backlist.start_area_name);
  127. tempHTML=tempHTML.replace('[返程出发地站点]',backlist.start_res_name);
  128. tempHTML=tempHTML.replace('[返程时间]',backlist.start_time);
  129. tempHTML=tempHTML.replace('[返程日期]',backlist.start_date);
  130. tempHTML=tempHTML.replace('[返程目的地]',backlist.end_area_name);
  131. tempHTML=tempHTML.replace('[返程目的地站点]',backlist.end_res_name);
  132. tempHTML=tempHTML.replace('[返程人数]',backlist.seat_num+'人');
  133. tempHTML=tempHTML.replace('[返程座位]',backlist.seat_type);
  134. tempHTML=tempHTML.replace('[50]',data.total_price);
  135. var passHTML = $('#passenger').html();
  136. var passtemp = '';
  137. if (passenger.length > 0) {
  138. for (var i = 0; i < passenger.length; i++) {
  139. var p_html=passHTML;
  140. p_html = p_html.replace('[乘车人]',passenger[i].name);
  141. p_html = p_html.replace('[身份证信息]',passenger[i].id_num_encrypt);
  142. passtemp += p_html;
  143. }
  144. // $('#passenger').html(passtemp);
  145. }
  146. if (golist.order_status == "145") {
  147. tempHTML=tempHTML.replace('<div style="display: none;" class="noneback"></div>','<div class="ub-f1 darkgreen_color white_color text_middle ulev1 " style="padding:0.12rem 0;width:1%;" onclick="goToPay('+data.order_id+')">去支付</div>');
  148. tempHTML=tempHTML.replace('[payred_color]','payred_color');
  149. }else if (golist.order_status == "146") {
  150. tempHTML=tempHTML.replace('[payred_color]','yellow_color');
  151. if (golist.can_do == '0') {
  152. //不能退票
  153. tempHTML=tempHTML.replace('class="ulev4 fontgreen_color" id="price"','class="ulev4 lightgray_color" id="price"');
  154. tempHTML=tempHTML.replace('<div style="display: none;" class="noneback"></div>','<div class="ub-f1 text_middle ui_radiu_all ui_m_r30 ui_m_t05 ui_m_b05" style="padding:0.07rem 0; border: 1px solid white; color:white;font-size:0.15rem;width: 1%;margin-top: 0.08rem;margin-bottom: 0.08rem;margin-left: 0.5rem;">退票</div>');
  155. } else{
  156. tempHTML=tempHTML.replace('<div style="display: none;" class="noneback"></div>','<div class="ub-f1 text_middle ui_radiu_all ui_m_r30 ui_m_t05 ui_m_b05" style="padding:0.07rem 0; border: 1px solid #3d434f;font-size:0.15rem;width: 1%;margin-top: 0.08rem;margin-bottom: 0.08rem;margin-left: 0.5rem;" onclick="rufundTicket('+data.order_id+')">退票</div>');
  157. }
  158. // $('#title_div_back').html('提示:往返订单只能合并退票');
  159. }else if(golist.order_status == "148"){
  160. tempHTML=tempHTML.replace('[payred_color]','lightgray_color');
  161. tempHTML=tempHTML.replace('<div style="display: none;" class="noneback"></div>','<div class="ub-f1 text_middle ui_radiu_all ui_m_r25 ui_m_t05 ui_m_b05 fontgreen_color" style="padding:0.04rem 0; border: 1px solid #5cc4bb;font-size:0.15rem;width:1%;margin-left: 0.5rem;margin-top: 0.08rem;margin-bottom: 0.08rem;" onclick="buyAgain()">重新购票</div>');
  162. // $('#title_content_back').html('订单已取消')
  163. }else if(golist.order_status == "147"){
  164. tempHTML=tempHTML.replace('[payred_color]','lightgray_color');
  165. tempHTML=tempHTML.replace('<div style="display: none;" class="noneback"></div>','<div class="ub-f1 text_middle ui_radiu_all ui_m_r25 ui_m_t05 ui_m_b05" style="padding:0.07rem 0; border: 1px solid white;color:white;font-size:0.15rem">隐藏</div>');
  166. }
  167. $('#goback').html(tempHTML);
  168. $('#passenger').html(passtemp);
  169. if(status=="146"){
  170. $('#title_div_back').html('提示:往返订单只能合并退票');
  171. }else if(status=="148"){
  172. $('#title_content_back').html('订单已取消')
  173. }else if(status == "145"){
  174. timer(intDiff,'minute_show','second_show');
  175. }
  176. }
  177. }
  178. //重新购票
  179. function buyAgain(){
  180. window.location.href = "./travel_book.html";
  181. }
  182. //退票
  183. function rufundTicket(order_id){
  184. var r=confirm("确定要退票吗?");
  185. if (r==true){
  186. $.ajax({
  187. url:'./zz_wxsct/control.php', //请求地址
  188. type: "post",
  189. data:{
  190. type:"order_refund",
  191. order_id:order_id
  192. },//请求方式
  193. async:false,
  194. dataType: "json",
  195. success: function (data) {
  196. console.log(data);
  197. if(data.code == 0){
  198. alert('退票成功!');
  199. window.location.href = "./order_list.html";
  200. }else{
  201. alert(data.info);
  202. }
  203. }
  204. });
  205. }
  206. else{
  207. return;
  208. }
  209. }
  210. //支付
  211. function goToPay(order_id){
  212. var minute = '';
  213. var second = '';
  214. if (ifback == 0) {
  215. minute = $('#minute_show_go').html();
  216. second = $('#second_show_go').html();
  217. } else{
  218. minute = $('#minute_show').html();
  219. second = $('#second_show').html();
  220. }
  221. if (minute == '00分' && second == '00秒') {
  222. alert('支付已超时,请重新购票!');
  223. return false;
  224. }else{
  225. window.location.href = 'http://xmwx.zhizhuchuxing.cn/wechat/WxPay/realpay/onlinePay.php?orderid='+order_id+'&fx=11&code2=wxsc';
  226. }
  227. }
  228. //倒计时
  229. function timer(intDiff,minstr,secstr){
  230. window.setInterval(function(){
  231. var day=0,
  232. hour=0,
  233. minute=0,
  234. second=0;//时间默认值
  235. if(intDiff > 0){
  236. day = Math.floor(intDiff / (60 * 60 * 24));
  237. hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
  238. minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
  239. second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
  240. }
  241. if (minute <= 9) minute = '0' + minute;
  242. if (second <= 9) second = '0' + second;
  243. $('#'+minstr).html(minute+'分');
  244. $('#'+secstr).html(second+'秒');
  245. intDiff--;
  246. }, 1000);
  247. }