|
- //Author:zhangsq
- //Date:20160826
- //Description:查询结果
-
-
- var tempdate = '';
-
- var has_ticketHTML = '';
-
- var no_ticketHTML = '';
-
- // 去程
- var start_area_id = "";
- var start_area_type = "";
- var end_area_id = "";
- var end_area_type = "";
- var run_date = "";
-
-
- var cur_date = '';
- var cur_date_str = '';
-
-
- // 返程
- var go_ticket_id="";
- // 返程的ticket_id
- var back_ticket_ids=new Array();
-
- var no_resultHTMl = '';
-
-
- var go_date="";
- window.onload = function(){
- has_ticketHTML = $('#has_ticket').prop('outerHTML');
- no_ticketHTML = $('#no_ticket').prop('outerHTML');
- // has_ticketHTML=no_ticketHTML;
- no_resultHTMl = $('#no_no_no').html();
- start_area_id = getPar('start_area_id');
- start_area_type = getPar('start_area_type');
- end_area_id = getPar('end_area_id');
- end_area_type = getPar('end_area_type');
- run_date = getPar('run_date')!=""?getPar('run_date'):getPar('go_date');
-
- //zsq
- var date_str = getPar('run_date');
- if (date_str != '' ) {
- run_date = date_str;
- }
-
-
- //zsq end
-
-
-
-
-
- tempdate = run_date;
-
- var nowdate = getDateTime(0);
- var month = getMonthAndDayByDate(run_date,'month');
- var day = getMonthAndDayByDate(run_date,'day');
- if (tempdate==nowdate) {
- $('#show_date').html(month+'月'+day+'日 今天');
- $('#left').removeClass('fontgreen_color');
- $('#left').addClass('commongray_color');
- $('#left').removeAttr('onclick');
- $('#left_img').attr('src','images/a2/ic_return_d.png');
- } else{
- $('#show_date').html(month+'月'+day+'日');
- $('#left').removeClass('commongray_color');
- $('#left').addClass('fontgreen_color');
- $('#left').attr('onclick','leftDidClicked();');
- $('#left_img').attr('src','images/a2/ic_return_n_l.png');
- }
- go_date=getPar('go_date');
- go_ticket_id=getPar('go_ticket_id');
-
- if(go_ticket_id==""){ //去程
- //清除填写订单的四个缓存
- clearStorage('CacheInfo_people');
- clearStorage('CacheInfo_station');
- clearStorage('go_data');
- clearStorage('back_data');
- ZZLog('clearStorage');
- go_list();
- }else{ // 返程
- back_list();
- }
- }
- //点击了 前一天
- function leftDidClicked(){
- var nowdate = tempdate;
- var run_date = before(nowdate);
- tempdate = run_date;
- var nowdate = getDateTime(0);
- var month = getMonthAndDayByDate(run_date,'month');
- var day = getMonthAndDayByDate(run_date,'day');
- if (tempdate==nowdate) {
- $('#show_date').html(month+'月'+day+'日 今天');
- $('#left').removeClass('fontgreen_color');
- $('#left').addClass('commongray_color');
- $('#left').removeAttr('onclick');
- $('#left_img').attr('src','images/a2/ic_return_d.png');
- } else{
- $('#show_date').html(month+'月'+day+'日');
- $('#left').removeClass('commongray_color');
- $('#left').addClass('fontgreen_color');
- $('#left').attr('onclick','leftDidClicked();');
- $('#left_img').attr('src','images/a2/ic_return_n_l.png');
- }
- go_ticket_id=getPar('go_ticket_id');
- if(go_ticket_id==""){ //去程
- go_list();
- }else{ // 返程
- back_list();
- }
- }
- //点击了后一天
- function rightDidClicked(){
- var nowdate = tempdate;
- var run_date = after(nowdate);
- tempdate = run_date;
- var nowdate = getDateTime(0);
- var month = getMonthAndDayByDate(run_date,'month');
- var day = getMonthAndDayByDate(run_date,'day');
- if (tempdate==nowdate) {
- $('#show_date').html(month+'月'+day+'日 今天');
- $('#left').removeClass('fontgreen_color');
- $('#left').addClass('commongray_color');
- $('#left').removeAttr('onclick');
- $('#left_img').attr('src','images/a2/ic_return_d.png');
- } else{
- $('#show_date').html(month+'月'+day+'日');
- $('#left').removeClass('commongray_color');
- $('#left').addClass('fontgreen_color');
- $('#left').attr('onclick','leftDidClicked();');
- $('#left_img').attr('src','images/a2/ic_return_n_l.png');
- }
- go_ticket_id=getPar('go_ticket_id');
- if(go_ticket_id==""){ //去程
- go_list();
- }else{ // 返程
- back_list();
- }
-
- // var start_area_id = getPar('start_area_id');
- // var start_area_type = getPar('start_area_type');
- // var end_area_id = getPar('end_area_id');
- // var end_area_type = getPar('end_area_type');
- //
-
- }
- // go 去程
- function go_list(){
- //转圈圈
- //$("#loadingToast").show();
- var url=base_api+"zz_wxsct/control.php";
- var parm={
- type:"bus_reservation_list_go",
- start_id:start_area_id,
- start_type:start_area_type,
- end_id:end_area_id,
- end_type:end_area_type,
- run_date:tempdate
- }
- ZZLog(url+JSON.stringify(parm));
- $.post(url,parm,function(res_data){
- res_data=JSON.parse(res_data);
- ZZLog(res_data);
- //转圈圈
- //$("#loadingToast").hide();
- if (res_data.code == "0") {
- // if (res_data.totalnum == '0') {
- //
- // $('#detailInfo').addClass('ui_hide');
- // $('#no_result').removeClass('ui_hide');
- // recommendInfo(res_data.list);
- //
- // }else{
- // if (res_data.select_type == "recommend") {
- // recommendInfo(res_data.list);
- // $('#detailInfo').addClass('ui_hide');
- // $('#no_result').removeClass('ui_hide');
- // } else{
- // $('#detailInfo').removeClass('ui_hide');
- // $('#no_result').addClass('ui_hide');
- // reloadData(res_data);
- // }
- // }
- if (res_data.select_type == 'normal') {
- $('#detailInfo').removeClass('ui_hide');
- $('#no_result').addClass('ui_hide');
- reloadData(res_data);
- } else if(res_data.select_type == "tomorrow_normal"){
- $('#detailInfo').addClass('ui_hide');
- $('#no_result').removeClass('ui_hide');
- $('#tomorrow').html('今日没有匹配的车次');
- $('#tomorrow_new').html('请更换日期查询');
- $('#no').addClass('ui_hide');
-
- }else{
- recommendInfo(res_data.list);
- $('#detailInfo').addClass('ui_hide');
- $('#no_result').removeClass('ui_hide');
- }
-
-
- } else{
- alert(res_data.info);
- }
- });
- }
-
- //推荐信息
- function recommendInfo(list){
- if (list.length == 0) {
-
- $('#no').hide();
- } else{
- $('#no').show();
- var tempHTML = '';
- var newHTML = '';
- for(var i=0;i<list.length;i++){
- tempHTML = no_resultHTMl;
- tempHTML = tempHTML.replace('[出发地]',list[i].start_area_name);
- tempHTML = tempHTML.replace('[目的地]',list[i].end_area_name);
- tempHTML = tempHTML.replace('[价格]',list[i].price);
- tempHTML = tempHTML.replace('[全程用时]',list[i].center_time);
- tempHTML = tempHTML.replace('[start_area_id]',list[i].start_area_id);
- tempHTML = tempHTML.replace('[end_area_id]',list[i].end_area_id);
- tempHTML = tempHTML.replace('[start_area_type]',list[i].start_area_type);
- tempHTML = tempHTML.replace('[end_area_type]',list[i].end_area_type);
- tempHTML = tempHTML.replace('remmend_ticket','remmend_ticket'+i);
- tempHTML = tempHTML.replace("[start_id],[start_type],[end_id],[end_type]",list[i].start_area_id+',\''+list[i].start_area_type+'\','+list[i].end_area_id+',\''+list[i].end_area_type+'\'');
- newHTML += tempHTML;
- }
- $('#no_no_no').html(newHTML)
- }
- }
-
- // back 返程
- function back_list(){
- //转圈圈
- //$("#loadingToast").show();
- var url=base_api+"zz_wxsct/control.php";
- var parm={
- type:"bus_reservation_list_back",
- date:go_date,
- ticket_id:go_ticket_id
- }
- ZZLog(url+JSON.stringify(parm));
- $.post(url,parm,function(res_data){
- res_data=JSON.parse(res_data);
- ZZLog(res_data);
- //转圈圈
- //$("#loadingToast").hide();
- if (res_data.code == "0") {
- if (res_data.totalnum == '0') {
- $('#detailInfo').addClass('ui_hide');
- $('#no_result').removeClass('ui_hide');
- $('#no').addClass('ui_hide');
- }else{
- $('#no_result').addClass('ui_hide');
- $('#detailInfo').removeClass('ui_hide');
- }
- reloadData(res_data);
- } else{
- alert(res_data.info);
- }
- });
- }
- //加载数据
- function reloadData(data){
- var list = data.list;
- var tempHTML = '';
- var newHTML = ''
- for(var i=0;i<list.length;i++){
- if (list[i].ticket_over == '充足') {
- tempHTML = has_ticketHTML;
- } else{
- tempHTML = no_ticketHTML;
- }
- if(i==list.length-1){
- tempHTML=tempHTML.replace('style','style="margin-bottom:0.6rem;');
- }
- tempHTML=tempHTML.replace('[出发地]',list[i].start_area_name);
- tempHTML=tempHTML.replace('[目的地]',list[i].end_area_name);
- tempHTML=tempHTML.replace('[出发地站点]',list[i].start_res_name);
- tempHTML=tempHTML.replace('[目的地站点]',list[i].end_res_name);
- tempHTML=tempHTML.replace('[时间]',list[i].start_time);
- tempHTML=tempHTML.replace('[价格]',parseInt(list[i].price));
- tempHTML=tempHTML.replace('[全程用时]',list[i].center_time);
- tempHTML=tempHTML.replace('[start_area_id]',list[i].start_area_id);
- tempHTML=tempHTML.replace('[start_station_id]',list[i].start_res_id);
- tempHTML=tempHTML.replace('[end_area_id]',list[i].end_area_id);
- tempHTML=tempHTML.replace('[end_station_id]',list[i].end_res_id);
- // tempHTML=tempHTML.replace('[order_id]','\''+list[i].run_id+'\',\''+list[i].start_area_id+'\',\''+list[i].end_area_id+'\',\''+list[i].start_res_id+'\',\''+list[i].end_res_id+'\'');
- if(go_ticket_id==""){ //去程
- tempHTML=tempHTML.replace('[order_id]','\''+list[i].run_id+'\',\''+list[i].start_area_name+'\',\''+list[i].end_area_name+'\',\''+list[i].run_date+'\',\''+list[i].price+'\',\''+list[i].line_id+'\',\''+list[i].ticket_id+'\',\''+list[i].start_time+'\',\''+list[i].start_area_id+'\',\''+list[i].end_area_id+'\',\''+list[i].start_res_id+'\',\''+list[i].end_res_id+'\',\''+''+'\'');
- }else{ // 返程
- tempHTML=tempHTML.replace('[order_id]','\''+list[i].run_id+'\',\''+list[i].start_area_name+'\',\''+list[i].end_area_name+'\',\''+list[i].run_date+'\',\''+list[i].price+'\',\''+list[i].line_id+'\',\''+list[i].ticket_id+'\',\''+list[i].start_time+'\',\''+list[i].start_area_id+'\',\''+list[i].end_area_id+'\',\''+list[i].start_res_id+'\',\''+list[i].end_res_id+'\',\''+list[i].ticket_id+'\'');
- }
-
- tempHTML=tempHTML.replace('[可选上车站点]',list[i].select_station);
- newHTML+=tempHTML;
- }
- $('#detailInfo').html(newHTML);
- }
- //获取前一天日期
- function before(d){
- d = new Date(d);
- d = +d - 1000*60*60*24;
- d = new Date(d);
- //return d;
- //格式化
- var year = ";" + d.getFullYear() + ";";
- var month = ";" + (d.getMonth()+0+1) + ";";
- var day = ";" + d.getDate() + ";";
- if(year.length < 4) {
- year = "0" + year;
- }
- if(month.length < 4) {
- month = "0" + month;
- }
- if(day.length < 4) {
- day = "0" + day;
- }
- var datestr = year + "-" + month + "-" + day;
- datestr = datestr.replace(/;/g, "");
- return datestr;
- // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
-
- }
- //获取后一天日期
- function after(d){
- d = new Date(d);
- d = +d + 1000*60*60*24;
- d = new Date(d);
- //return d;
- //格式化
- var year = ";" + d.getFullYear() + ";";
- var month = ";" + (d.getMonth()+0+1) + ";";
- var day = ";" + d.getDate() + ";";
- if(year.length < 4) {
- year = "0" + year;
- }
- if(month.length < 4) {
- month = "0" + month;
- }
- if(day.length < 4) {
- day = "0" + day;
- }
- var datestr = year + "-" + month + "-" + day;
- datestr = datestr.replace(/;/g, "");
- return datestr;
- // return d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate();
-
- }
- function getMonthAndDayByDate(datestr,info){
- var dateAry = datestr.split('-');
- var cNewTimeStr;
- switch(info){
- case 'year':
- cNewTimeStr = dateAry[0];
- break;
- case 'month':
- cNewTimeStr = dateAry[1];
- break;
- default:
- cNewTimeStr = dateAry[2];
- break;
- }
- return cNewTimeStr;
- }
-
- function goToBook(run_ids,start_area_name,end_area_name,run_dates,prices,line_id,ticket_ids,start_times,start_area_id,end_area_id,start_res_id,end_res_id,ticket_id){
- var list_orders= {
- end_area : end_area_name,
- start_area : start_area_name,
- price : prices,
- prod_id : line_id,
- run_date : run_dates,
- run_id : run_ids,
- start_time : start_times,
- ticket_id : ticket_id
- }
-
- setStorJson('list_order',list_orders);
- setStorage("list_id",line_id);
- setStorage("run_id",run_ids);
- if(line_id == "449860"||line_id == "449865"||line_id == "450036"||line_id == "450037"||line_id == "450539"||line_id == "450544"){
- var list = getStorJson("list_order");
- console.log(list)
- //setStorJson('list_order',list_order);
- window.location.href ="http://xmwx.zhizhuchuxing.cn/ZZDZ2/submit_order.html";
- }else{
- //go_ticket_id 在返程的时候是返程ticket_id 去程可以不传ticket_id
- if(go_ticket_id){
- window.location.href = "./fill_order.html?run_id="+run_ids+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&start_res_id="+start_res_id+"&end_res_id="+end_res_id+"&go_ticket_id="+ticket_id;
- }else{
- window.location.href = "./fill_order.html?run_id="+run_ids+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&start_res_id="+start_res_id+"&end_res_id="+end_res_id+"&go_ticket_id=";
- }
- }
- }
-
-
- //日历点击事件
- function selectCalander(){
- // start_area_id=791&start_area_type=area&end_area_id=850&end_area_type=area&run_date=2016-09-10&tt=20160910144026
- if(go_ticket_id){
- window.location.href = "./calendar.html?run_date="+run_date+"&start_area_type="+start_area_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&end_area_type="+end_area_type+"&go_ticket_id="+go_ticket_id+"&from=search_results";
- }else{
- window.location.href = "./calendar.html?run_date="+run_date+"&start_area_type="+start_area_type+"&start_area_id="+start_area_id+"&end_area_id="+end_area_id+"&end_area_type="+end_area_type+"&go_ticket_id="+"&from=search_results";
- }
- }
-
- function goToRemmendInfo(start_id,start_type,end_id,end_type){
- var run_date = tempdate;
- var listURL='./search_results.html?start_area_id='+start_id
- +"&start_area_type="+start_type
- +"&end_area_id="+end_id
- +"&end_area_type="+end_type
- +"&run_date="+run_date;
- listURL=encodeURI(listURL);
- window.location.href=listURL;
- }
|