|
-
- var data = getStorJson("payOrderInfo");
- //记录出发地站点数组
- var start_station_list = '';
- //记录目的地站点数组
- var end_station_list = '';
- //记录返程出发地站点数组
- var back_start_station_list = '';
- //记录返程目的地站点数组
- var back_end_station_list = '';
- //记录是否选择返程状态
- var ifback = 0;
- //上弹框
- var wei_infoHTML = '';
- //返程的startid
- var back_start_id = ''
- //返程的end_id
- var back_end_id = ''
- //返程结果的html()
- var HTML = '';
- //返程的html()
- var backHTML = '';
- //总页面html
- var allHTML = '';
- //票种数量的html
- var count_html = '';
- //去程和往返的交集库存
- var stockCount = 0;
- //定义一个 只记录去程库存 一般取消返程选中时 重置去程库存
- var stockCountTemp = 0;
- //记录可选择的票种数量
- var ticketCount = 0;
-
- var newHTML='';
-
- var curpage = 1;
-
- var thisdataStrShow = '';
-
- //去程
- var run_id = '';
- var line_id = '';
- var ticket = '';
-
- //返程
- var back_run_id = '';
- var back_line_id = '';
- var back_ticket = '';
-
-
- $(document).ready(function() {
- // put all your jQuery goodness in here.
- });
-
- window.onload = function(){
-
- wei_infoHTML = $('#wei_info').html();
- HTML = $('#list_info').html();
- backHTML = $('#select_back_div').html();
- allHTML = $('#back_info').html();
- count_html = $('#seat_count_info').html();
-
- var run_id = data.run_id;
- var start_area_id = data.start_area_id;
- var end_area_id = data.end_area_id;
- //返程
- back_start_id = data.end_area_id;
- back_end_id = data.start_area_id;
- //展示去程信息
- showGoInfo(run_id,start_area_id,end_area_id);
-
-
- }
- //展示去程信息
- function showGoInfo(run_id,start_area_id,end_area_id){
- $.ajax({
- url:'./zz-fx/control.php',
- type: "post",
- data: {
- run_id:data.run_id,
- start_area_id:data.start_area_id,
- end_area_id:data.end_area_id,
- back:1,
- type:"retrieval_site"
- },
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- console.log(data);
- //去程信息的数据交互
- goInfoReloadData(data.list);
- }
- },
- fail: function (data) {
- // 此处放失败后执行的代码
- }
- });
- }
-
- //去程信息的数据交互
- function goInfoReloadData(data){
- var go_info_HTML = $('#go_info').html();
- var temp = go_info_HTML;
- temp = temp.replace('7月28日',data.date);
- temp = temp.replace('[出发地]',data.start_area_name);
- temp = temp.replace('[目的地]',data.end_area_name);
- $('#go_info').html(temp);
-
-
- start_station_list = data.start_order;
- end_station_list = data.end_order;
-
- // var start_station_html = '';
- // for (var i = 0 ; i < start_station_list.length; i ++) {
- // var tempHTML = wei_infoHTML;
- // tempHTML = tempHTML.replace('示例菜单',start_station_list[i].name);
- // tempHTML = tempHTML.replace('[id]',start_station_list[i].id);
- // start_station_html += tempHTML;
- // }
- // $('#wei_info').html(start_station_html);
- $('#up_station_time').html(start_station_list[0].name);
- $('#up_station_time').attr('valId',start_station_list[0].id);
-
- // var end_station_html = '';
- // for (var i = 0 ; i < end_station_list.length; i ++) {
- // var tempHTML1 = wei_infoHTML;
- // tempHTML1 = tempHTML1.replace('示例菜单',end_station_list[i].name);
- // tempHTML1 = tempHTML1.replace('[id]',end_station_list[i].id);
- // end_station_html += tempHTML1;
- // }
- // $('#wei_info').html(end_station_html);
- $('#down_station_time').html(end_station_list[0].name);
- $('#down_station_time').attr('valId',end_station_list[0].id);
-
- run_id = data.run_id;
- line_id = data.line_id;
- var start_id = $('#up_station_time').attr('valid');
- var end_id = $('#down_station_time').attr('valid');
- ticket = data.ticket;
- bus_type = data.bus_type;
- //犹豫异步加载的问题 所以只能在展示数据后 继续调用票种价格等相关信息
- $.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) {
- // 此处放失败后执行的代码
- }
- });
- }
-
-
-
-
-
- //替换去程票种数量信息
- function showCountInfoByGo(data){
- var html1 = '';
- var temp1 = count_html;
- temp1 = temp1.replace('普通座',data.site_type);
- temp1 = temp1.replace('50元',data.price);
- //数量
- var maxCount = data.num > 20 ? 20 : data.num;
- maxCount = maxCount>0 ? maxCount : 0;
-
- stockCount = maxCount;
- stockCountTemp = maxCount;
-
- html1 += temp1;
- $('#seat_count_info').html(html1);
- //
- // if (stockCount == 0) {
- // var count_replace = '';
- // $('#ifback').attr('disabled','disabled');
- // for (var i = 0 ; i <= stockCount; i ++) {
- // var tempHTML2 = '<option value="[0]">[-]</option>';
- // tempHTML2 = tempHTML2.replace('[0]',i);
- // tempHTML2 = tempHTML2.replace('[-]','无库存');
- // count_replace += tempHTML2;
- // }
- // $('#count_station').html(count_replace);
- // } else{
- // var count_replace = '';
- // for (var i = 0 ; i <= stockCount; i ++) {
- // var tempHTML2 = '<option value="[0]">[-]</option>';
- // tempHTML2 = tempHTML2.replace('[0]',i);
- // tempHTML2 = tempHTML2.replace('[-]',i);
- // count_replace += tempHTML2;
- // }
- // $('#count_station').html(count_replace);
- // }
- // var select_count = $('#count_station').val();
- // var totalPrice = parseFloat(select_count)*parseFloat(data.price);
- // $('#total').html(totalPrice);
- // ticket_id = data.ticket_id;
- // back_back_id = data.back_back_id;
- }
-
- //增加购买数量
- function addition(){
- if (ticketCount<stockCount) {
- ticketCount ++ ;
- $('#adult').val(ticketCount);
- }else{
- alert('无法购买更多!');
- }
- }
-
- //减法购买数量
- function subtraction(){
- if (ticketCount>0) {
- ticketCount --;
- $('#adult').val(ticketCount);
- }else{
- alert('请选择正确的票种数量!');
- }
- }
-
-
-
- //上弹框的内容封装
- 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(){
- $('#'+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) {
- // 此处放失败后执行的代码
- }
- });
-
-
- }
-
- })
- }
-
- //选择站点的下侧弹层
- $("#start_area").click(function(){
- upDiv(start_station_list,'up_station_time','go');
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
- $("#end_area").click(function(){
- upDiv(end_station_list,'down_station_time','go');
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
-
- $('#mask').click(function(){
- $("#mask").css("display","none");
- $("#weui_actionsheet").removeClass("weui_actionsheet_toggle");
- })
-
-
- //选择日期
- $(document).ready(function(){
- var tomonth = new Date();
-
- $("#ifback").on("click",function(){
- if (ifback == 1) {
- ifback = 0;
- $('#back_info').addClass('ui_hide');
- $('#ifandback').addClass('ui_hide');
- stockCount = stockCountTemp;
- }else{
- addmouth($(".month"),tomonth.getFullYear(),tomonth.getMonth());
- $(".month").show();
- $("#order_detail_info").hide();
- $("#back_info").removeClass('ui_hide');
- $('#ifandback').removeClass('ui_hide');
- selectDate();
- }
- });
- })
- //选中日期
- function selectDate(){
- $(".canday").on("click",function(){
- ifback = 1;
- if($(this).html()=="今天"){
- var seldate = new Date().getDate();
- }else{
- var seldate =$(this).html();
- }
- var yearmonth = $(".currentdate").html().split("年");
-
- if (yearmonth[1] != 10 || yearmonth[1] != 11 || yearmonth[1] != 12) {
- var show_yearmonth = '0'+yearmonth[1];
- }
- if (seldate<10) {
- var show_seldate = '0'+seldate;
- }else{
- var show_seldate = seldate;
- }
- //前台展示
- thisdataStrShow = yearmonth[1]+'月'+seldate+'日';
- //后台传参
- var thisdataStrSend = yearmonth[0]+"-"+show_yearmonth+"-"+show_seldate;
- //获取星期
- var thisdata = yearmonth[0]+"/"+yearmonth[1]+"/"+seldate;
- var select_week = getWeekDay(thisdata);
- // $("#nowdate").html(thisdataStrShow);
- // $('#nowdate').attr('sendStr',thisdataStrSend);
- // $('#nowWeek').html(select_week);
- // $(".month").hide();
- // $("#order_detail_info").show();
-
- //根据返程日期 调用数据
- reloadBackData(thisdataStrSend);
- })
- }
- //加载返程数据
- function reloadBackData(backtime){
- $.ajax({
- url:'./zz-fx/control.php', //请求地址
- type: "post", //请求方式
- // data: data, //请求参数
- data:{
- start_area : back_start_id,
- end_area : back_end_id,
- go_time : backtime,
- bus_type : data.bus_type,
- type:"retrieval_through",
- run_type:1,
- currpage:1,
- pagesize:data.pagesize
- },
- async:false,
- dataType: "json",
- success: function (data) {
- console.log(data);
- if(data.code == 0){
- var sum = data.totalnum;
- if (sum == 0) {
- alert('没有返程相关班次,请重新选择!')
- return;
- }else{
- $(".month").hide();
- $('#back_search_results').removeClass('ui_hide');
- $('#order_detail_info').addClass('ui_hide');
- //替换返程数据信息
- replaceBackInfo(data);
- }
- }
- },
- fail: function (date) {
- }
- });
- }
-
- //替换返程数据信息
- function replaceBackInfo(data){
- var list = data.list;
- $('#select_date_a').html(thisdataStrShow);
-
- for(var i=0;i<list.length;i++){
- var tempHTML=HTML;
-
- tempHTML=tempHTML.replace('[出发地]',list[i].start_area_name);
- tempHTML=tempHTML.replace('[目的地]',list[i].end_area_name);
- tempHTML=tempHTML.replace('[时间]',list[i].start_time);
- tempHTML=tempHTML.replace('[价格]',list[i].price);
- console.log(list[i].line_id);
- tempHTML=tempHTML.replace('[order_id]',list[i].run_id);
- tempHTML=tempHTML.replace('[order_idli]',list[i].run_id);
- tempHTML=tempHTML.replace('[start_id]',list[i].start_area_id);
- tempHTML=tempHTML.replace('[end_id]',list[i].end_area_id);
- tempHTML=tempHTML.replace('[start_name]','\''+list[i].start_area_name+'\'');
- tempHTML=tempHTML.replace('[end_name]','\''+list[i].end_area_name+'\'');
- newHTML+=tempHTML;
- }
- $('#list_info').html(newHTML);
- }
-
- //每个详情的点击事件
- function goPayInfo(id,start_id,end_id,start_name,end_name){
- $('#order_detail_info').removeClass('ui_hide');
- $('#order_detail_info').show();
- $('#back_search_results').addClass('ui_hide');
- var newhtml = '';
- var temp = allHTML;
- temp = temp.replace('7月28日',thisdataStrShow);
- temp = temp.replace('[出发地]',start_name);
- temp = temp.replace('[目的地]',end_name);
- $('#back_info').html(temp);
-
- $.ajax({
- url:'./zz-fx/control.php',
- type: "post",
- data: {
- run_id:id,
- start_area_id:start_id,
- end_area_id:end_id,
- back:2,
- type:"retrieval_site"
- },
- dataType: "json",
- success: function (data) {
- if(data.code == 0){
- console.log(data);
- //返程信息的数据交互
- backInfoReloadData(data.list);
- }
- },
- fail: function (data) {
- // 此处放失败后执行的代码
- }
- });
-
- }
-
- //返程站点信息的数据交互
- function backInfoReloadData(data){
- back_start_station_list = data.start_order;
- back_end_station_list = data.end_order;
-
- $('#back_up_station_time').html(back_start_station_list[0].name);
- $('#back_up_station_time').attr('valId',back_start_station_list[0].id);
-
- $('#back_down_station_time').html(back_end_station_list[0].name);
- $('#back_down_station_time').attr('valId',back_end_station_list[0].id);
-
-
-
-
- //选择站点的下侧弹层
- $("#back_up_station").click(function(){
- upDiv(back_start_station_list,'back_up_station_time','back');
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
-
- $("#back_down_station").click(function(){
- upDiv(back_end_station_list,'back_down_station_time','back');
- $("#mask").css("display","block");
- $("#weui_actionsheet").addClass("weui_actionsheet_toggle");
- })
-
- back_ticket = data.ticket;
- back_run_id = data.run_id;
- back_line_id = data.line_id;
-
- 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 showCountInfoByBack(data){
- var html1 = '';
- var temp1 = count_html;
- temp1 = temp1.replace('[座位等级]',data.site_type);
- temp1 = temp1.replace('[价格]',parseFloat(data.price)*2);
- //数量
- var maxCount = data.num > 20 ? 20 : data.num;
- maxCount = maxCount>0 ? maxCount : 0;
-
- stockCount = maxCount < stockCount ? maxCount : stockCount;
-
- html1 += temp1;
- $('#seat_count_info').html(html1);
- }
|