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.
 
 
 
 
 
 

522 lines
16 KiB

  1. //Author:fuhc
  2. //Date:20160826
  3. //Description:出行预订
  4. var start_area_name="请选择出发地";
  5. var start_area_id="";
  6. var start_area_type="";
  7. var end_area_name="请选择目的地";
  8. var end_area_id="";
  9. var end_area_type="";
  10. var run_date="";
  11. //获取头部切换信息
  12. var top_cut = getStorage("top_cut");
  13. //获取城际直通车出发地目的地
  14. var start_city_id = getStorage("start_city_id");
  15. //获取奔驰专线出发地目的地
  16. var start_benz_id = getStorage("start_benz_id");
  17. //线路类型
  18. var line_type = getStorage("line_type");
  19. //读取缓存
  20. var start_area_info=getStorJson('f_wx_start_hot_city20160826');//出发地
  21. var end_area_info=getStorJson('f_wx_end_hot_city20160826'); //目的地
  22. //$("#loading_html").show();
  23. //页面加载
  24. window.onload=function(){
  25. $("#body_html").show();
  26. baseInfo();
  27. if(top_cut == null){
  28. top_cut = 0;
  29. }
  30. if(start_city_id == null){
  31. start_city_id = 0;
  32. }
  33. if(start_benz_id == null){
  34. start_benz_id = 0;
  35. }
  36. if(line_type == null){
  37. line_type = 0;
  38. }
  39. cut_bus_load(top_cut);
  40. run_date=getPar('run_date'); //出发日期
  41. var run_date_str=getPar('run_date_str'); //出发日期eg 8月21日
  42. // 有目的地
  43. if(start_area_info){
  44. start_area_id=start_area_info['area_id'];
  45. start_area_name=start_area_info['area_name'];
  46. start_area_type=start_area_info['area_type'];
  47. }
  48. // 有出发地
  49. if(end_area_info){
  50. end_area_id=end_area_info['area_id'];
  51. end_area_name=end_area_info['area_name'];
  52. end_area_type=end_area_info['area_type'];
  53. }
  54. //出发日期
  55. if(run_date){
  56. $('#run_date').text(run_date_str);
  57. }else{
  58. // var cur_date_m_d=getDateTime(0);
  59. var cur_date_m_d = after(getDateTime(0));
  60. cur_date_m_d=cur_date_m_d.substring(5);
  61. cur_date_m_d=cur_date_m_d.replace('-','月');
  62. cur_date_m_d=cur_date_m_d+'日';
  63. run_date=after(getDateTime(0));
  64. $('#run_date').text(cur_date_m_d);
  65. }
  66. //zhangsq
  67. var year = getMonthAndDayByDate(run_date,'year');
  68. var month = getMonthAndDayByDate(run_date,'month');
  69. var day = getMonthAndDayByDate(run_date,'day');
  70. var str = year+ '/' +month +'/'+day;
  71. var week = getWeekDay(str);
  72. //zhangsq end
  73. $('#run_day').text(run_date==getDateTime(0)?'今天':week);
  74. //判断选择的日期是否是当前日期
  75. // $('#run_day').text(run_date==getDateTime(0)?'今天':"");
  76. //有缓存就进去
  77. if(start_area_id!=""){
  78. $('#start_area').text(start_area_name);
  79. $('#start_area').removeClass('lightgray_color');
  80. }
  81. if(end_area_id!=""){
  82. $('#end_area').text(end_area_name);
  83. $('#end_area').removeClass('lightgray_color');
  84. }
  85. // $("#loading_html").show();
  86. }
  87. //点击事件
  88. $(document).ready(function(){
  89. //点击出发地
  90. $('#start_area').click(function(){
  91. var tt=getDateTime(4);
  92. // 跳转前将URL编码
  93. var listURL='hot_city.html?from=travel_book&poi_type=&op_type=in&tt='+tt+'&station_id='+''+'&line_type='+line_type;
  94. listURL = encodeURI(listURL);
  95. window.location.href=listURL;
  96. });
  97. //点击目的地
  98. $('#end_area').click(function(){
  99. var tt=getDateTime(4);
  100. // 跳转前将URL编码
  101. var listURL='hot_city.html?from=travel_book&poi_type=&op_type=out&tt='+tt+'&station_id='+start_area_id+'&line_type='+line_type;
  102. listURL = encodeURI(listURL);
  103. window.location.href=listURL;
  104. });
  105. //选择日期
  106. $('#sel_data').click(function(){
  107. var tt=getDateTime(4);
  108. var listURL='calendar.html?from=travel_book&tt='+tt;
  109. // 跳转前将URL编码
  110. listURL = encodeURI(listURL);
  111. window.location.href=listURL;
  112. });
  113. //点击交换
  114. $('.exchange').click(function(){
  115. if(start_area_name=="请选择出发地"||end_area_name=="请选择目的地"){
  116. return;
  117. }else{
  118. // 有出发地缓存
  119. if(start_area_info){
  120. var data = {
  121. op_type: "in",
  122. area_id: end_area_id,
  123. area_name: end_area_name
  124. };
  125. setStorJson('f_wx_start_hot_city20160826', data);
  126. }
  127. // 有目的地缓存
  128. if(end_area_info){
  129. var data = {
  130. op_type: "out",
  131. area_id: start_area_id,
  132. area_name: start_area_name
  133. };
  134. setStorJson('f_wx_end_hot_city20160826', data);
  135. }
  136. var temp_id=start_area_id;
  137. var temp_name=start_area_name;
  138. var temp_type=start_area_type;
  139. start_area_id=end_area_id;
  140. start_area_name=end_area_name;
  141. start_area_type=end_area_type;
  142. end_area_id=temp_id;
  143. end_area_name=temp_name;
  144. end_area_type=temp_type;
  145. $('#start_area').text(start_area_name);
  146. $('#end_area').text(end_area_name);
  147. if(start_area_name!="请选择出发地"&&start_area_name!="请选择目的地"){
  148. $('#start_area').removeClass('lightgray_color');
  149. }else{
  150. $('#start_area').addClass('lightgray_color');
  151. }
  152. if(end_area_name!="请选择目的地"&&end_area_name!="请选择出发地"){
  153. $('#end_area').removeClass('lightgray_color');
  154. }else{
  155. $('#end_area').addClass('lightgray_color');
  156. }
  157. }
  158. });
  159. //点击查询
  160. $('#btn_search').click(function(){
  161. //判断日期非空
  162. if(run_date=="" || start_area_id=="" || end_area_id==""){
  163. alert('请选择出发地或目的地!');
  164. return;
  165. }
  166. //清空缓存
  167. clearStorage('f_wx_start_hot_city');
  168. clearStorage('f_wx_end_hot_city');
  169. var tt=getDateTime(4);
  170. var listURL='search_results.html?start_area_id='+start_area_id
  171. +"&end_area_id="+end_area_id
  172. +"&if_go=go"
  173. +"&run_date="+run_date;
  174. listURL=encodeURI(listURL);
  175. window.location.href=listURL;
  176. });
  177. $('.btn_Recommend').click(function(){
  178. start_area_id = $(this).attr("start_area_id");
  179. start_area_type = $(this).attr("type");
  180. end_area_id = $(this).attr("end_area_id");
  181. end_area_type = $(this).attr("type");
  182. var tomorrow = parseInt(getMonthAndDayByDate(run_date,'day'))+1;
  183. run_date = GetDateStr(1);
  184. var tt=getDateTime(4);
  185. var listURL='search_results.html?start_area_id='+start_area_id
  186. +"&start_area_type="+start_area_type
  187. +"&end_area_id="+end_area_id
  188. +"&end_area_type="+end_area_type
  189. +"&run_date="+run_date
  190. +"&tt="+tt;
  191. listURL=encodeURI(listURL);
  192. window.location.href=listURL;
  193. });
  194. })
  195. //头部切换
  196. function cut_bus(index){
  197. //切欢时清缓存信息、变样式
  198. clearStorage("f_wx_end_hot_city20160826");
  199. clearStorage("f_wx_start_hot_city20160826");
  200. $('#start_area').text("请选择出发地");
  201. $('#start_area').addClass('lightgray_color');
  202. $('#end_area').text("请选择目的地");
  203. $('#end_area').addClass('lightgray_color');
  204. start_area_name = "请选择出发地";
  205. start_area_id = "";
  206. end_area_name = "请选择目的地";
  207. end_area_id = "";
  208. $(".cut_top").children().addClass("cut_top_hide");
  209. $(".cut_top").children().removeClass("cut_top_show");
  210. $("#cut_"+index).removeClass("cut_top_hide");
  211. $("#cut_"+index).addClass("cut_top_show");
  212. $("#bus_station").children().hide();
  213. $(".cut_bus"+index).show();
  214. top_cut = index;
  215. line_type = $("#cut_"+index).attr("line_type");
  216. setStorage("top_cut",top_cut);
  217. setStorage("line_type",line_type);
  218. }
  219. function cut_bus_load(index){
  220. $(".cut_top").children().addClass("cut_top_hide");
  221. $(".cut_top").children().removeClass("cut_top_show");
  222. $("#cut_"+index).removeClass("cut_top_hide");
  223. $("#cut_"+index).addClass("cut_top_show");
  224. $("#bus_station").children().hide();
  225. $(".cut_bus"+index).show();
  226. top_cut = index;
  227. line_type = $("#cut_"+index).attr("line_type");
  228. setStorage("top_cut",top_cut);
  229. setStorage("line_type",line_type);
  230. }
  231. // 是否存在相同的
  232. function is_exists(all_arr,dict){
  233. var flag=false;
  234. for (var i=0,m=all_arr.length;i<m;i++) {
  235. var temp=all_arr[i];
  236. if((temp['start_area_id']==dict['start_area_id'] && temp['start_area_type']==dict['start_area_type'])
  237. && temp['end_area_id']==dict['end_area_id'] && temp['end_area_type']==dict['end_area_type']){
  238. flag=true;
  239. break;
  240. }
  241. }
  242. return flag;
  243. }
  244. function GetDateStr(AddDayCount) {
  245. var dd = new Date();
  246. dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
  247. var y = dd.getFullYear();
  248. var m = dd.getMonth()+1;//获取当前月份的日期
  249. var d = dd.getDate();
  250. return y+"-"+m+"-"+d;
  251. }
  252. //切换城际直通车出发地、目的地
  253. //function change_city_bus(){
  254. // var start_add = $("#city_bus_0").text();
  255. // var end_add = $("#city_bus_1").text();
  256. // $("#city_bus_0").text(end_add);
  257. // $("#city_bus_1").text(start_add);
  258. // if($("#city_bus_0").text()=="上海"){
  259. // start_city_id = 0;
  260. // }else if($("#city_bus_0").text()=="杭州"){
  261. // start_city_id = 1;
  262. // }
  263. // setStorage("start_city_id",start_city_id);
  264. //}
  265. //获取城际直通车出发地、目的地
  266. //function get_city_bus(index){
  267. // var start_add = $("#city_bus_0").text();
  268. // var end_add = $("#city_bus_1").text();
  269. // if(index == 0){
  270. // $("#city_bus_0").text(start_add);
  271. // $("#city_bus_1").text(end_add);
  272. // }else if(index == 1){
  273. // $("#city_bus_0").text(end_add);
  274. // $("#city_bus_1").text(start_add);
  275. // }
  276. //
  277. //
  278. //}
  279. //切换奔驰专线出发地、目的地
  280. //function change_benz_bus(){
  281. // var start_add = $("#benz_bus_0").text();
  282. // var end_add = $("#benz_bus_1").text();
  283. // $("#benz_bus_0").text(end_add);
  284. // $("#benz_bus_1").text(start_add);
  285. // if($("#benz_bus_0").text()=="南京"){
  286. // start_benz_id = 0;
  287. // }else if($("#benz_bus_0").text()=="淮安"){
  288. // start_benz_id = 1;
  289. // }
  290. // setStorage("start_benz_id",start_benz_id);
  291. //}
  292. //获取城际直通车出发地、目的地
  293. //function get_benz_bus(index){
  294. // var start_add = $("#benz_bus_0").text();
  295. // var end_add = $("#benz_bus_1").text();
  296. // if(index == 0){
  297. // $("#benz_bus_0").text(start_add);
  298. // $("#benz_bus_1").text(end_add);
  299. // }else if(index == 1){
  300. // $("#benz_bus_0").text(end_add);
  301. // $("#benz_bus_1").text(start_add);
  302. // }
  303. //
  304. //
  305. //}
  306. function baseInfo(){
  307. var param = {
  308. }
  309. ZZLog(base_api + "trip/index&" + JSON.stringify(param));
  310. $.ajax({
  311. type: "post",
  312. url: base_api + "trip/index",
  313. data: param,
  314. dataType: 'json',
  315. success: function(res_data) {
  316. ZZLog(res_data);
  317. if(res_data.flag == true) {
  318. base_html(res_data.data);
  319. } else {
  320. alert(res_data.mag);
  321. }
  322. },
  323. error: function(e) {
  324. ZZLog(e);
  325. }
  326. });
  327. }
  328. //替换首页基础信息
  329. function base_html(data){
  330. var temp_lunbo = "";
  331. var temp_dsn = "";
  332. var temp_dsn = "";
  333. var temp_through = "";
  334. var temp_rim = "";
  335. //轮播
  336. for(var i=0,j=data.recomList.length;i<j;i++){
  337. var str = data.recomList[i].toUrl;
  338. temp_lunbo += '<div class="swiper-slide"><img class="urlurl" style="width: 100%;" src="'+pic_api+data.recomList[i].img+'"; to_url="'+str+'"/></div>'
  339. }
  340. $(".swiper-wrapper").html(temp_lunbo);
  341. $('.urlurl').click(function(){
  342. var urlstr = $(this).attr('to_url');
  343. window.location.href = urlstr;
  344. })
  345. //迪士尼穿梭
  346. for(var i=0,j=data.dsn.length;i<j;i++){
  347. temp_dsn += '<li class="ub disney_bus ui_p_a20 inner_up_line_color" onclick="disneyDidClicked('+data.dsn[i].start_id+','+data.dsn[i].end_id+')">'
  348. + '<div style="width:1%" class="ub ub-f1 ub-ver text_right">'
  349. + '<div style="font-size: 0.11rem;" class="commongray_color">全程用时</div>'
  350. + '<div class="fontmiddle_color">'+data.dsn[i].bus_time+'</div>'
  351. + '</div>'
  352. + '<img style="height: 0.35rem;margin-top: 0.04rem;" class="ui_p_r05 ui_p_l05" src="images/img_points@2x.png"/>'
  353. + '<div style="width:1%" class="ub ub-f4 ub-ver">'
  354. + '<div style="margin-top:-0.03rem" class="lightblack_color ulev1">'+data.dsn[i].dsnstart+'</div>'
  355. + '<div style="margin-top: 0.1rem;" class="lightblack_color ulev1">'+data.dsn[i].dsnend+'</div>'
  356. + '</div>'
  357. + '<div style="top: 0.15rem; class="ub ub-pe ub-ver">'
  358. + '<span class="ulev1" style="color:#519d9e;">¥</span>'
  359. + '<span style="color:#519d9e;font-size: 0.32rem;">'+parseInt(Math.ceil(data.dsn[i].price))+'</span>'
  360. + '</div>'
  361. + '</li>'
  362. }
  363. $("#dsn_bus").html(temp_dsn);
  364. $('#dsn_bus').show();
  365. //直通巴士
  366. for(var i=0,j=data.scenicList.length;i<j;i++){
  367. temp_through += '<div style="width:1%;" class="ub ub-f1 ub-ver ui_p_l05 ui_p_r05" onclick="aroundDidClicked('+data.scenicList[i].start_id+','+data.scenicList[i].end_id+')">'
  368. + '<div style="background-image: url('+pic_api+data.scenicList[i].img+')" class="scene_direct uc-tl1 uc-tr1 text_right">'
  369. + '<img class="tuijian" style="width: 0.32rem;" src="images/img_jian@2x.png"/>'
  370. + '</div>'
  371. + '<div style="padding:0.08rem;padding-bottom:0.09rem;" class="ub ub-ae tuijian_biankuang uc-bl1 uc-br1">'
  372. + '<div class="ub ub-f1 ub-ver">'
  373. + '<div style="font-size: 0.1rem;padding-left:0.01rem;" class="commongray_color">全程'+data.scenicList[i].bus_time+'</div>'
  374. + '<div class="white_color darkgreen_color bus_type">'+data.scenicList[i].car_type+'</div>'
  375. + '</div>'
  376. + '<div style="top:0.02rem;"><span class="price_color">¥</span><span style="font-size:0.21rem;" class="price_color">'+parseInt(Math.ceil(data.scenicList[i].price))+'</span></div>'
  377. + '</div>'
  378. + '</div>'
  379. }
  380. $("#through_bus").html(temp_through);
  381. $('#through_bus').show();
  382. //周边游
  383. for(var i=0,j=data.rimList.length;i<j;i++){
  384. var str = '';
  385. switch (data.rimList[i].type){
  386. case '372':
  387. str = 'images/img-zhitongbashi.png';
  388. break;
  389. case '370':
  390. str = 'images/img-chejing.png';
  391. break;
  392. case '376':
  393. str = 'images/img-bashi.png';
  394. break;
  395. case '371':
  396. str = 'images/img-chejiu.png';
  397. break;
  398. default:
  399. break;
  400. }
  401. temp_rim += '<li onclick="rimDidClicked('+data.rimList[i].pro_id+')" travel_type="'+data.rimList[i].type+'" style="background-image: url('+pic_api+data.rimList[i].img+');height: 1.3rem;border-radius: 0.05rem;" class="ub rim_travel ui_m_l10 ui_m_r10 ui_m_b10 ui_m_r10 ui_m_b10 ub-ver ub-pe">'
  402. + '<img style="height: 0.17rem;position: absolute;top: 0.1rem;" src="'+str+'"/>'
  403. + '<div style="background-color: rgba(0, 0, 0, 0.5);padding-top: 0.06rem;padding-bottom: 0.08rem;padding-right: 0.08rem;padding-left: 0.08rem;border-radius: 0.05rem;" class="ub ub-pe uc-bl1 uc-br1">'
  404. + '<div class="ub-f1 ub ub-ver">'
  405. + '<div style="opacity: 0.8;" class="ulev2 white_color">'+data.rimList[i].zname+'</div>'
  406. + '<div style="font-size: 0.11rem;opacity: 0.8;" class="white_color">'+data.rimList[i].tickdes+' </div>'
  407. + '</div>'
  408. + '<div class="ub ub-ae">'
  409. + '<span style="font-size: 0.11rem;opacity: 0.8;" class="white_color">¥</span>'
  410. + '<span style="opacity: 0.8;" class="white_color ulev5">'+parseInt(Math.ceil(data.rimList[i].price))+'</span>'
  411. + '</div>'
  412. + '</div>'
  413. + '</li>'
  414. }
  415. $("#rim_travel").html(temp_rim);
  416. $('#rim_travel').show();
  417. $("#loading_html").show();
  418. //轮播空间swiper
  419. var swiper = new Swiper('.swiper-container', {
  420. loop : true,
  421. paginationClickable: true,
  422. centeredSlides: true,
  423. autoplay : 2000,
  424. autoplayDisableOnInteraction : false
  425. });
  426. //轮播点击事件
  427. // function go_ticket(){
  428. // window.location.href="disney_bus.html";
  429. // }
  430. // function go_picture(){
  431. // window.location.href="search_bus.html";
  432. // }
  433. }
  434. function around_travel(){
  435. //MtaH5.clickStat('test0001');
  436. window.location.href="trave_around_main.html";
  437. }
  438. function dsn_travel(){
  439. //MtaH5.clickStat('test0001');
  440. window.location.href="disney_tranship.html";
  441. }
  442. function plane_travel(){
  443. //MtaH5.clickStat('test0001');
  444. window.location.href="pick_drop_person.html";
  445. }
  446. //景区直通点击 跳转列表页面
  447. function aroundDidClicked(start_id,end_id){
  448. var run_date = after(getDateTime(0));
  449. window.location.href = './search_results.html?start_area_id='+start_id+'&end_area_id='+end_id+'&ifgo=go'+'&run_date='+run_date;
  450. }
  451. //周边游点击 跳转详情页面
  452. function rimDidClicked(pro_id){
  453. window.location.href = './travel_around_detail.html?pro_id='+pro_id;
  454. }
  455. //迪士尼 跳转列表页面
  456. function disneyDidClicked(start_id,end_id){
  457. var run_date = after(getDateTime(0));
  458. window.location.href = './search_results.html?start_area_id='+start_id+'&end_area_id='+end_id+'&ifgo=go'+'&run_date='+run_date;
  459. }
  460. //跳转活动页面’
  461. function goToProductDetail(toUrl){
  462. window.location.open(toUrl);
  463. }