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.
 
 
 
 

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