|
-
- //Author:zhangsq
- //Date:20160826
- //Description:查询结果
-
- var goinfoHTML = '';
- var backinfoHTML = '';
- //记录去程时间
- var go_date = '';
- //去程的出发地站点数组
- var go_stares_ary = '';
- //去程的目的地站点数组
- var go_endres_ary = '';
- //返程的出发地站点数组
- var back_stares_ary = '';
- //返程的目的地站点数组
- var back_endres_ary = '';
-
- //记录map info
- var map_info = '';
- //站点下弹框
- var resHTML = '';
- //乘客人弹层的html
- var passHTML = '';
-
- //ticket_id
- var ticket_id_back = '';
- var ticket_id_go = '';
- var ticket_id_back_back ='';
- var run_id_go = '';
- var run_id_back = '';
-
- //乘客数量
- var passCount = 0;
- //记录乘客人的数组
- var passAry = '';
-
- //记录是否选择返程 0为单一去程
- var ifselback = 0;
-
- //选择不同的站点弹层
- var sel_res_div = '';
-
-
- $(document).ready(function(){
-
- })
-
- window.onload = function(){
- $("#loadingToast").show();
- //去程的html
- goinfoHTML = $('#goinfo').html();
- //返程的html
- backinfoHTML = $('#backinfo').html();
- //站点html 下弹框
- resHTML = $('#wei_info').html();
- //乘客人的弹层
- passHTML = $('#wei_info_passenger').html();
- //加载乘客人信息
- reloadPassangersInfo();
- //判断返程
- var go_ticketid = getPar('go_ticket_id');
- if (go_ticketid == '') {
- $('#discount').removeClass('ui_hide');
- $('#hideback').addClass('ui_hide');
- $('#backinfo').addClass('ui_hide');
- ifselback = 0
- //加载去程的信息
- reloadGoInfo();
- } else{
- $("#loadingToast").show();
- $('#add_back').addClass('ui_hide');
-
- $('#discount').addClass('ui_hide');
-
- ifselback = 1;
- //加载去程和返程信息
- reloadBackInfo(go_ticketid);
- }
-
-
-
- }
-
- //加载乘客人信息
- function reloadPassangersInfo(){
- var url=base_api+"./zz_wxsct/control.php";
- var parm={
- type:"order_getcustomer"
- }
- $.post(url,parm,function(res_data){
- res_data=JSON.parse(res_data);
- ZZLog(res_data);
- if (res_data.code == 0) {
- passCount = res_data.list.length;
- passAry = res_data.list;
- }
- });
- }
-
- //页面开始 加载去程信息
- 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);
- setStorJson('go_data',res_data);
- } else{
- alert(res_data.info);
- }
- });
- }
-
- //替换去程信息
- function replaceGoInfo(data){
- 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');
- go_date = list.run_date;
- if (nowdate == list.run_date) {
- temphtml = temphtml.replace('[日期]',selmonth+'月'+selday+'日'+' 今天');
- }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('[startarea_goid]',list.start_area_id);
- temphtml = temphtml.replace('[startres_goid]',list.start_res_id);
- temphtml = temphtml.replace('[endarea_goid]',list.end_area_id);
- temphtml = temphtml.replace('[endres_goid]',list.end_res_id);
- temphtml = temphtml.replace('[run_id_go]',list.run_id);
- temphtml = temphtml.replace('[价格]',list.ticket.go_price);
- $('#goinfo').html(temphtml);
- $('#distance_back').html('全程'+list.distance+'公里');
- $('#usetime_back').html(list.center_time);
- ticket_id_back = list.ticket.ticket_id_back;
- ticket_id_go = list.ticket.ticket_id_go;
- run_id_go = list.run_id;
-
- var temphtml1 = $('#seatInfo').html();
- temphtml1 = temphtml1.replace('[普通座]',list.ticket.site);
- temphtml1 = temphtml1.replace('[单程]',list.ticket.run_type);
- if (list.ticket.discount_price == '0') {
- temphtml1 = temphtml1.replace('[优惠]','无往返优惠');
- }else{
- temphtml1 = temphtml1.replace('[优惠]','往返优惠'+list.ticket.discount_price+'元');
- }
- $('#seatInfo').html(temphtml1);
- //去程的出发地、目的地数组
- 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");
- $('#res_div').css("display","block");
- sel_res_div = 'startres_goid';
- upDiv(go_stares_ary,'start_res_go','go');
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
- $("#end_area").click(function(){
- $("#mask").css("display","block");
- $('#res_div').css("display","block");
- sel_res_div = 'endres_goid';
- upDiv(go_endres_ary,'end_res_go','go');
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
-
- $('#mask').click(function(){
- $("#mask").css("display","none");
- $('#res_div').css("display","none");
- $('#continue_add').css("display","none");
- $('#add_pass').css("display","none");
- $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
- })
- $('#total_div').removeClass('ui_hide');
- $("#loadingToast").hide();
- }
-
-
-
-
- //选择返程
- 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);
- ifselback = 1;
-
- window.location.href = './calendar.html?go_ticket_id='+go_ticket_id+'&go_date='+go_date+'&from=fill_order';
- }
-
- //取消返程
- function hideBackInfo(){
- $('#discount').removeClass('ui_hide');
- $('#hideback').addClass('ui_hide');
- $('#backinfo').addClass('ui_hide');
- $('#add_back').removeClass('ui_hide');
-
- ifselback = 0;
- }
-
- //跳转地图
- function goToMapInfo(){
- setStorJson('goMapInfo',map_info);
- window.location.href = './navigation_map.html';
- }
-
- ////选择站点的下侧弹层
- //$("#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 changeTicketInfoGo(){
- var type = 'bus_detail_ticket_go';
- var run_id = $('#hiderun').html();
- var start_area_id = $('#stare_area_id').attr('startarea_goid');
- var start_res_id = $('#start_res_go').attr('startres_goid');
- var end_area_id = $('#end_area_id').attr('endarea_goid');
- var end_res_id = $('#end_res_go').attr('endres_goid');
- var data = {
- type:type,
- run_id:run_id,
- start_area_id:start_area_id,
- start_res_id:start_res_id,
- end_area_id:end_area_id,
- end_res_id:end_res_id
- }
- ZZLog('参数')
- ZZLog(data);
- $.ajax({
- url:base_api+'./zz_wxsct/control.php',
- type: "post",
- data: data,
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- console.log(data);
- //替换去程票种数量信息
- showCountInfoByBack(data.list);
- }else{
- alert(data.info)
- }
- },
- fail: function (data) {
- alert(data.info);
- }
- });
- }
-
-
- //加载去程和返程信息
- function reloadBackInfo(go_ticket_id){
- //得到去程的信息 并填充
- var godata = getStorJson('go_data');
- replaceGoInfo(godata);
- var run_id = getPar('run_id');
- $('#loadingToast').show();
- var url=base_api+"./zz_wxsct/control.php";
- var parm={
- type:"bus_detail_info_back",
- run_id:run_id,
- ticket_id:go_ticket_id
- }
- ZZLog(url+JSON.stringify(parm));
- $.post(url,parm,function(res_data){
- res_data=JSON.parse(res_data);
- ZZLog('返程');
- ZZLog(res_data);
- if (res_data.code == 0) {
- // 替换去程信息
- replaceBackInfo(res_data);
- setStorJson('back_data',res_data);
- } else{
- alert(res_data.info);
- }
- });
- }
-
-
- //替换返程日期
- function replaceBackInfo(data){
- if (data.list.bus_type == '256'){
- $('#start_res_back').addClass('ui_hide');
- $('#end_res_back').addClass('ui_hide');
- }else{
- $('#start_res_back').removeClass('ui_hide');
- $('#end_res_back').removeClass('ui_hide');
- }
- var list = data.list;
- var temphtml = backinfoHTML;
- 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+'日'+' 今天');
- }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('[back_line_id]',list.line_id);
- temphtml = temphtml.replace('[back_ticket_id]',list.ticket.ticket_id_go);
- temphtml = temphtml.replace('[startarea_backid]',list.start_area_id);
- temphtml = temphtml.replace('[startres_backid]',list.start_res_id);
- temphtml = temphtml.replace('[endarea_backid]',list.end_area_id);
- temphtml = temphtml.replace('[endres_backid]',list.end_res_id);
- temphtml = temphtml.replace('[run_id_back]',list.run_id);
- temphtml = temphtml.replace('[返程价格]',list.ticket.price);
- $('#backinfo').html(temphtml);
- ticket_id_back_back = list.ticket.ticket_id;
- run_id_back = list.run_id;
- // ticket_id_go = list.ticket.ticket_id_go;
-
- //去程的出发地、目的地数组
- back_stares_ary = list.start_res_array;
- back_endres_ary = list.end_res_array;
- //记录地图信息
- // map_info = list['map'];
-
-
- //选择站点的下侧弹层
- $("#back_start_area").click(function(){
- $("#mask").css("display","block");
- $('#res_div').css("display","block");
- sel_res_div = 'startres_goid';
- upDiv(back_stares_ary,'start_res_back','back');
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
- $("#back_end_area").click(function(){
- $("#mask").css("display","block");
- $('#res_div').css("display","block");
- sel_res_div = 'endres_goid';
- upDiv(back_endres_ary,'end_res_back','back');
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
-
- $('#mask').click(function(){
- $("#mask").css("display","none");
- $('#res_div').css("display","none");
- $('#continue_add').css("display","none");
- $('#add_pass').css("display","none");
- $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
- })
-
- $('#hideback').removeClass('ui_hide');
- $('#backinfo').removeClass('ui_hide');
- $("#loadingToast").hide();
- }
-
- //添加乘客
- function addPassanger(){
- if (passCount == 0) {
- $("#mask").css("display","block");
- $('#add_pass').css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- } else{
- var html = '';
- for (var i = 0 ; i < passAry.length; i ++) {
- var tempHTML = passHTML;
- tempHTML = tempHTML.replace('[乘客]',passAry[i].name);
- tempHTML = tempHTML.replace('[证件]',passAry[i].id_num);
- tempHTML = tempHTML.replace('[changeid]',passAry[i].id);
- tempHTML = tempHTML.replace('[img]','img'+passAry[i].id);
- tempHTML = tempHTML.replace('[selid]',passAry[i].id);
- // tempHTML = tempHTML.replace('[showtime]',data.station[i].start_time);
- // tempHTML = tempHTML.replace('images/a3/ic_select_sel.png','images/a3/ic_select_nor.png');
- html += tempHTML;
- }
- $('#wei_info_passenger').html(html);
-
-
- $("#mask").css("display","block");
- $('#continue_add').css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
-
- // $('.weui_actionsheet_cell').click(function(){
-
- $('#ok').click(function(){
- var newhtml = '';
- $('.selectInfo').each(function(){
- var str = '<div class="ub line_color_b ui_line_b ui_p_b15 passinfo" >'
- +'<div class="ub-f1 ui_p_t15 ui_p_t15 ulev1" style="color: black;width:1%;text-overflow:ellipsis;white-space:nowrap;overflow:hidden;">'+$(this).parent().children().eq(0).text()+'</div>'
- +'<div class="ub-f1 ui_p_t15 ui_p_t15 lightgray_color" style="width:1%">'+$(this).parent().children().eq(1).text()+'</div>'
- +'<div class="ub-f1 ui_p_t15 ui_p_t15 ui_p_l5 ui_p_r30 text_right" onclick="delThis(this)">'
- +'<img src="images/a3/ic_delete.png" style="width: 0.2rem;"/>'
- +'</div>'
- +'</div>'
- newhtml += str;
- })
- $('#fill_info').html(newhtml);
- $('#mask').click();
- countTotal();
- })
- $('#add_pass_info').click(function(){
- goToAddPassangers();
- })
- // })
- }
- }
-
- //删除某一个乘车人信息
- function delThis(obj){
- $(obj).parent().remove();
- countTotal();
- }
-
- //计算购买总数
- function countTotal() {
- var count = $('#fill_info').children().length;
- $('#people_count').html(count);
-
-
-
-
- if (ifselback == 1) {
- $('#count_price').html(count*$('#back_price').html());
- }else{
- $('#count_price').html(count*$('#go_price').html());
- }
-
- }
-
- //修改乘客信息
- function changeinfo(id){
- var temp = getPar('go_ticket_id');
- 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_end');
- if (temp == '') {
- var urlstr = './wirte_order.html?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+'&man_id='+id;
- window.open(urlstr);
- }else{
- var urlstr = './wirte_order.html?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+'&go_ticket_id='+temp+'&man_id='+id;
- window.open(urlstr);
- }
- }
-
- //选中乘客
- function selectInfo(selid,obj){
- if (obj.id == 0) {
- $('#img'+selid).addClass('selectInfo');
- $('#img'+selid).attr('src','images/a3/ic_select_sel.png');
- obj.id = 1;
- } else{
- $('#img'+selid).removeClass('selectInfo');
- $('#img'+selid).attr('src','images/a3/ic_select_nor.png');
- obj.id = 0;
- }
- // $('#img'+selid).addClass('selectInfo');
- // $('#img'+selid).attr('src','images/a3/ic_select_sel.png')
- }
-
- //跳转添加乘客界面
- function goToAddPassangers(){
- var temp = getPar('go_ticket_id');
- 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_end');
- if (temp == '') {
- window.location.href = './wirte_order.html?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;
- }else{
- window.location.href = './wirte_order.html?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+'&go_ticket_id='+temp;
- }
- }
-
- //支付按钮的点击
- function payBtnDidClicked(){
-
- var custmer = $('#custmer').val();
- var tel = $('#tel').val();
- if (custmer =='') {
- alert('请输入联系人!');
- return;
- } else if(tel == ''){
- alert('请输入手机号!');
- return;
- }
- $("#loadingToast").show();
- var newstr = '';
- $('.passinfo').each(function(){
- var str = $(this).children().eq(0).text()+'*'+$(this).children().eq(1).text();
- newstr += str + '/';
- })
- var passenger = newstr.substring(0,newstr.length-1);
- //联系人 乘客人信息
- var customer = '{,'+custmer+',1,'+tel+',,,,0,,,'+passenger+'}';
- var prod = '';
-
- var count = $('#people_count').html();
-
- if (ifselback == 0) {
- prod = '{m'+ticket_id_go+'p'+count+'|r'+run_id_go+'}'
- }else{
- //判断是否 有返程优惠
- if (ticket_id_back == '') {
- prod = '{m'+ticket_id_go+'p'+count+'|r'+run_id_go+'}'
- } else{
- prod = '{m'+ticket_id_back+'p'+count+'|r'+run_id_go+'}'
- }
- }
- var ifback = ifselback;
-
- var back_prod = '{m'+ticket_id_back_back+'p'+count+'|r'+run_id_back+'}';
-
-
- var data = {
- type : 'order_submit',
- prod : prod,
- ifback : ifselback,
- back_prod : back_prod,
- customer :customer
- }
- ZZLog('提交传参')
- ZZLog(data);
- var url=base_api+"./zz_wxsct/control.php";
- var parm=data;
- $.post(url,parm,function(res_data){
- res_data=JSON.parse(res_data);
- ZZLog(res_data);
- if (res_data.code == 0) {
- $("#loadingToast").hide();
- window.location.href = './pay_success.html';
-
- }else{
- alert(res_data.info);
- }
- });
-
- }
-
- //展示去程票种 修改后的信息
- function showCountInfoByBack(data){
- map_info = data['map'];
- var temphtml1 = $('#seatInfo').html();
- temphtml1 = temphtml1.replace('[普通座]',data.ticket.site);
- temphtml1 = temphtml1.replace('[单程]',data.ticket.run_type);
- if (data.ticket.discount_price == '0') {
- temphtml1 = temphtml1.replace('[优惠]','无往返优惠');
- }else{
- temphtml1 = temphtml1.replace('[优惠]','往返优惠'+data.ticket.discount_price+'元');
- }
- $('#seatInfo').html(temphtml1);
- $('#go_price').html(data.ticket.go_price);
- $('#gotime').html(data.start_time);
- $('#distance').html('全程'+data.distance+'公里');
- $('#usetime').html(data.center_time);
-
- ticket_id_back = data.ticket.ticket_id_back;
- ticket_id_go = data.ticket.ticket_id_go;
- }
-
-
- //上弹框的内容封装
- function upDiv(data,select_id,goBack){
- var sel = $('#'+select_id).attr(sel_res_div);
- var html = '';
- for (var i = 0 ; i < data.station.length; i ++) {
- var tempHTML = resHTML;
- tempHTML = tempHTML.replace('示例菜单',data.station[i].res_name);
- tempHTML = tempHTML.replace('[res_id]',data.station[i].res_id);
- tempHTML = tempHTML.replace('[showtime]',data.station[i].start_time);
- if (sel == data.station[i].res_id) {
- tempHTML = tempHTML.replace('images/a3/ic_select_nor.png','images/a3/ic_select_sel.png');
- } else{
- tempHTML = tempHTML.replace('images/a3/ic_select_nor.png','images/a3/ic_select_nor.png');
- }
-
- // tempHTML = tempHTML.replace('images/a3/ic_select_sel.png','images/a3/ic_select_nor.png');
- html += tempHTML;
- }
- $('#wei_info').html(html);
- // html = html.replace('[poi]',data.area_name)
- $('#poi').html(data.area_name);
- $('#actionsheet_cancel').click(function(){
- $('#mask').click();
- })
- $('.weui_actionsheet_cell').click(function(){
-
- $('#'+select_id).html(this.innerHTML);
- $('#'+select_id).attr(sel_res_div,this.id);
- var seltime = $(this).attr('showtime');
- //添加选中图片
- // $(this).parent().eq(1).attr('src','images/a3/ic_select_sel.png');
-
-
-
- $('gotime').html(seltime);
- $('#mask').click();
- //修改去程的票种信息
- changeTicketInfoGo();
- })
- }
-
- //截取日期参数
- 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;
- }
|