|
-
- //Author:zhangsq
- //Date:20160826
- //Description:查询结果
-
- var goinfoHTML = '';
- //记录去程时间
- var go_date = '';
- //去程的出发地站点数组
- var go_stares_ary = '';
- //去程的目的地站点数组
- var go_endres_ary = '';
- //记录map info
- var map_info = '';
-
- $(document).ready(function(){
-
- })
-
- window.onload = function(){
- //去程的html
- goinfoHTML = $('#goinfo').html();
-
- //加载去程的信息
- reloadGoInfo();
- }
-
- //页面开始 加载去程信息
- function reloadGoInfo(){
- var run_id = getPar('run_id');
- var start_area_id = getPar('start_area_id');
- var end_area_id = getPar('end_area_id');
- var start_res_id = getPar('start_res_id');
- var end_res_id = getPar('end_res_id');
-
- var url=base_api+"./zz_wxsct/control.php";
- var parm={
- type:"bus_detail_info_go",
- run_id:run_id,
- start_area_id:start_area_id,
- end_area_id:end_area_id,
- start_res_id:start_res_id,
- end_res_id:end_res_id
- }
- ZZLog(url+JSON.stringify(parm));
- $.post(url,parm,function(res_data){
- res_data=JSON.parse(res_data);
- ZZLog(res_data);
- if (res_data.code == 0) {
- // 替换去程信息
- replaceGoInfo(res_data);
- } else{
- alert(res_data.info);
- }
- });
- }
-
- //替换去程信息
- function replaceGoInfo(data){
- console.log(data);
- alert(data.list.bus_type)
- if (data.list.bus_type == '256'){
- $('#start_res').addClass('ui_hide');
- $('#end_res').addClass('ui_hide');
- }else{
- $('#start_res').removeClass('ui_hide');
- $('#end_res').removeClass('ui_hide');
- }
- var list = data.list;
- var temphtml = goinfoHTML;
- var nowdate = getDateTime(0);
- var selmonth = getMonthAndDayByDate(list.run_date,'month');
- var selday = getMonthAndDayByDate(list.run_date,'day');
- if (nowdate == list.run_date) {
- temphtml = temphtml.replace('[日期]',selmonth+'月'+selday+'日'+' &nbdp;今天');
- }else{
- temphtml = temphtml.replace('[日期]',selmonth+'月'+selday+'日');
- }
- temphtml = temphtml.replace('[去程时间]',list.start_time);
- temphtml = temphtml.replace('[出发地]',list.start_area_name);
- temphtml = temphtml.replace('[出发地站点]',list.start_res_name);
- temphtml = temphtml.replace('[目的地]',list.end_area_name);
- temphtml = temphtml.replace('[目的地站点]',list.end_res_name);
- temphtml = temphtml.replace('[日程]','全程'+list.distance+'公里');
- temphtml = temphtml.replace('[用时]',list.center_time);
- temphtml = temphtml.replace('[go_line_id]',list.line_id);
- temphtml = temphtml.replace('[go_ticket_id]',list.ticket.ticket_id_go);
- temphtml = temphtml.replace('[价格]',list.ticket.go_price);
- temphtml = temphtml.replace('[普通座]',list.ticket.site);
- temphtml = temphtml.replace('[单程]',list.ticket.ticket_id_go);
- if (list.ticket.discount_price == '0') {
- temphtml = temphtml.replace('[优惠]','无往返优惠');
- }else{
- temphtml = temphtml.replace('[优惠]','往返优惠'+list.ticket.discount_price+'元');
- }
- $('#goinfo').html(temphtml);
-
- //去程的出发地、目的地数组
- go_stares_ary = list.start_res_array;
- go_endres_ary = list.end_res_array;
- //记录地图信息
- map_info = list['map'];
- }
-
-
- //选择站点的下侧弹层
- $("#start_area").click(function(){
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
- $('#mask').click(function(){
- $("#mask").css("display","none");
- $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
- })
-
-
- //选择返程
- function selectBackInfo(){
- var go_ticket_id = $('#go_id_info').attr('go_ticket_id');
- var data = {
- back : 'back',
- go_date : go_date,
- go_ticket_id : go_ticket_id
- }
- setStorJson('goListInfo',data);
- window.location.href = './calendar.html?go_ticket_id='+go_ticket_id+'&go_date='+go_date+'&back=back'+'&from=fill_order';
- }
-
- //跳转地图
- function goToMapInfo(){
- setStorJson('goMapInfo',map_info);
- window.location.href = '';
- }
-
- //选择站点的下侧弹层
- $("#start_res_go").click(function(){
- // upDiv(start_station_list,'start_res_go','go');
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
- $("#end_res_go").click(function(){
- upDiv(end_station_list,'end_res_go','go');
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
-
- $('#mask').click(function(){
- $("#mask").css("display","none");
- $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
- })
-
-
-
- //上弹框的内容封装
- function upDiv(data,select_id,goBack){
- var html = '';
- for (var i = 0 ; i < data.length; i ++) {
- var tempHTML = wei_infoHTML;
- tempHTML = tempHTML.replace('示例菜单',data[i].name);
- tempHTML = tempHTML.replace('[id]',data[i].id);
- html += tempHTML;
- }
- $('#wei_info').html(html);
- $('.weui_actionsheet_cell').click(function(){
- if (this.innerHTML == '取消') {
- $('#mask').click();
- return ;
- }else{
- $('#'+select_id).html(this.innerHTML);
- $('#'+select_id).attr('valid',this.id);
- $('#mask').click();
- }
-
- if (goBack == 'go') {
- var start_id = $('#up_station_time').attr('valid');
- var end_id = $('#down_station_time').attr('valid');
- $.ajax({
- url:'./zz-fx/control.php',
- type: "post",
- data: {
- run_id:run_id,
- line_id:line_id,
- start_id:start_id,
- end_id:end_id,
- tickets:ticket,
- back:1,
- type:"retrieval_tickets"
- },
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- console.log(data);
- //替换去程票种数量信息
- showCountInfoByGo(data.list);
- }
- },
- fail: function (data) {
- // 此处放失败后执行的代码
- }
- });
- } else{
- var back_start_station_id = $('#back_up_station_time').attr('valid');
- var back_end_station_id = $('#back_down_station_time').attr('valid');
-
- $.ajax({
- url:'./zz-fx/control.php',
- type: "post",
- data: {
- run_id:back_run_id,
- line_id:back_line_id,
- start_id:back_start_station_id,
- end_id:back_end_station_id,
- tickets:back_ticket,
- back:2,
- type:"retrieval_tickets"
- },
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- console.log(data);
- //替换去程票种数量信息
- showCountInfoByBack(data.list);
- }
- },
- fail: function (data) {
- // 此处放失败后执行的代码
- }
- });
-
-
- }
-
- })
- }
-
-
- //截取日期参数
- 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;
- }
|