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.
 
 
 
 
 

192 lines
5.2 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. window.onload=function(){
  13. //读取缓存
  14. //var search_list=getStorJson('f_wx_search_20160827'); //搜索记录
  15. var start_area_info=getStorJson('f_wx_start_hot_city20160826');//出发地
  16. var end_area_info=getStorJson('f_wx_end_hot_city20160826'); //目的地
  17. run_date=getPar('run_date'); //出发日期
  18. var run_date_str=getPar('run_date_str'); //出发日期eg 8月21日
  19. // 有目的地
  20. if(start_area_info){
  21. start_area_id=start_area_info['area_id'];
  22. start_area_name=start_area_info['area_name'];
  23. start_area_type=start_area_info['area_type'];
  24. }
  25. // 有出发地
  26. if(end_area_info){
  27. end_area_id=end_area_info['area_id'];
  28. end_area_name=end_area_info['area_name'];
  29. end_area_type=end_area_info['area_type'];
  30. }
  31. //出发日期
  32. if(run_date){
  33. $('#run_date').text(run_date_str);
  34. }else{
  35. var cur_date_m_d=getDateTime(0);
  36. cur_date_m_d=cur_date_m_d.substring(5);
  37. cur_date_m_d=cur_date_m_d.replace('-','月');
  38. cur_date_m_d=cur_date_m_d+'日';
  39. run_date=getDateTime(0);
  40. $('#run_date').text(cur_date_m_d);
  41. }
  42. //zhangsq
  43. var year = getMonthAndDayByDate(run_date,'year');
  44. var month = getMonthAndDayByDate(run_date,'month');
  45. var day = getMonthAndDayByDate(run_date,'day');
  46. var str = year+ '/' +month +'/'+day;
  47. var week = getWeekDay(str);
  48. //zhangsq end
  49. $('#run_day').text(run_date==getDateTime(0)?'今天':week);
  50. //判断选择的日期是否是当前日期
  51. // $('#run_day').text(run_date==getDateTime(0)?'今天':"");
  52. if(start_area_id!=""){
  53. $('#start_area').text(start_area_name);
  54. $('#start_area').removeClass('lightgray_color');
  55. }
  56. if(end_area_id!=""){
  57. $('#end_area').text(end_area_name);
  58. $('#end_area').removeClass('lightgray_color');
  59. }
  60. }
  61. //点击事件
  62. $(document).ready(function(){
  63. //点击出发地
  64. $('#start_area').click(function(){
  65. var tt=getDateTime(4);
  66. // 跳转前将URL编码
  67. var listURL='hot_city_new.html?op_type=start&his_area_id='+start_area_id+'&tt='+tt;
  68. listURL = encodeURI(listURL);
  69. window.location.href=listURL;
  70. });
  71. //点击目的地
  72. $('#end_area').click(function(){
  73. var tt=getDateTime(4);
  74. // 跳转前将URL编码
  75. var listURL='hot_city_new.html?op_type=end&his_area_id='+end_area_id+'&tt='+tt;
  76. listURL = encodeURI(listURL);
  77. window.location.href=listURL;
  78. });
  79. //选择日期
  80. $('#sel_data').click(function(){
  81. var tt=getDateTime(4);
  82. var listURL='calendar.html?from=travel_book&tt='+tt;
  83. // 跳转前将URL编码
  84. listURL = encodeURI(listURL);
  85. window.location.href=listURL;
  86. });
  87. //点击交换
  88. $('.exchange').click(function(){
  89. var temp_id=start_area_id;
  90. var temp_name=start_area_name;
  91. var temp_type=start_area_type;
  92. start_area_id=end_area_id;
  93. start_area_name=end_area_name;
  94. start_area_type=end_area_type;
  95. end_area_id=temp_id;
  96. end_area_name=temp_name;
  97. end_area_type=temp_type;
  98. $('#start_area').text(start_area_name);
  99. $('#end_area').text(end_area_name);
  100. if(start_area_name!="请输入出发地"&&start_area_name!="请输入目的地"){
  101. $('#start_area').removeClass('lightgray_color');
  102. }else{
  103. $('#start_area').addClass('lightgray_color');
  104. }
  105. if(end_area_name!="请输入目的地"&&end_area_name!="请输入出发地"){
  106. $('#end_area').removeClass('lightgray_color');
  107. }else{
  108. $('#end_area').addClass('lightgray_color');
  109. }
  110. });
  111. //点击查询
  112. $('#btn_search').click(function(){
  113. //判断日期非空
  114. if(run_date=="" || start_area_id=="" || end_area_id==""){
  115. alert('请填写完整!!!');
  116. return;
  117. }
  118. //清空缓存
  119. clearStorage('f_wx_start_hot_city');
  120. clearStorage('f_wx_end_hot_city');
  121. var tt=getDateTime(4);
  122. var listURL='search_results.html?start_area_id='+start_area_id
  123. +"&start_area_type="+start_area_type
  124. +"&end_area_id="+end_area_id
  125. +"&end_area_type="+end_area_type
  126. +"&run_date="+run_date
  127. +"&tt="+tt;
  128. listURL=encodeURI(listURL);
  129. window.location.href=listURL;
  130. });
  131. $('.btn_Recommend').click(function(){
  132. start_area_id = $(this).attr("start_area_id");
  133. start_area_type = $(this).attr("type");
  134. end_area_id = $(this).attr("end_area_id");
  135. end_area_type = $(this).attr("type");
  136. var tomorrow = parseInt(getMonthAndDayByDate(run_date,'day'))+1;
  137. run_date = getMonthAndDayByDate(run_date,'year') +'-'+ getMonthAndDayByDate(run_date,'month') +'-'+ tomorrow;
  138. var tt=getDateTime(4);
  139. var listURL='search_results.html?start_area_id='+start_area_id
  140. +"&start_area_type="+start_area_type
  141. +"&end_area_id="+end_area_id
  142. +"&end_area_type="+end_area_type
  143. +"&run_date="+run_date
  144. +"&tt="+tt;
  145. listURL=encodeURI(listURL);
  146. window.location.href=listURL;
  147. });
  148. })
  149. // 是否存在相同的
  150. function is_exists(all_arr,dict){
  151. var flag=false;
  152. for (var i=0,m=all_arr.length;i<m;i++) {
  153. var temp=all_arr[i];
  154. if((temp['start_area_id']==dict['start_area_id'] && temp['start_area_type']==dict['start_area_type'])
  155. && temp['end_area_id']==dict['end_area_id'] && temp['end_area_type']==dict['end_area_type']){
  156. flag=true;
  157. break;
  158. }
  159. }
  160. return flag;
  161. }