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.
 
 
 
 

163 lines
5.2 KiB

  1. var pagesize = 10;
  2. var aa = '';
  3. var tr_str='';
  4. var aaaHTML='';
  5. function reload_Info(httpData, myURL2) {
  6. currpage = getPar("currpage");
  7. aa = currpage;
  8. if (currpage) {} else {
  9. currpage = 1;
  10. }
  11. var sum = httpData['totalTickets'];
  12. var tag = "test";
  13. var sendurl = myURL2;
  14. //总数
  15. var count = httpData['totalTickets'];
  16. var aaa = $("#aaa");
  17. if(count==undefined || count=='' || count<=0 || count==false){
  18. aaa.html('');
  19. }else{
  20. var tempStr = aaaHTML.replace('6', count);
  21. aaa.html(tempStr);
  22. }
  23. //车票信息
  24. var searchTicketInfo = httpData['searchInfo'];
  25. var ttt = $("#ttt");
  26. var tttHTML = tr_str;
  27. var newHTML = '';
  28. for (var i = 0; i < searchTicketInfo.length; i++) {
  29. var tempDict = searchTicketInfo[i];
  30. var tempHTML = tttHTML;
  31. // var str= '<a href="order_details.html?">'+tempDict['parent_orderNo']+'';
  32. var parent_detail_id = tempDict['parent_orderNo'];
  33. var parentid = '<a onclick="open_new_path(this)" go_path="order_details.html?order_id=' + parent_detail_id + '" target="_black">' + tempDict['parent_orderNo'] + '';
  34. var carNo = tempDict['carNo'];
  35. carNo=(Array(2).join(0)+carNo).slice(-2);
  36. tempHTML = tempHTML.replace('[线路]', tempDict['line']);
  37. tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
  38. tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
  39. tempHTML = tempHTML.replace('[出行时间]', tempDict['travel_time']);
  40. tempHTML = tempHTML.replace('[车次]', carNo);
  41. tempHTML = tempHTML.replace('[座位]', tempDict['seat']);
  42. // tempHTML = tempHTML.replace('[人群]', tempDict['people']);
  43. tempHTML = tempHTML.replace('[座号]', tempDict['seatNo']);
  44. tempHTML = tempHTML.replace('[售价]', tempDict['price']);
  45. tempHTML = tempHTML.replace('[打印]', tempDict['print']);
  46. // tempHTML=tempHTML.replace('[订单号]',tempDict['orderNo']);
  47. tempHTML = tempHTML.replace('[订单号]', parentid);
  48. var orrder_detail_id = tempDict['orderNo'];
  49. var see = '<a onclick="open_new_path(this)" go_path="detailTicket.html?order_id=' + orrder_detail_id + '" target="_black">查看';
  50. tempHTML = tempHTML.replace('[查看]', see);
  51. newHTML += tempHTML;
  52. }
  53. ttt.html(newHTML);
  54. $('#ttt').css({
  55. "display": ""
  56. });
  57. $('.footer').css({
  58. "display": ""
  59. });
  60. $('#test').html('');
  61. if(sum>0){
  62. getPager(sendurl, sum, currpage, pagesize, tag, 'currpage');
  63. }
  64. }
  65. window.onload = function() {
  66. tr_str=$("#ttt").html();
  67. aaaHTML=$("#aaa").html();
  68. var start = getPar("startarea")?getPar("startarea"):'';
  69. var end = getPar("endarea")? getPar("endarea"):'';
  70. var line = getPar("line")?getPar("line"):'';
  71. var start_time = getPar("starttime")?getPar("starttime"):'';
  72. var carNo = getPar("carNo")?getPar("carNo"):'';
  73. var seatNo = getPar("seatNo")?getPar("seatNo"):'';
  74. var name = getPar("name")?getPar("name"):'';
  75. $('#sstart_area').val(start);
  76. $('#send_area').val(end);
  77. $('#sline').val(line);
  78. $('#id-date-picker-1').val(start_time);
  79. $('#scarNo').val(carNo);
  80. $('#sseatNo').val(seatNo);
  81. $('#sname').val(name);
  82. click_search();
  83. }
  84. /*======================网络请求的Ajax的代码=======================*/
  85. // 创建一个Ajax对象
  86. if (window.ActiveXObject) {
  87. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  88. } else {
  89. var myreq = new XMLHttpRequest();
  90. }
  91. // 请求方法,传入URL
  92. function get_virtual_user_list(myURL, myURL2) {
  93. myreq.open("get", myURL, true);
  94. // 接收的数据交给哪个函数处理
  95. myreq.onreadystatechange = function() {
  96. if (myreq.readyState == 4) {
  97. // newstr 就是接收到的数据
  98. var newstr = myreq.responseText;
  99. var httpData = JSON.parse(newstr);
  100. reload_Info(httpData, myURL2);
  101. }
  102. };
  103. myreq.send();
  104. }
  105. function getPar(par) {
  106. //获取当前URL
  107. var local_url = document.location.href;
  108. local_url = decodeURI(local_url);
  109. //获取要取得的get参数位置
  110. var get = local_url.indexOf(par + "=");
  111. if (get == -1) {
  112. return false;
  113. }
  114. //截取字符串
  115. var get_par = local_url.slice(par.length + get + 1);
  116. //判断截取后的字符串是否还有其他get参数
  117. var nextPar = get_par.indexOf("&");
  118. if (nextPar != -1) {
  119. get_par = get_par.slice(0, nextPar);
  120. }
  121. return get_par;
  122. }
  123. function click_search() {
  124. var start = $('#sstart_area').val();
  125. var end =$('#send_area').val();
  126. var line =$('#sline').val();
  127. var start_time = $('#id-date-picker-1').val()?$('#id-date-picker-1').val():'';
  128. var carNo = $('#scarNo').val();
  129. var seatNo =$('#sseatNo').val();
  130. var name = $('#sname').val();
  131. currpage = getPar("currpage");
  132. if(!currpage){currpage=1;}
  133. aa = currpage;
  134. var myUrl1 = "./st-xm/Api/search_ticket.php?startarea=" + start + "&endarea=" + end + "&starttime=" + start_time + "&line=" + line + "&carNo=" + carNo + "&seatNo=" + seatNo + "&name=" + name + "&pagesize=" + pagesize + "&currpage=" + aa;
  135. // var myUrl1 = "http://192.168.6.107:8081/st-xm/Api/search_ticket.php?startarea=&endarea=&starttime=&line=%E4%B8%8A%E6%B5%B7&carNo=&seatNo=&name=&currpage=2&pagesize=1"
  136. var myUrl2 = "./searchTicket.html?startarea=" + start + "&endarea=" + end + "&starttime=" + start_time + "&line=" + line + "&carNo=" + carNo + "&seatNo=" + seatNo + "&name=" + name + "&pagesize=" + pagesize;
  137. get_virtual_user_list(myUrl1, myUrl2);
  138. }
  139. $(document).ready(function() {
  140. $("#searchBtn").click(function() {
  141. click_search();
  142. })
  143. });