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.
 
 
 
 

157 lines
5.1 KiB

  1. function reload_Info(httpData){
  2. //车票信息
  3. var detailTicketInfo=httpData['detailTicketInfo'];
  4. var ticket_info=$("#ttt");
  5. var tttHTML=ticket_info.html();
  6. var newHTML=''
  7. for(var i=0;i<detailTicketInfo.length;i++){
  8. var tempDict=detailTicketInfo[0];
  9. var tempHTML=tttHTML;
  10. var hour = parseInt(tempDict['total_time']/60);
  11. var min =tempDict['total_time']%60;
  12. var total_time_str = hour+'小时'+min+'分';
  13. $('#ID').html('<a href="#">'+tempDict['orderNo']+'</a>');
  14. tempHTML=tempHTML.replace('[微信服务号]',tempDict['orderNo']);
  15. tempHTML=tempHTML.replace('[出发地]',tempDict['start_area']);
  16. tempHTML=tempHTML.replace('[目的地]',tempDict['end_area']);
  17. tempHTML=tempHTML.replace('[上车点]',tempDict['up_station']);
  18. tempHTML=tempHTML.replace('[下车点]',tempDict['down_station']);
  19. tempHTML=tempHTML.replace('[线路代码]',tempDict['codeId']);
  20. tempHTML=tempHTML.replace('[总时间]',total_time_str);
  21. tempHTML=tempHTML.replace('[出行时间]',tempDict['start_time']);
  22. tempHTML=tempHTML.replace('[价格]',tempDict['price']);
  23. tempHTML=tempHTML.replace('[车位号]',tempDict['carNo']);
  24. tempHTML=tempHTML.replace('[座位号]',tempDict['seatNo']);
  25. tempHTML=tempHTML.replace('[人群]',tempDict['seat']);
  26. tempHTML=tempHTML.replace('[年龄]',tempDict['people']);
  27. tempHTML=tempHTML.replace('[打印]',tempDict['print']);
  28. tempHTML=tempHTML.replace('[出票]',tempDict['chuPiao']);
  29. tempHTML=tempHTML.replace('[改签]',tempDict['gaiqian']);
  30. tempHTML=tempHTML.replace('[车牌]',tempDict['carId']);
  31. tempHTML=tempHTML.replace('[品牌]',tempDict['brand']);
  32. tempHTML=tempHTML.replace('[车座]',tempDict['carSeat']);
  33. tempHTML=tempHTML.replace('[车公司]',tempDict['company']);
  34. tempHTML=tempHTML.replace('[司机]',tempDict['driverName']);
  35. tempHTML=tempHTML.replace('[工牌]',tempDict['job_no']);
  36. tempHTML=tempHTML.replace('[电话]',tempDict['tel']);
  37. tempHTML=tempHTML.replace('[司机公司]',tempDict['company']);
  38. newHTML+=tempHTML;
  39. }
  40. ticket_info.html(newHTML);
  41. $('.control-show').css({"display":""});
  42. }
  43. console.log(getDateTime(4));
  44. document.addEventListener('DOMContentLoaded',function(){
  45. console.log(getDateTime(4));
  46. var order_id=getPar('order_id');
  47. get_virtual_user_list('./st-xm/Api/ticket_details.php?order_id='+order_id);
  48. console.log(getDateTime(4));
  49. },false);
  50. //window.onload=function(){
  51. //// get_virtual_user_list('./json/detailJson.html');
  52. // var order_id=getPar('order_id');
  53. // get_virtual_user_list('http://192.168.6.107:8081/st-xm/Api/ticket_details.php?order_id='+order_id);
  54. //}
  55. /*======================网络请求的Ajax的代码=======================*/
  56. // 创建一个Ajax对象
  57. if (window.ActiveXObject){
  58. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  59. }else{
  60. var myreq = new XMLHttpRequest();
  61. }
  62. // 请求方法,传入URL
  63. function get_virtual_user_list(myURL)
  64. {
  65. myreq.open("get",myURL,true);
  66. // 接收的数据交给哪个函数处理
  67. myreq.onreadystatechange = show_user_list;
  68. myreq.send();
  69. }
  70. function show_user_list()
  71. {
  72. if (myreq.readyState == 4)
  73. {
  74. console.log(getDateTime(4));
  75. // newstr 就是接收到的数据
  76. var newstr = myreq.responseText;
  77. var httpData=JSON.parse(newstr);
  78. reload_Info(httpData);
  79. }
  80. }
  81. function getPar(par){
  82. //获取当前URL
  83. var local_url = document.location.href;
  84. local_url = decodeURI(local_url);
  85. //获取要取得的get参数位置
  86. var get = local_url.indexOf(par +"=");
  87. if(get == -1){
  88. return false;
  89. }
  90. //截取字符串
  91. var get_par = local_url.slice(par.length + get + 1);
  92. //判断截取后的字符串是否还有其他get参数
  93. var nextPar = get_par.indexOf("&");
  94. if(nextPar != -1){
  95. get_par = get_par.slice(0, nextPar);
  96. }
  97. return get_par;
  98. }
  99. //时间函数
  100. function getDateTime(nTypeFlag) {
  101. var tNowTime = new Date();
  102. var myYear = ';' + tNowTime.getFullYear() + ';';
  103. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  104. var myDay = ';' + tNowTime.getDate() + ';';
  105. var myHour = ';' + tNowTime.getHours() + ';';
  106. var myMinu = ';' + tNowTime.getMinutes() + ';';
  107. var mySecond = ';' + tNowTime.getSeconds() + ';';
  108. if (myMonth.length < 4) myMonth = '0' + myMonth;
  109. if (myDay.length < 4) myDay = '0' + myDay;
  110. if (myHour.length < 4) myHour = '0' + myHour;
  111. if (myMinu.length < 4) myMinu = '0' + myMinu;
  112. if (mySecond.length < 4) mySecond = '0' + mySecond;
  113. var cNewTimeStr;
  114. //alert(tNowTime);
  115. switch (nTypeFlag + 1 - 1) {
  116. case 0:
  117. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  118. break;
  119. case 1:
  120. cNewTimeStr = myYear + myMonth + myDay;
  121. break;
  122. case 2:
  123. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  124. break;
  125. case 3:
  126. cNewTimeStr = myHour + myMinu + mySecond;
  127. break;
  128. case 4:
  129. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  130. break;
  131. case 5:
  132. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  133. break;
  134. case 6:
  135. cNewTimeStr = myYear;
  136. break;
  137. case 7:
  138. cNewTimeStr = myYear + '-' + myMonth;
  139. break;
  140. default:
  141. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  142. break;
  143. }
  144. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  145. return cNewTimeStr;
  146. }