|
- //Author:fuhc
- //Date:20160826
- //Description:出行预订
-
-
-
-
-
-
- var start_area_name="请输入出发地";
- var start_area_id="";
- var start_area_type="";
-
- var end_area_name="请输入目的地";
- var end_area_id="";
- var end_area_type="";
- var run_date="";
-
- //页面加载
- window.onload=function(){
-
- //读取缓存
- //var search_list=getStorJson('f_wx_search_20160827'); //搜索记录
-
- var start_area_info=getStorJson('f_wx_start_hot_city20160826');//出发地
- var end_area_info=getStorJson('f_wx_end_hot_city20160826'); //目的地
- run_date=getPar('run_date'); //出发日期
- var run_date_str=getPar('run_date_str'); //出发日期eg 8月21日
-
-
-
- // 有目的地
- if(start_area_info){
- start_area_id=start_area_info['area_id'];
- start_area_name=start_area_info['area_name'];
- start_area_type=start_area_info['area_type'];
- }
- // 有出发地
- if(end_area_info){
- end_area_id=end_area_info['area_id'];
- end_area_name=end_area_info['area_name'];
- end_area_type=end_area_info['area_type'];
- }
- //出发日期
-
- if(run_date){
- $('#run_date').text(run_date_str);
- }else{
- var cur_date_m_d=getDateTime(0);
- cur_date_m_d=cur_date_m_d.substring(5);
- cur_date_m_d=cur_date_m_d.replace('-','月');
- cur_date_m_d=cur_date_m_d+'日';
- run_date=getDateTime(0);
- $('#run_date').text(cur_date_m_d);
- }
- //zhangsq
- var year = getMonthAndDayByDate(run_date,'year');
- var month = getMonthAndDayByDate(run_date,'month');
- var day = getMonthAndDayByDate(run_date,'day');
- var str = year+ '/' +month +'/'+day;
- var week = getWeekDay(str);
- //zhangsq end
- $('#run_day').text(run_date==getDateTime(0)?'今天':week);
- //判断选择的日期是否是当前日期
- // $('#run_day').text(run_date==getDateTime(0)?'今天':"");
-
-
- if(start_area_id!=""){
- $('#start_area').text(start_area_name);
- $('#start_area').removeClass('lightgray_color');
- }
- if(end_area_id!=""){
- $('#end_area').text(end_area_name);
- $('#end_area').removeClass('lightgray_color');
- }
- }
- //点击事件
- $(document).ready(function(){
- //点击出发地
- $('#start_area').click(function(){
- var tt=getDateTime(4);
- // 跳转前将URL编码
- var listURL='hot_city_new.html?op_type=start&his_area_id='+start_area_id+'&tt='+tt;
- listURL = encodeURI(listURL);
- window.location.href=listURL;
- });
- //点击目的地
- $('#end_area').click(function(){
- var tt=getDateTime(4);
- // 跳转前将URL编码
- var listURL='hot_city_new.html?op_type=end&his_area_id='+end_area_id+'&tt='+tt;
- listURL = encodeURI(listURL);
- window.location.href=listURL;
- });
-
- //选择日期
- $('#sel_data').click(function(){
- var tt=getDateTime(4);
- var listURL='calendar.html?from=travel_book&tt='+tt;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href=listURL;
- });
-
- //点击交换
- $('.exchange').click(function(){
-
- var temp_id=start_area_id;
- var temp_name=start_area_name;
- var temp_type=start_area_type;
-
- start_area_id=end_area_id;
- start_area_name=end_area_name;
- start_area_type=end_area_type;
-
- end_area_id=temp_id;
- end_area_name=temp_name;
- end_area_type=temp_type;
-
- $('#start_area').text(start_area_name);
- $('#end_area').text(end_area_name);
- if(start_area_name!="请输入出发地"&&start_area_name!="请输入目的地"){
- $('#start_area').removeClass('lightgray_color');
- }else{
- $('#start_area').addClass('lightgray_color');
- }
- if(end_area_name!="请输入目的地"&&end_area_name!="请输入出发地"){
- $('#end_area').removeClass('lightgray_color');
- }else{
- $('#end_area').addClass('lightgray_color');
- }
-
- });
-
- //点击查询
- $('#btn_search').click(function(){
-
- //判断日期非空
- if(run_date=="" || start_area_id=="" || end_area_id==""){
- alert('请填写完整!!!');
- return;
- }
-
- //清空缓存
- clearStorage('f_wx_start_hot_city');
- clearStorage('f_wx_end_hot_city');
-
- var tt=getDateTime(4);
- var listURL='search_results.html?start_area_id='+start_area_id
- +"&start_area_type="+start_area_type
- +"&end_area_id="+end_area_id
- +"&end_area_type="+end_area_type
- +"&run_date="+run_date
- +"&tt="+tt;
- listURL=encodeURI(listURL);
- window.location.href=listURL;
-
- });
-
- $('.btn_Recommend').click(function(){
- start_area_id = $(this).attr("start_area_id");
- start_area_type = $(this).attr("type");
- end_area_id = $(this).attr("end_area_id");
- end_area_type = $(this).attr("type");
- var tomorrow = parseInt(getMonthAndDayByDate(run_date,'day'))+1;
- run_date = getMonthAndDayByDate(run_date,'year') +'-'+ getMonthAndDayByDate(run_date,'month') +'-'+ tomorrow;
- var tt=getDateTime(4);
- var listURL='search_results.html?start_area_id='+start_area_id
- +"&start_area_type="+start_area_type
- +"&end_area_id="+end_area_id
- +"&end_area_type="+end_area_type
- +"&run_date="+run_date
- +"&tt="+tt;
- listURL=encodeURI(listURL);
- window.location.href=listURL;
-
- });
- })
- // 是否存在相同的
- function is_exists(all_arr,dict){
- var flag=false;
- for (var i=0,m=all_arr.length;i<m;i++) {
- var temp=all_arr[i];
- if((temp['start_area_id']==dict['start_area_id'] && temp['start_area_type']==dict['start_area_type'])
- && temp['end_area_id']==dict['end_area_id'] && temp['end_area_type']==dict['end_area_type']){
- flag=true;
- break;
- }
- }
- return flag;
- }
|