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.
 
 
 
 
 
 

396 lines
11 KiB

  1. //Author:zhangsq
  2. //Date:20160826
  3. //Description:查询结果
  4. $("#loading_html").show();
  5. var tempdate = '';
  6. //有票种普通
  7. var has_ticketHTML = '';
  8. //有票种奔驰
  9. var has_benzHTML = '';
  10. //无票种普通
  11. var no_ticketHTML = '';
  12. //无票种奔驰
  13. var no_benzHTML = '';
  14. // 去程
  15. var start_area_id = "";
  16. var start_area_type = "";
  17. var end_area_id = "";
  18. var end_area_type = "";
  19. var run_date = "";
  20. var cur_date = '';
  21. var cur_date_str = '';
  22. // 返程
  23. var go_ticket_id="";
  24. // 返程的ticket_id
  25. var back_ticket_ids=new Array();
  26. var no_resultHTMl = '';
  27. var if_go = getPar("if_go");
  28. var get_from = getPar("form");
  29. var pick_drop_person_type = getPar("pick_drop_person_type")
  30. var go_date="";
  31. window.onload = function(){
  32. has_ticketHTML = $('.has_ticket').prop('outerHTML');
  33. has_benzHTML = $('.has_benz').prop('outerHTML');
  34. no_ticketHTML = $('.no_ticket').prop('outerHTML');
  35. no_benzHTML = $('.no_benz').prop('outerHTML');
  36. // has_ticketHTML=no_ticketHTML;
  37. no_resultHTMl = $('#no_no_no').html();
  38. start_area_id = getPar('start_area_id');
  39. start_area_type = getPar('start_area_type');
  40. end_area_id = getPar('end_area_id');
  41. end_area_type = getPar('end_area_type');
  42. run_date = getPar('run_date')!=""?getPar('run_date'):getPar('go_date');
  43. //zsq
  44. var date_str = getPar('run_date');
  45. if (date_str != '' ) {
  46. run_date = date_str;
  47. }
  48. if (date_str == 'ad') {
  49. run_date = after(getDateTime(0));
  50. // getDateTime(0);
  51. }
  52. console.log(run_date);
  53. //zsq end
  54. tempdate = run_date;
  55. var nowdate = getDateTime(0);
  56. var month = getMonthAndDayByDate(run_date,'month');
  57. var day = getMonthAndDayByDate(run_date,'day');
  58. if (tempdate==nowdate) {
  59. $('#show_date').html(month+'月'+day+'日');
  60. $('#left').removeClass('fontgreen_color');
  61. $('#left').addClass('commongray_color');
  62. $('#left').removeAttr('onclick');
  63. $('#left_img').attr('src','images/a2/ic_return_d.png');
  64. } else{
  65. $('#show_date').html(month+'月'+day+'日');
  66. $('#left').removeClass('commongray_color');
  67. $('#left').addClass('fontgreen_color');
  68. $('#left').attr('onclick','leftDidClicked();');
  69. $('#left_img').attr('src','images/a2/ic_return_n_l.png');
  70. }
  71. go_date=getPar('go_date');
  72. go_ticket_id=getPar('go_ticket_id');
  73. if(go_ticket_id==""){ //去程
  74. //清除填写订单的四个缓存
  75. clearStorage('CacheInfo_people');
  76. clearStorage('CacheInfo_station');
  77. clearStorage('go_data');
  78. clearStorage('back_data');
  79. ZZLog('clearStorage');
  80. go_list();
  81. }else{ // 返程
  82. back_list();
  83. }
  84. }
  85. //点击了 前一天
  86. function leftDidClicked(){
  87. var nowdate = tempdate;
  88. var run_date = before(nowdate);
  89. tempdate = run_date;
  90. var nowdate = getDateTime(0);
  91. var month = getMonthAndDayByDate(run_date,'month');
  92. var day = getMonthAndDayByDate(run_date,'day');
  93. if (tempdate==nowdate) {
  94. $('#show_date').html(month+'月'+day+'日');
  95. $('#left').removeClass('fontgreen_color');
  96. $('#left').addClass('commongray_color');
  97. $('#left').removeAttr('onclick');
  98. $('#left_img').attr('src','images/a2/ic_return_d.png');
  99. } else{
  100. $('#show_date').html(month+'月'+day+'日');
  101. $('#left').removeClass('commongray_color');
  102. $('#left').addClass('fontgreen_color');
  103. $('#left').attr('onclick','leftDidClicked();');
  104. $('#left_img').attr('src','images/a2/ic_return_n_l.png');
  105. }
  106. go_ticket_id=getPar('go_ticket_id');
  107. if(go_ticket_id==""){ //去程
  108. go_list();
  109. }else{ // 返程
  110. back_list();
  111. }
  112. }
  113. //点击了后一天
  114. function rightDidClicked(){
  115. var nowdate = tempdate;
  116. var run_date = after(nowdate);
  117. tempdate = run_date;
  118. var nowdate = getDateTime(0);
  119. var month = getMonthAndDayByDate(run_date,'month');
  120. var day = getMonthAndDayByDate(run_date,'day');
  121. if (tempdate==nowdate) {
  122. $('#show_date').html(month+'月'+day+'日');
  123. $('#left').removeClass('fontgreen_color');
  124. $('#left').addClass('commongray_color');
  125. $('#left').removeAttr('onclick');
  126. $('#left_img').attr('src','images/a2/ic_return_d.png');
  127. } else{
  128. $('#show_date').html(month+'月'+day+'日');
  129. $('#left').removeClass('commongray_color');
  130. $('#left').addClass('fontgreen_color');
  131. $('#left').attr('onclick','leftDidClicked();');
  132. $('#left_img').attr('src','images/a2/ic_return_n_l.png');
  133. }
  134. go_ticket_id=getPar('go_ticket_id');
  135. if(go_ticket_id==""){ //去程
  136. go_list();
  137. }else{ // 返程
  138. back_list();
  139. }
  140. // var start_area_id = getPar('start_area_id');
  141. // var start_area_type = getPar('start_area_type');
  142. // var end_area_id = getPar('end_area_id');
  143. // var end_area_type = getPar('end_area_type');
  144. //
  145. }
  146. // go 去程
  147. function go_list(){
  148. //转圈圈
  149. //$("#loadingToast").show();
  150. var url=base_api+"runs/getRunsList";
  151. var parm={
  152. start_area_id:start_area_id,
  153. end_area_id:end_area_id,
  154. run_date:tempdate,
  155. is_recommend:1
  156. }
  157. ZZLog(url+JSON.stringify(parm));
  158. $.post(url,parm,function(res_data){
  159. res_data=JSON.parse(res_data);
  160. console.log(res_data);
  161. if (res_data.flag == true) {
  162. if (res_data.data.common_list.length > 0) {
  163. $('#detailInfo').removeClass('ui_hide');
  164. $('#no_result').addClass('ui_hide');
  165. reloadData(res_data.data.common_list);
  166. }
  167. // else if(res_data.select_type == "tomorrow_normal"){
  168. // $('#detailInfo').addClass('ui_hide');
  169. // $('#no_result').removeClass('ui_hide');
  170. // $('#tomorrow').html('今日没有匹配的车次');
  171. // $('#tomorrow_new').html('请更换日期查询');
  172. // $('#no').addClass('ui_hide');
  173. //
  174. // }
  175. else{
  176. recommendInfo(res_data.data.recommend_list);
  177. //TODO 进入隐藏
  178. $('#detailInfo').addClass('ui_hide');
  179. $('#no_result').removeClass('ui_hide');
  180. }
  181. } else{
  182. alert(res_data.msg);
  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].total_time);
  200. tempHTML = tempHTML.replace('remmend_ticket','remmend_ticket'+i);
  201. tempHTML=tempHTML.replace('[start_area_id]',list[i].start_area_id);
  202. tempHTML=tempHTML.replace('[end_area_id]',list[i].end_area_id);
  203. tempHTML=tempHTML.replace('[run_id]',list[i].run_id);
  204. tempHTML=tempHTML.replace('[line_type]',list[i].line_type);
  205. tempHTML=tempHTML.replace('[air_type]',list[i].air_type);
  206. newHTML += tempHTML;
  207. }
  208. $('#no_no_no').html(newHTML);
  209. $(".tuijian").click(function(){
  210. var end_area_id = $(this).attr("end_area_id");
  211. var start_area_id = $(this).attr("start_area_id");
  212. var line_type = $(this).attr("line_type");
  213. var air_type = $(this).attr("air_type");
  214. var run_id = $(this).attr("run_id");
  215. if(line_type == "380"){
  216. clearStorage("CacheStationInfo_Go");
  217. clearStorage("CacheStationInfo_Back");
  218. window.location.href="pick_drop_fill_order.html?air_type="+air_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&run_id="+run_id+"&if_go=go";
  219. }else{
  220. if(if_go=="back"){
  221. clearStorage("CacheStationInfo_Back");
  222. window.location.href="fill_order.html?start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&run_id="+run_id+"&if_go=back";
  223. }else{
  224. clearStorage("CacheStationInfo_Go");
  225. clearStorage("CacheStationInfo_Back");
  226. window.location.href="fill_order.html?start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&run_id="+run_id+"&if_go=go";
  227. }
  228. }
  229. });
  230. }
  231. }
  232. //加载数据
  233. function reloadData(data){
  234. var list = data;
  235. var tempHTML = '';
  236. var newHTML = ''
  237. for(var i=0;i<list.length;i++){
  238. // TODO 奔驰车有票无票样式 has_ticketHTML has_benzHTML no_ticketHTML no_benzHTML
  239. if (list[i].stock > 0) {
  240. tempHTML = has_ticketHTML;
  241. } else{
  242. tempHTML = no_ticketHTML;
  243. }
  244. tempHTML=tempHTML.replace('[出发地]',list[i].start_area_name);
  245. tempHTML=tempHTML.replace('[目的地]',list[i].end_area_name);
  246. tempHTML=tempHTML.replace('[时间]',list[i].run_time);
  247. tempHTML=tempHTML.replace('[价格]',parseInt(list[i].price));
  248. tempHTML=tempHTML.replace('[全程用时]',list[i].total_time);
  249. tempHTML=tempHTML.replace('[start_area_id]',list[i].start_area_id);
  250. tempHTML=tempHTML.replace('[end_area_id]',list[i].end_area_id);
  251. tempHTML=tempHTML.replace('[run_id]',list[i].run_id);
  252. tempHTML=tempHTML.replace('[line_type]',list[i].line_type);
  253. tempHTML=tempHTML.replace('[air_type]',list[i].air_type);
  254. newHTML+=tempHTML;
  255. }
  256. $('#detailInfo').html(newHTML);
  257. $(".disney_bus").click(function(){
  258. var end_area_id = $(this).attr("end_area_id");
  259. var start_area_id = $(this).attr("start_area_id");
  260. var line_type = $(this).attr("line_type");
  261. var air_type = $(this).attr("air_type");
  262. var run_id = $(this).attr("run_id");
  263. if(line_type == "380"){
  264. clearStorage("CacheStationInfo_Go");
  265. clearStorage("CacheStationInfo_Back");
  266. window.location.href="pick_drop_fill_order.html?air_type="+air_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&run_id="+run_id+"&if_go=go";
  267. }else{
  268. if(if_go=="back"){
  269. clearStorage("CacheStationInfo_Back");
  270. window.location.href="fill_order.html?start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&run_id="+run_id+"&if_go=back";
  271. }else{
  272. clearStorage("CacheStationInfo_Go");
  273. clearStorage("CacheStationInfo_Back");
  274. window.location.href="fill_order.html?start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&run_id="+run_id+"&if_go=go";
  275. }
  276. }
  277. });
  278. $('#detailInfo').show();
  279. }
  280. //获取前一天日期
  281. function before(d){
  282. d = new Date(d);
  283. d = +d - 1000*60*60*24;
  284. d = new Date(d);
  285. //return d;
  286. //格式化
  287. var year = ";" + d.getFullYear() + ";";
  288. var month = ";" + (d.getMonth()+0+1) + ";";
  289. var day = ";" + d.getDate() + ";";
  290. if(year.length < 4) {
  291. year = "0" + year;
  292. }
  293. if(month.length < 4) {
  294. month = "0" + month;
  295. }
  296. if(day.length < 4) {
  297. day = "0" + day;
  298. }
  299. var datestr = year + "-" + month + "-" + day;
  300. datestr = datestr.replace(/;/g, "");
  301. return datestr;
  302. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  303. }
  304. //获取后一天日期
  305. function after(d){
  306. d = new Date(d);
  307. d = +d + 1000*60*60*24;
  308. d = new Date(d);
  309. //return d;
  310. //格式化
  311. var year = ";" + d.getFullYear() + ";";
  312. var month = ";" + (d.getMonth()+0+1) + ";";
  313. var day = ";" + d.getDate() + ";";
  314. if(year.length < 4) {
  315. year = "0" + year;
  316. }
  317. if(month.length < 4) {
  318. month = "0" + month;
  319. }
  320. if(day.length < 4) {
  321. day = "0" + day;
  322. }
  323. var datestr = year + "-" + month + "-" + day;
  324. datestr = datestr.replace(/;/g, "");
  325. return datestr;
  326. // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
  327. }
  328. function getMonthAndDayByDate(datestr,info){
  329. var dateAry = datestr.split('-');
  330. var cNewTimeStr;
  331. switch(info){
  332. case 'year':
  333. cNewTimeStr = dateAry[0];
  334. break;
  335. case 'month':
  336. cNewTimeStr = dateAry[1];
  337. break;
  338. default:
  339. cNewTimeStr = dateAry[2];
  340. break;
  341. }
  342. return cNewTimeStr;
  343. }
  344. //日历点击事件
  345. function selectCalander(){
  346. window.location.href = "./calendar.html?run_date="+run_date+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&if_go="+if_go+"&from=search_results"+"&go_run_date="+getPar('go_run_date');
  347. }