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.
 
 
 
 

338 lines
12 KiB

  1. /*======================网络请求的Ajax的代码=======================*/
  2. var carTicketInfo = null;
  3. var ticket_info_str='';
  4. // 创建一个Ajax对象
  5. if (window.ActiveXObject) {
  6. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  7. } else {
  8. var myreq = new XMLHttpRequest();
  9. }
  10. //======================基本信息结束
  11. window.onload = function() {
  12. var run_id = getPar('run_id');
  13. if (run_id) {} else {
  14. run_id = '1';
  15. }
  16. ticket_info_str=$("#ticketList").html();
  17. // get_virtual_user_list('http://192.168.6.245:8080/st-xm/Api/runInfoControll.php?method=getRunInfo&run_id=' + run_id);
  18. get_virtual_user_list('./st-xm/Api/runInfoControll.php?method=getRunInfo&user_id=1&run_id=' + run_id);
  19. }
  20. // 请求方法,传入URL
  21. function get_virtual_user_list(myURL) {
  22. //location.href='./st-xm/Api/runInfoControll.php?method=getRunInfo&run_id='+myURL;
  23. var tnowtime = getDateTime(4);
  24. console.log(myURL)
  25. if (myURL.indexOf('?') >= 0) {
  26. myURL += '&tt=' + tnowtime;
  27. } else {
  28. myURL += '?tt=' + tnowtime;
  29. }
  30. $.getJSON(myURL, function(httpData) {
  31. // newstr 就是接收到的数据
  32. //
  33. if (httpData['code'] != '0') {
  34. alert(httpData['info']);
  35. return;
  36. }
  37. //基本信息
  38. $("#startarea").text(httpData['property'] + ' (' + httpData['prod_name'] + ')');
  39. $("#starttime").text(httpData['run_date'] + ' ' + httpData['run_time']);
  40. //途径站点
  41. if(httpData['station_list']){
  42. waytosite(httpData['station_list']);
  43. }else{
  44. $('#tujingstation').css('display','none');
  45. }
  46. //班次状态
  47. $('#bancistatus').text((function(data) {
  48. return data == "137" ? "待审核" : data == "138" ? "待调派" : data == "139" ? "已调派" : data == "140" ? "已发车" : data == "141" ? "已完成" : data == "142" ? "已停用" : "其他"
  49. })(httpData['run_status']));
  50. //收客状态
  51. // $('#shoukestatus').text(httpData['receiving']);
  52. //承运信息
  53. if(httpData['bus_info']){
  54. chenyunInfo(httpData['bus_info']);
  55. }else{
  56. $('#chenyun').css('display','none');
  57. }
  58. //可售票种
  59. if(httpData['ticket_type']){
  60. keshouTicket(httpData['ticket_type']);
  61. }else{
  62. $('#keshouTicket').css('display','none');
  63. }
  64. $('.control-show').css('display','block');
  65. //预售天数
  66. // $('#yushoudays').text(httpData['pre_sale_day'] + '天');
  67. //车票信息
  68. if(httpData['order_ticket_info_list']){
  69. carTicketInfo = httpData['order_ticket_info_list'];
  70. }
  71. // }
  72. });
  73. // $.ajax({
  74. // url:myURL,
  75. // success:function(data){
  76. // var httpData = JSON.parse(data);
  77. // console.log(httpData);
  78. // // newstr 就是接收到的数据
  79. // var newstr = myreq.responseText;
  80. // console.log(eval("("+newstr+")"))
  81. // var httpData = JSON.parse(newstr);
  82. // //
  83. // if (httpData['code'] != '0') {
  84. // alert(httpData['info']);
  85. // return;
  86. // }
  87. // //基本信息
  88. // $("#startarea").text(httpData['property'] + ' (' + httpData['prod_name'] + ')');
  89. // $("#starttime").text(httpData['run_date'] + ' ' + httpData['run_time']);
  90. // //途径站点
  91. // waytosite(httpData['station_list']);
  92. // //班次状态
  93. // $('#bancistatus').text(httpData['run_status']);
  94. // //收客状态
  95. // $('#shoukestatus').text(httpData['receiving']);
  96. // //承运信息
  97. // chenyunInfo(httpData['bus_info']);
  98. // //可售票种
  99. // keshouTicket(httpData['ticket_type']);
  100. // //预售天数
  101. // $('#yushoudays').text(httpData['pre_sale_day'] + '天');
  102. // //车票信息
  103. // var carTicketInfo = httpData['order_ticket_info_list'];
  104. // var newHTML = ''
  105. // for (var i = 0; i < carTicketInfo.length; i++) {
  106. // var tempDict = carTicketInfo[i];
  107. // var tempHTML = $("#ticketList").html();
  108. // tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
  109. // tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
  110. // tempHTML = tempHTML.replace('[上]', tempDict['start_station']);
  111. // tempHTML = tempHTML.replace('[下]', tempDict['end_station']);
  112. // tempHTML = tempHTML.replace('[出行时间]', tempDict['start_time'] + ' - ' + tempDict['end_time']);
  113. // tempHTML = tempHTML.replace('[车号]', tempDict['bus_order_id']);
  114. // tempHTML = tempHTML.replace('[座位]', tempDict['seat_type']);
  115. // tempHTML = tempHTML.replace('[人群]', tempDict['crowd']);
  116. // tempHTML = tempHTML.replace('[座号]', tempDict['seat_name']);
  117. // tempHTML = tempHTML.replace('[售价]', tempDict['order_price']);
  118. // tempHTML = tempHTML.replace('[出票]', tempDict['if_ticket']);
  119. // tempHTML = tempHTML.replace('[打印]', tempDict['if_print']);
  120. // tempHTML = tempHTML.replace('[操作]', '<a target="_Blank" href="detailTicket.html?order_id='+tempDict['order_id']+'">查看</a>');
  121. // newHTML += tempHTML;
  122. // }
  123. // //车票信息下面
  124. // var carTicketInfo_Down = httpData['not_in_order_ticket_info_list'];
  125. // for (var i = 0; i < carTicketInfo_Down.length; i++) {
  126. // var tempDict = carTicketInfo_Down[i];
  127. // var tempHTML = $("#ticketList").html();
  128. // tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
  129. // tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
  130. // tempHTML = tempHTML.replace('[上]', '');
  131. // tempHTML = tempHTML.replace('[下]', '');
  132. // tempHTML = tempHTML.replace('[出行时间]', '');
  133. // tempHTML = tempHTML.replace('[车号]', '');
  134. // tempHTML = tempHTML.replace('[座位]', tempDict['seat']);
  135. // tempHTML = tempHTML.replace('[人群]', tempDict['crowd']);
  136. // tempHTML = tempHTML.replace('[座号]', '-');
  137. // tempHTML = tempHTML.replace('[售价]', '-');
  138. // tempHTML = tempHTML.replace('[出票]', tempDict['sale']);
  139. // tempHTML = tempHTML.replace('[打印]', '');
  140. // tempHTML = tempHTML.replace('[操作]', '');
  141. // newHTML += tempHTML;
  142. // }
  143. // $("#ticketList").html(newHTML);
  144. // $('.control-show').css('display','block');
  145. // }
  146. // })
  147. }
  148. //途径站点
  149. function waytosite(waytosite) {
  150. var tujingHTML = ''
  151. for (var i = 0; i < waytosite.length; i++) {
  152. var tempDict = waytosite[i];
  153. var tempHTML = $("#tujingstation").html();
  154. tempHTML = tempHTML.replace('[时间]', tempDict['start_time']);
  155. tempHTML = tempHTML.replace('[站点]', tempDict['station_name']);
  156. tempHTML = tempHTML.replace('[上下类型]', tempDict['type_name']);
  157. tempHTML = tempHTML.replace('[检票口]', function() {
  158. console.log(tempDict['res_name'])
  159. return !tempDict['res_name'] ? "-" : tempDict['res_name']
  160. });
  161. //tempDict['res_name']
  162. tujingHTML += tempHTML;
  163. }
  164. $("#tujingstation").html(tujingHTML);
  165. }
  166. //承运信息
  167. function chenyunInfo(chenyunInfo) {
  168. var chenHTML = '';
  169. var cyHTML = $('#chenyun').html();
  170. for (var i = 0; i < chenyunInfo.length; i++) {
  171. var tempDict = chenyunInfo[i];
  172. var tempHTML=cyHTML;
  173. var carNo = tempDict['bus_order_id'];
  174. carNo=(Array(2).join(0)+carNo).slice(-2);
  175. tempHTML = tempHTML.replace('[车次]', carNo);
  176. tempHTML = tempHTML.replace('[品牌]', tempDict['bus_brand']);
  177. tempHTML = tempHTML.replace('[座位]', tempDict['property']);
  178. tempHTML = tempHTML.replace('[选座支持]', tempDict['allow_select_seat']);
  179. tempHTML = tempHTML.replace('[车辆]', tempDict['send_bus_res_id']);
  180. tempHTML = tempHTML.replace('[司机]', tempDict['send_bus_driver_res_id']);
  181. chenHTML += tempHTML;
  182. }
  183. $("#chenyun").html(chenHTML);
  184. }
  185. //可售票种
  186. function keshouTicket(keshouTicket) {
  187. var keshouHTML = '';
  188. for (var i = 0; i < keshouTicket.length; i++) {
  189. var tempDict = keshouTicket[i];
  190. var tempHTML = $('#keshouTicket').html();
  191. tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
  192. tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
  193. tempHTML = tempHTML.replace('[座位]', tempDict['seat']);
  194. // tempHTML = tempHTML.replace('[人群]', tempDict['croed']);
  195. tempHTML = tempHTML.replace('[零售价]', tempDict['price']);
  196. if (tempDict['max_count']=="0") {
  197. tempDict['max_count']="Freesale";
  198. };
  199. tempHTML = tempHTML.replace('[最大可售]', tempDict['max_count']);
  200. // tempHTML = tempHTML.replace('[已售]', tempDict['sale_count']);
  201. keshouHTML += tempHTML;
  202. }
  203. $('#keshouTicket').html(keshouHTML);
  204. }
  205. function type_choose(typeName) {
  206. var basic = $("#carBasicInfo");
  207. var carInfo = $("#carTicketInfo");
  208. var li_basic = $("#li_basic a");
  209. var li_carInfo = $("#li_carInfo a");
  210. if (typeName == "基本信息") {
  211. basic.css("display", "block");
  212. carInfo.css("display", "none");
  213. li_carInfo.css("background", "#f9f9f9");
  214. li_basic.css("background", "#DDDDDD");
  215. } else {
  216. basic.css("display", "none");
  217. carInfo.css("display", "block");
  218. li_carInfo.css("background", "#DDDDDD");
  219. li_basic.css("background", "#f9f9f9");
  220. if(carTicketInfo.length<=0){
  221. $("#ticketList").html('');
  222. alert('目前已售车票数量为0');
  223. return;
  224. }
  225. $("#ticketList").html('');
  226. var newHTML = ''
  227. for (var i = 0; i < carTicketInfo.length; i++) {
  228. var tempDict = carTicketInfo[i];
  229. var tempHTML = ticket_info_str;
  230. var carNo = tempDict['bus_order_id'];
  231. carNo=(Array(2).join(0)+carNo).slice(-2);
  232. tempHTML = tempHTML.replace('[出发地]', tempDict['start_area']);
  233. tempHTML = tempHTML.replace('[目的地]', tempDict['end_area']);
  234. tempHTML = tempHTML.replace('[上]', tempDict['start_station']);
  235. tempHTML = tempHTML.replace('[下]', tempDict['end_station']);
  236. tempHTML = tempHTML.replace('[出行时间]', tempDict['start_time'] + ' - ' + tempDict['end_time']);
  237. tempHTML = tempHTML.replace('[车次]', carNo);
  238. tempHTML = tempHTML.replace('[座位]', tempDict['seat_type']);
  239. // tempHTML = tempHTML.replace('[人群]', tempDict['crowd']);
  240. tempHTML = tempHTML.replace('[座号]', tempDict['seat_name']);
  241. tempHTML = tempHTML.replace('[售价]', tempDict['order_price']);
  242. tempHTML = tempHTML.replace('[出票]', tempDict['if_ticket']);
  243. tempHTML = tempHTML.replace('[打印]', tempDict['if_print']);
  244. tempHTML = tempHTML.replace('[操作]', '<a target="_Blank" onclick="open_new_path(this)" go_path="detailTicket.html?order_id=' + tempDict['order_id'] + '">查看</a>');
  245. newHTML += tempHTML;
  246. }
  247. $("#ticketList").html(newHTML);
  248. }
  249. }
  250. function getPar(par) {
  251. //获取当前URL
  252. var local_url = document.location.href;
  253. local_url = decodeURI(local_url);
  254. //获取要取得的get参数位置
  255. var get = local_url.indexOf(par + "=");
  256. if (get == -1) {
  257. return false;
  258. }
  259. //截取字符串
  260. var get_par = local_url.slice(par.length + get + 1);
  261. //判断截取后的字符串是否还有其他get参数
  262. var nextPar = get_par.indexOf("&");
  263. if (nextPar != -1) {
  264. get_par = get_par.slice(0, nextPar);
  265. }
  266. return get_par;
  267. }
  268. function getDateTime(nTypeFlag) {
  269. var tNowTime = new Date();
  270. var myYear = ';' + tNowTime.getFullYear() + ';';
  271. var myMonth = ';' + (tNowTime.getMonth() + 1 - 0) + ';';
  272. var myDay = ';' + tNowTime.getDate() + ';';
  273. var myHour = ';' + tNowTime.getHours() + ';';
  274. var myMinu = ';' + tNowTime.getMinutes() + ';';
  275. var mySecond = ';' + tNowTime.getSeconds() + ';';
  276. if (myMonth.length < 4) myMonth = '0' + myMonth;
  277. if (myDay.length < 4) myDay = '0' + myDay;
  278. if (myHour.length < 4) myHour = '0' + myHour;
  279. if (myMinu.length < 4) myMinu = '0' + myMinu;
  280. if (mySecond.length < 4) mySecond = '0' + mySecond;
  281. var cNewTimeStr;
  282. //alert(tNowTime);
  283. switch (nTypeFlag + 1 - 1) {
  284. case 0:
  285. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  286. break;
  287. case 1:
  288. cNewTimeStr = myYear + myMonth + myDay;
  289. break;
  290. case 2:
  291. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  292. break;
  293. case 3:
  294. cNewTimeStr = myHour + myMinu + mySecond;
  295. break;
  296. case 4:
  297. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  298. break;
  299. case 5:
  300. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  301. break;
  302. case 6:
  303. cNewTimeStr = myYear;
  304. break;
  305. case 7:
  306. cNewTimeStr = myYear + '-' + myMonth;
  307. break;
  308. default:
  309. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  310. break;
  311. }
  312. cNewTimeStr = cNewTimeStr.replace(/;/g, "");
  313. return cNewTimeStr;
  314. }