Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 
 

427 řádky
14 KiB

  1. //Author:zhangsq
  2. //Date:20160826
  3. //Description:查询结果
  4. var tempdate = '';
  5. var has_ticketHTML = '';
  6. var no_ticketHTML = '';
  7. // 去程
  8. var start_area_id = "";
  9. var start_area_type = "";
  10. var end_area_id = "";
  11. var end_area_type = "";
  12. var run_date = "";
  13. var cur_date = '';
  14. var cur_date_str = '';
  15. // 返程
  16. var go_ticket_id="";
  17. // 返程的ticket_id
  18. var back_ticket_ids=new Array();
  19. var no_resultHTMl = '';
  20. var go_date="";
  21. window.onload = function(){
  22. has_ticketHTML = $('#has_ticket').prop('outerHTML');
  23. no_ticketHTML = $('#no_ticket').prop('outerHTML');
  24. // has_ticketHTML=no_ticketHTML;
  25. no_resultHTMl = $('#no_no_no').html();
  26. start_area_id = getPar('start_area_id');
  27. start_area_type = getPar('start_area_type');
  28. end_area_id = getPar('end_area_id');
  29. end_area_type = getPar('end_area_type');
  30. run_date = getPar('run_date')!=""?getPar('run_date'):getPar('go_date');
  31. //zsq
  32. var date_str = getPar('run_date');
  33. if (date_str != '' ) {
  34. run_date = date_str;
  35. }
  36. //zsq end
  37. tempdate = run_date;
  38. var nowdate = getDateTime(0);
  39. var month = getMonthAndDayByDate(run_date,'month');
  40. var day = getMonthAndDayByDate(run_date,'day');
  41. if (tempdate==nowdate) {
  42. $('#show_date').html(month+'月'+day+'日  今天');
  43. $('#left').removeClass('fontgreen_color');
  44. $('#left').addClass('commongray_color');
  45. $('#left').removeAttr('onclick');
  46. $('#left_img').attr('src','images/a2/ic_return_d.png');
  47. } else{
  48. $('#show_date').html(month+'月'+day+'日');
  49. $('#left').removeClass('commongray_color');
  50. $('#left').addClass('fontgreen_color');
  51. $('#left').attr('onclick','leftDidClicked();');
  52. $('#left_img').attr('src','images/a2/ic_return_n_l.png');
  53. }
  54. go_date=getPar('go_date');
  55. go_ticket_id=getPar('go_ticket_id');
  56. if(go_ticket_id==""){ //去程
  57. //清除填写订单的四个缓存
  58. clearStorage('CacheInfo_people');
  59. clearStorage('CacheInfo_station');
  60. clearStorage('go_data');
  61. clearStorage('back_data');
  62. ZZLog('clearStorage');
  63. go_list();
  64. }else{ // 返程
  65. back_list();
  66. }
  67. }
  68. //点击了 前一天
  69. function leftDidClicked(){
  70. var nowdate = tempdate;
  71. var run_date = before(nowdate);
  72. tempdate = run_date;
  73. var nowdate = getDateTime(0);
  74. var month = getMonthAndDayByDate(run_date,'month');
  75. var day = getMonthAndDayByDate(run_date,'day');
  76. if (tempdate==nowdate) {
  77. $('#show_date').html(month+'月'+day+'日  今天');
  78. $('#left').removeClass('fontgreen_color');
  79. $('#left').addClass('commongray_color');
  80. $('#left').removeAttr('onclick');
  81. $('#left_img').attr('src','images/a2/ic_return_d.png');
  82. } else{
  83. $('#show_date').html(month+'月'+day+'日');
  84. $('#left').removeClass('commongray_color');
  85. $('#left').addClass('fontgreen_color');
  86. $('#left').attr('onclick','leftDidClicked();');
  87. $('#left_img').attr('src','images/a2/ic_return_n_l.png');
  88. }
  89. go_ticket_id=getPar('go_ticket_id');
  90. if(go_ticket_id==""){ //去程
  91. go_list();
  92. }else{ // 返程
  93. back_list();
  94. }
  95. }
  96. //点击了后一天
  97. function rightDidClicked(){
  98. var nowdate = tempdate;
  99. var run_date = after(nowdate);
  100. tempdate = run_date;
  101. var nowdate = getDateTime(0);
  102. var month = getMonthAndDayByDate(run_date,'month');
  103. var day = getMonthAndDayByDate(run_date,'day');
  104. if (tempdate==nowdate) {
  105. $('#show_date').html(month+'月'+day+'日  今天');
  106. $('#left').removeClass('fontgreen_color');
  107. $('#left').addClass('commongray_color');
  108. $('#left').removeAttr('onclick');
  109. $('#left_img').attr('src','images/a2/ic_return_d.png');
  110. } else{
  111. $('#show_date').html(month+'月'+day+'日');
  112. $('#left').removeClass('commongray_color');
  113. $('#left').addClass('fontgreen_color');
  114. $('#left').attr('onclick','leftDidClicked();');
  115. $('#left_img').attr('src','images/a2/ic_return_n_l.png');
  116. }
  117. go_ticket_id=getPar('go_ticket_id');
  118. if(go_ticket_id==""){ //去程
  119. go_list();
  120. }else{ // 返程
  121. back_list();
  122. }
  123. // var start_area_id = getPar('start_area_id');
  124. // var start_area_type = getPar('start_area_type');
  125. // var end_area_id = getPar('end_area_id');
  126. // var end_area_type = getPar('end_area_type');
  127. //
  128. }
  129. // go 去程
  130. function go_list(){
  131. //转圈圈
  132. //$("#loadingToast").show();
  133. var url=base_api+"zz_wxsct/control.php";
  134. var parm={
  135. type:"bus_reservation_list_go",
  136. start_id:start_area_id,
  137. start_type:start_area_type,
  138. end_id:end_area_id,
  139. end_type:end_area_type,
  140. run_date:tempdate
  141. }
  142. ZZLog(url+JSON.stringify(parm));
  143. $.post(url,parm,function(res_data){
  144. res_data=JSON.parse(res_data);
  145. ZZLog(res_data);
  146. //转圈圈
  147. //$("#loadingToast").hide();
  148. if (res_data.code == "0") {
  149. // if (res_data.totalnum == '0') {
  150. //
  151. // $('#detailInfo').addClass('ui_hide');
  152. // $('#no_result').removeClass('ui_hide');
  153. // recommendInfo(res_data.list);
  154. //
  155. // }else{
  156. // if (res_data.select_type == "recommend") {
  157. // recommendInfo(res_data.list);
  158. // $('#detailInfo').addClass('ui_hide');
  159. // $('#no_result').removeClass('ui_hide');
  160. // } else{
  161. // $('#detailInfo').removeClass('ui_hide');
  162. // $('#no_result').addClass('ui_hide');
  163. // reloadData(res_data);
  164. // }
  165. // }
  166. if (res_data.select_type == 'normal') {
  167. $('#detailInfo').removeClass('ui_hide');
  168. $('#no_result').addClass('ui_hide');
  169. reloadData(res_data);
  170. } else if(res_data.select_type == "tomorrow_normal"){
  171. $('#detailInfo').addClass('ui_hide');
  172. $('#no_result').removeClass('ui_hide');
  173. $('#tomorrow').html('今日没有匹配的车次');
  174. $('#tomorrow_new').html('请更换日期查询');
  175. $('#no').addClass('ui_hide');
  176. }else{
  177. recommendInfo(res_data.list);
  178. $('#detailInfo').addClass('ui_hide');
  179. $('#no_result').removeClass('ui_hide');
  180. }
  181. } else{
  182. alert(res_data.info);
  183. }
  184. });
  185. }
  186. //推荐信息
  187. function recommendInfo(list){
  188. if (list.length == 0) {
  189. $('#no').hide();
  190. } else{
  191. $('#no').show();
  192. var tempHTML = '';
  193. var newHTML = '';
  194. for(var i=0;i<list.length;i++){
  195. tempHTML = no_resultHTMl;
  196. tempHTML = tempHTML.replace('[出发地]',list[i].start_area_name);
  197. tempHTML = tempHTML.replace('[目的地]',list[i].end_area_name);
  198. tempHTML = tempHTML.replace('[价格]',list[i].price);
  199. tempHTML = tempHTML.replace('[全程用时]',list[i].center_time);
  200. tempHTML = tempHTML.replace('[start_area_id]',list[i].start_area_id);
  201. tempHTML = tempHTML.replace('[end_area_id]',list[i].end_area_id);
  202. tempHTML = tempHTML.replace('[start_area_type]',list[i].start_area_type);
  203. tempHTML = tempHTML.replace('[end_area_type]',list[i].end_area_type);
  204. tempHTML = tempHTML.replace('remmend_ticket','remmend_ticket'+i);
  205. tempHTML = tempHTML.replace("[start_id],[start_type],[end_id],[end_type]",list[i].start_area_id+',\''+list[i].start_area_type+'\','+list[i].end_area_id+',\''+list[i].end_area_type+'\'');
  206. newHTML += tempHTML;
  207. }
  208. $('#no_no_no').html(newHTML)
  209. }
  210. }
  211. // back 返程
  212. function back_list(){
  213. //转圈圈
  214. //$("#loadingToast").show();
  215. var url=base_api+"zz_wxsct/control.php";
  216. var parm={
  217. type:"bus_reservation_list_back",
  218. date:go_date,
  219. ticket_id:go_ticket_id
  220. }
  221. ZZLog(url+JSON.stringify(parm));
  222. $.post(url,parm,function(res_data){
  223. res_data=JSON.parse(res_data);
  224. ZZLog(res_data);
  225. //转圈圈
  226. //$("#loadingToast").hide();
  227. if (res_data.code == "0") {
  228. if (res_data.totalnum == '0') {
  229. $('#detailInfo').addClass('ui_hide');
  230. $('#no_result').removeClass('ui_hide');
  231. $('#no').addClass('ui_hide');
  232. }else{
  233. $('#no_result').addClass('ui_hide');
  234. $('#detailInfo').removeClass('ui_hide');
  235. }
  236. reloadData(res_data);
  237. } else{
  238. alert(res_data.info);
  239. }
  240. });
  241. }
  242. //加载数据
  243. function reloadData(data){
  244. var list = data.list;
  245. var tempHTML = '';
  246. var newHTML = ''
  247. for(var i=0;i<list.length;i++){
  248. if (list[i].ticket_over == '充足') {
  249. tempHTML = has_ticketHTML;
  250. } else{
  251. tempHTML = no_ticketHTML;
  252. }
  253. if(i==list.length-1){
  254. tempHTML=tempHTML.replace('style','style="margin-bottom:0.6rem;');
  255. }
  256. tempHTML=tempHTML.replace('[出发地]',list[i].start_area_name);
  257. tempHTML=tempHTML.replace('[目的地]',list[i].end_area_name);
  258. tempHTML=tempHTML.replace('[出发地站点]',list[i].start_res_name);
  259. tempHTML=tempHTML.replace('[目的地站点]',list[i].end_res_name);
  260. tempHTML=tempHTML.replace('[时间]',list[i].start_time);
  261. tempHTML=tempHTML.replace('[价格]',parseInt(list[i].price));
  262. tempHTML=tempHTML.replace('[全程用时]',list[i].center_time);
  263. tempHTML=tempHTML.replace('[start_area_id]',list[i].start_area_id);
  264. tempHTML=tempHTML.replace('[start_station_id]',list[i].start_res_id);
  265. tempHTML=tempHTML.replace('[end_area_id]',list[i].end_area_id);
  266. tempHTML=tempHTML.replace('[end_station_id]',list[i].end_res_id);
  267. // tempHTML=tempHTML.replace('[order_id]','\''+list[i].run_id+'\',\''+list[i].start_area_id+'\',\''+list[i].end_area_id+'\',\''+list[i].start_res_id+'\',\''+list[i].end_res_id+'\'');
  268. if(go_ticket_id==""){ //去程
  269. tempHTML=tempHTML.replace('[order_id]','\''+list[i].run_id+'\',\''+list[i].start_area_name+'\',\''+list[i].end_area_name+'\',\''+list[i].run_date+'\',\''+list[i].price+'\',\''+list[i].line_id+'\',\''+list[i].ticket_id+'\',\''+list[i].start_time+'\',\''+list[i].start_area_id+'\',\''+list[i].end_area_id+'\',\''+list[i].start_res_id+'\',\''+list[i].end_res_id+'\',\''+''+'\'');
  270. }else{ // 返程
  271. tempHTML=tempHTML.replace('[order_id]','\''+list[i].run_id+'\',\''+list[i].start_area_name+'\',\''+list[i].end_area_name+'\',\''+list[i].run_date+'\',\''+list[i].price+'\',\''+list[i].line_id+'\',\''+list[i].ticket_id+'\',\''+list[i].start_time+'\',\''+list[i].start_area_id+'\',\''+list[i].end_area_id+'\',\''+list[i].start_res_id+'\',\''+list[i].end_res_id+'\',\''+list[i].ticket_id+'\'');
  272. }
  273. tempHTML=tempHTML.replace('[可选上车站点]',list[i].select_station);
  274. newHTML+=tempHTML;
  275. }
  276. $('#detailInfo').html(newHTML);
  277. }
  278. //获取前一天日期
  279. function before(d){
  280. d = new Date(d);
  281. d = +d - 1000*60*60*24;
  282. d = new Date(d);
  283. //return d;
  284. //格式化
  285. var year = ";" + d.getFullYear() + ";";
  286. var month = ";" + (d.getMonth()+0+1) + ";";
  287. var day = ";" + d.getDate() + ";";
  288. if(year.length < 4) {
  289. year = "0" + year;
  290. }
  291. if(month.length < 4) {
  292. month = "0" + month;
  293. }
  294. if(day.length < 4) {
  295. day = "0" + day;
  296. }
  297. var datestr = year + "-" + month + "-" + day;
  298. datestr = datestr.replace(/;/g, "");
  299. return datestr;
  300. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  301. }
  302. //获取后一天日期
  303. function after(d){
  304. d = new Date(d);
  305. d = +d + 1000*60*60*24;
  306. d = new Date(d);
  307. //return d;
  308. //格式化
  309. var year = ";" + d.getFullYear() + ";";
  310. var month = ";" + (d.getMonth()+0+1) + ";";
  311. var day = ";" + d.getDate() + ";";
  312. if(year.length < 4) {
  313. year = "0" + year;
  314. }
  315. if(month.length < 4) {
  316. month = "0" + month;
  317. }
  318. if(day.length < 4) {
  319. day = "0" + day;
  320. }
  321. var datestr = year + "-" + month + "-" + day;
  322. datestr = datestr.replace(/;/g, "");
  323. return datestr;
  324. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  325. }
  326. function getMonthAndDayByDate(datestr,info){
  327. var dateAry = datestr.split('-');
  328. var cNewTimeStr;
  329. switch(info){
  330. case 'year':
  331. cNewTimeStr = dateAry[0];
  332. break;
  333. case 'month':
  334. cNewTimeStr = dateAry[1];
  335. break;
  336. default:
  337. cNewTimeStr = dateAry[2];
  338. break;
  339. }
  340. return cNewTimeStr;
  341. }
  342. function goToBook(run_ids,start_area_name,end_area_name,run_dates,prices,line_id,ticket_ids,start_times,start_area_id,end_area_id,start_res_id,end_res_id,ticket_id){
  343. var list_orders= {
  344. end_area : end_area_name,
  345. start_area : start_area_name,
  346. price : prices,
  347. prod_id : line_id,
  348. run_date : run_dates,
  349. run_id : run_ids,
  350. start_time : start_times,
  351. ticket_id : ticket_id
  352. }
  353. setStorJson('list_order',list_orders);
  354. setStorage("list_id",line_id);
  355. setStorage("run_id",run_ids);
  356. if(line_id == "449860"||line_id == "449865"||line_id == "450036"||line_id == "450037"||line_id == "450539"||line_id == "450544"){
  357. var list = getStorJson("list_order");
  358. console.log(list)
  359. //setStorJson('list_order',list_order);
  360. window.location.href ="http://xmwx.zhizhuchuxing.cn/ZZDZ2/submit_order.html";
  361. }else{
  362. //go_ticket_id 在返程的时候是返程ticket_id 去程可以不传ticket_id
  363. if(go_ticket_id){
  364. window.location.href = "./fill_order.html?run_id="+run_ids+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&start_res_id="+start_res_id+"&end_res_id="+end_res_id+"&go_ticket_id="+ticket_id;
  365. }else{
  366. window.location.href = "./fill_order.html?run_id="+run_ids+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&start_res_id="+start_res_id+"&end_res_id="+end_res_id+"&go_ticket_id=";
  367. }
  368. }
  369. }
  370. //日历点击事件
  371. function selectCalander(){
  372. // start_area_id=791&start_area_type=area&end_area_id=850&end_area_type=area&run_date=2016-09-10&tt=20160910144026
  373. if(go_ticket_id){
  374. window.location.href = "./calendar.html?run_date="+run_date+"&start_area_type="+start_area_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&end_area_type="+end_area_type+"&go_ticket_id="+go_ticket_id+"&from=search_results";
  375. }else{
  376. window.location.href = "./calendar.html?run_date="+run_date+"&start_area_type="+start_area_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&end_area_type="+end_area_type+"&go_ticket_id="+"&from=search_results";
  377. }
  378. }
  379. function goToRemmendInfo(start_id,start_type,end_id,end_type){
  380. var run_date = tempdate;
  381. var listURL='./search_results.html?start_area_id='+start_id
  382. +"&start_area_type="+start_type
  383. +"&end_area_id="+end_id
  384. +"&end_area_type="+end_type
  385. +"&run_date="+run_date;
  386. listURL=encodeURI(listURL);
  387. window.location.href=listURL;
  388. }