|
- //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="";
- //获取头部切换信息
- var top_cut = getStorage("top_cut");
- //获取城际直通车出发地目的地
- var start_city_id = getStorage("start_city_id");
- //获取奔驰专线出发地目的地
- var start_benz_id = getStorage("start_benz_id");
- //线路类型
- var line_type = getStorage("line_type");
- //读取缓存
- var start_area_info=getStorJson('f_wx_start_hot_city20160826');//出发地
- var end_area_info=getStorJson('f_wx_end_hot_city20160826'); //目的地
-
- //$("#loading_html").show();
- //页面加载
- window.onload=function(){
- $("#body_html").show();
- baseInfo();
-
- if(top_cut == null){
- top_cut = 0;
- }
- if(start_city_id == null){
- start_city_id = 0;
- }
- if(start_benz_id == null){
- start_benz_id = 0;
- }
- if(line_type == null){
- line_type = 0;
- }
- cut_bus_load(top_cut);
-
-
-
- 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);
- var cur_date_m_d = after(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=after(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');
- }
- // $("#loading_html").show();
- }
- //点击事件
- $(document).ready(function(){
- //点击出发地
- $('#start_area').click(function(){
- var tt=getDateTime(4);
- // 跳转前将URL编码
- var listURL='hot_city.html?from=travel_book&poi_type=&op_type=in&tt='+tt+'&station_id='+''+'&line_type='+line_type;
- listURL = encodeURI(listURL);
- window.location.href=listURL;
- });
- //点击目的地
- $('#end_area').click(function(){
- var tt=getDateTime(4);
- // 跳转前将URL编码
- var listURL='hot_city.html?from=travel_book&poi_type=&op_type=out&tt='+tt+'&station_id='+start_area_id+'&line_type='+line_type;
- 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(){
- if(start_area_name=="请选择出发地"||end_area_name=="请选择目的地"){
- return;
- }else{
-
- // 有出发地缓存
- if(start_area_info){
- var data = {
- op_type: "in",
- area_id: end_area_id,
- area_name: end_area_name
- };
- setStorJson('f_wx_start_hot_city20160826', data);
-
- }
- // 有目的地缓存
- if(end_area_info){
- var data = {
- op_type: "out",
- area_id: start_area_id,
- area_name: start_area_name
- };
- setStorJson('f_wx_end_hot_city20160826', data);
-
- }
-
- 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
- +"&end_area_id="+end_area_id
- +"&if_go=go"
- +"&run_date="+run_date;
- 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 = GetDateStr(1);
- 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 cut_bus(index){
- //切欢时清缓存信息、变样式
- clearStorage("f_wx_end_hot_city20160826");
- clearStorage("f_wx_start_hot_city20160826");
- $('#start_area').text("请选择出发地");
- $('#start_area').addClass('lightgray_color');
- $('#end_area').text("请选择目的地");
- $('#end_area').addClass('lightgray_color');
-
- start_area_name = "请选择出发地";
- start_area_id = "";
- end_area_name = "请选择目的地";
- end_area_id = "";
-
- $(".cut_top").children().addClass("cut_top_hide");
- $(".cut_top").children().removeClass("cut_top_show");
- $("#cut_"+index).removeClass("cut_top_hide");
- $("#cut_"+index).addClass("cut_top_show");
- $("#bus_station").children().hide();
- $(".cut_bus"+index).show();
- top_cut = index;
- line_type = $("#cut_"+index).attr("line_type");
- setStorage("top_cut",top_cut);
- setStorage("line_type",line_type);
-
-
- }
-
- function cut_bus_load(index){
-
- $(".cut_top").children().addClass("cut_top_hide");
- $(".cut_top").children().removeClass("cut_top_show");
- $("#cut_"+index).removeClass("cut_top_hide");
- $("#cut_"+index).addClass("cut_top_show");
- $("#bus_station").children().hide();
- $(".cut_bus"+index).show();
- top_cut = index;
- line_type = $("#cut_"+index).attr("line_type");
- setStorage("top_cut",top_cut);
- setStorage("line_type",line_type);
- }
- // 是否存在相同的
- 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;
- }
-
- function GetDateStr(AddDayCount) {
- var dd = new Date();
- dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
- var y = dd.getFullYear();
- var m = dd.getMonth()+1;//获取当前月份的日期
- var d = dd.getDate();
- return y+"-"+m+"-"+d;
- }
- //切换城际直通车出发地、目的地
- //function change_city_bus(){
- // var start_add = $("#city_bus_0").text();
- // var end_add = $("#city_bus_1").text();
- // $("#city_bus_0").text(end_add);
- // $("#city_bus_1").text(start_add);
- // if($("#city_bus_0").text()=="上海"){
- // start_city_id = 0;
- // }else if($("#city_bus_0").text()=="杭州"){
- // start_city_id = 1;
- // }
- // setStorage("start_city_id",start_city_id);
- //}
- //获取城际直通车出发地、目的地
- //function get_city_bus(index){
- // var start_add = $("#city_bus_0").text();
- // var end_add = $("#city_bus_1").text();
- // if(index == 0){
- // $("#city_bus_0").text(start_add);
- // $("#city_bus_1").text(end_add);
- // }else if(index == 1){
- // $("#city_bus_0").text(end_add);
- // $("#city_bus_1").text(start_add);
- // }
- //
- //
- //}
-
- //切换奔驰专线出发地、目的地
- //function change_benz_bus(){
- // var start_add = $("#benz_bus_0").text();
- // var end_add = $("#benz_bus_1").text();
- // $("#benz_bus_0").text(end_add);
- // $("#benz_bus_1").text(start_add);
- // if($("#benz_bus_0").text()=="南京"){
- // start_benz_id = 0;
- // }else if($("#benz_bus_0").text()=="淮安"){
- // start_benz_id = 1;
- // }
- // setStorage("start_benz_id",start_benz_id);
- //}
- //获取城际直通车出发地、目的地
- //function get_benz_bus(index){
- // var start_add = $("#benz_bus_0").text();
- // var end_add = $("#benz_bus_1").text();
- // if(index == 0){
- // $("#benz_bus_0").text(start_add);
- // $("#benz_bus_1").text(end_add);
- // }else if(index == 1){
- // $("#benz_bus_0").text(end_add);
- // $("#benz_bus_1").text(start_add);
- // }
- //
- //
- //}
-
- function baseInfo(){
- var param = {
-
- }
- ZZLog(base_api + "trip/index&" + JSON.stringify(param));
- $.ajax({
- type: "post",
- url: base_api + "trip/index",
- data: param,
- dataType: 'json',
- success: function(res_data) {
- ZZLog(res_data);
- if(res_data.flag == true) {
- base_html(res_data.data);
- } else {
- alert(res_data.mag);
- }
- },
- error: function(e) {
- ZZLog(e);
- }
- });
- }
-
- //替换首页基础信息
- function base_html(data){
- var temp_lunbo = "";
- var temp_dsn = "";
- var temp_dsn = "";
- var temp_through = "";
- var temp_rim = "";
- //轮播
- for(var i=0,j=data.recomList.length;i<j;i++){
- var str = data.recomList[i].toUrl;
- temp_lunbo += '<div class="swiper-slide"><img class="urlurl" style="width: 100%;" src="'+pic_api+data.recomList[i].img+'"; to_url="'+str+'"/></div>'
- }
- $(".swiper-wrapper").html(temp_lunbo);
- $('.urlurl').click(function(){
- var urlstr = $(this).attr('to_url');
- window.location.href = urlstr;
- })
- //迪士尼穿梭
- for(var i=0,j=data.dsn.length;i<j;i++){
- 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+')">'
- + '<div style="width:1%" class="ub ub-f1 ub-ver text_right">'
- + '<div style="font-size: 0.11rem;" class="commongray_color">全程用时</div>'
- + '<div class="fontmiddle_color">'+data.dsn[i].bus_time+'</div>'
- + '</div>'
- + '<img style="height: 0.35rem;margin-top: 0.04rem;" class="ui_p_r05 ui_p_l05" src="images/img_points@2x.png"/>'
- + '<div style="width:1%" class="ub ub-f4 ub-ver">'
- + '<div style="margin-top:-0.03rem" class="lightblack_color ulev1">'+data.dsn[i].dsnstart+'</div>'
- + '<div style="margin-top: 0.1rem;" class="lightblack_color ulev1">'+data.dsn[i].dsnend+'</div>'
- + '</div>'
- + '<div style="top: 0.15rem; class="ub ub-pe ub-ver">'
- + '<span class="ulev1" style="color:#519d9e;">¥</span>'
- + '<span style="color:#519d9e;font-size: 0.32rem;">'+parseInt(Math.ceil(data.dsn[i].price))+'</span>'
- + '</div>'
- + '</li>'
- }
- $("#dsn_bus").html(temp_dsn);
- $('#dsn_bus').show();
- //直通巴士
- for(var i=0,j=data.scenicList.length;i<j;i++){
- 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+')">'
- + '<div style="background-image: url('+pic_api+data.scenicList[i].img+')" class="scene_direct uc-tl1 uc-tr1 text_right">'
- + '<img class="tuijian" style="width: 0.32rem;" src="images/img_jian@2x.png"/>'
- + '</div>'
- + '<div style="padding:0.08rem;padding-bottom:0.09rem;" class="ub ub-ae tuijian_biankuang uc-bl1 uc-br1">'
- + '<div class="ub ub-f1 ub-ver">'
- + '<div style="font-size: 0.1rem;padding-left:0.01rem;" class="commongray_color">全程'+data.scenicList[i].bus_time+'</div>'
- + '<div class="white_color darkgreen_color bus_type">'+data.scenicList[i].car_type+'</div>'
- + '</div>'
- + '<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>'
- + '</div>'
- + '</div>'
- }
- $("#through_bus").html(temp_through);
- $('#through_bus').show();
- //周边游
- for(var i=0,j=data.rimList.length;i<j;i++){
- var str = '';
- switch (data.rimList[i].type){
- case '372':
- str = 'images/img-zhitongbashi.png';
- break;
- case '370':
- str = 'images/img-chejing.png';
- break;
- case '376':
- str = 'images/img-bashi.png';
- break;
- case '371':
- str = 'images/img-chejiu.png';
- break;
- default:
- break;
- }
- 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">'
- + '<img style="height: 0.17rem;position: absolute;top: 0.1rem;" src="'+str+'"/>'
- + '<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">'
- + '<div class="ub-f1 ub ub-ver">'
- + '<div style="opacity: 0.8;" class="ulev2 white_color">'+data.rimList[i].zname+'</div>'
- + '<div style="font-size: 0.11rem;opacity: 0.8;" class="white_color">'+data.rimList[i].tickdes+' </div>'
- + '</div>'
- + '<div class="ub ub-ae">'
- + '<span style="font-size: 0.11rem;opacity: 0.8;" class="white_color">¥</span>'
- + '<span style="opacity: 0.8;" class="white_color ulev5">'+parseInt(Math.ceil(data.rimList[i].price))+'</span>'
- + '</div>'
- + '</div>'
- + '</li>'
- }
- $("#rim_travel").html(temp_rim);
- $('#rim_travel').show();
- $("#loading_html").show();
- //轮播空间swiper
- var swiper = new Swiper('.swiper-container', {
- loop : true,
- paginationClickable: true,
- centeredSlides: true,
- autoplay : 2000,
- autoplayDisableOnInteraction : false
- });
-
-
- //轮播点击事件
- // function go_ticket(){
- // window.location.href="disney_bus.html";
- // }
- // function go_picture(){
- // window.location.href="search_bus.html";
- // }
-
- }
-
- function around_travel(){
- //MtaH5.clickStat('test0001');
- window.location.href="trave_around_main.html";
- }
- function dsn_travel(){
- //MtaH5.clickStat('test0001');
- window.location.href="disney_tranship.html";
- }
- function plane_travel(){
- //MtaH5.clickStat('test0001');
- window.location.href="pick_drop_person.html";
- }
-
-
- //景区直通点击 跳转列表页面
- function aroundDidClicked(start_id,end_id){
- var run_date = after(getDateTime(0));
- window.location.href = './search_results.html?start_area_id='+start_id+'&end_area_id='+end_id+'&ifgo=go'+'&run_date='+run_date;
- }
-
- //周边游点击 跳转详情页面
- function rimDidClicked(pro_id){
- window.location.href = './travel_around_detail.html?pro_id='+pro_id;
- }
-
- //迪士尼 跳转列表页面
- function disneyDidClicked(start_id,end_id){
- var run_date = after(getDateTime(0));
- window.location.href = './search_results.html?start_area_id='+start_id+'&end_area_id='+end_id+'&ifgo=go'+'&run_date='+run_date;
- }
-
-
-
- //跳转活动页面’
- function goToProductDetail(toUrl){
- window.location.open(toUrl);
- }
-
|