|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768 |
- var total_price = 0;
- var total_no = 1;
- var prod_Arr = [];
- var category_id = getStorage("category_id");
- var pro_cate_id = getStorage("pro_cate_id");
- var pro_cate_name = "";
- var run_date = after(getDateTime(0));
- var back_run_date = after(getDateTime(0));
- var go_year = getMonthAndDayByDate(run_date, 'year');
- var go_month = getMonthAndDayByDate(run_date, 'month');
- var go_day = getMonthAndDayByDate(run_date, 'day');
- var back_year = getMonthAndDayByDate(back_run_date, 'year');
- var back_month = getMonthAndDayByDate(back_run_date, 'month');
- var back_day = getMonthAndDayByDate(back_run_date, 'day');
- var car_id = "";
- var back_car_id = "";
- var go_back = "0";
- var run_date_list = [];
-
- var bus_stock = -1; //后台实时库存
-
- var back_station_prod = [];
- var back_prod_arr = [];
- var back_date_list = [];
- $(document).ready(function() {
-
- ifLogin(function(flag) {
- $('body').show();
- httpLoadInfo();
- });
-
- });
-
- function httpLoadInfo() {
- get_data();
- $("#go_run_date").text(go_month + "月" + go_day + "日");
- // $("#back_run_date").text(back_month + "月" + back_day + "日");
- $("#back_run_date").text('请选择');
- $("#go_sel_date").text(go_month + "月" + go_day + "日");
- $(".model").on("click", function() {
- $('.model_box').addClass('fadeInDown animated');
- setTimeout(function() {
- $('.model').hide();
- $('#body_mod').removeClass('mod_fil');
- }, 400);
- // $(".model_box").animate({
- // height: "hide"
- // }, 400, function() {
- // $(".model").hide();
- // $("#body_mod").removeClass("mod_fil");
- // });
- });
- $(".model_car").on("click", function() {
- $('.model_box_car').addClass('fadeInDown animated');
- setTimeout(function() {
- $('.model_car').hide();
- $('#body_mod').removeClass('mod_fil');
- }, 400);
- // $(".model_box_car").animate({
- // height: "hide"
- // }, 400, function() {
- // $(".model_car").hide();
- // $("#body_mod").removeClass("mod_fil");
- // });
- });
-
- $(".model_box").on("click", function(e) {
- e.stopPropagation();
- });
- $(".model_box_car").on("click", function(e) {
- e.stopPropagation();
- });
- }
-
- function get_data() {
- $.ajax({
- url: base_api + "prod/prod/get-prod-detail", //请求地址
- data: {
- pro_cate_id: pro_cate_id,
- category_id: category_id
- },
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- run_date_list = data.data.run_date;
- ZZLog(data);
- if(data.flag) {
- list_html(data.data);
- $("#bg_img").css("background-image", "url(" + data.data.show_img + ")");
- $(".top_title").text(data.data.pro_cate_name);
- pro_cate_name = data.data.pro_cate_name;
- } else {
- if(codeNotLogin == data['code']) {
- alert(infoNotLogin);
- var URL = '/web/fx/landmark_ticket.html';
- URL = encodeURI(URL);
- location.href = data['url'] + URL;
- } else if(codeNotRegister == res_data['code']) {
- location.href = 'register.html';
- } else {
- alert(data['msg']);
- }
- }
- },
- error: function(error) {
- console.log(error);
- }
- });
- }
-
- function list_html(data) {
- var temp = "";
- for(var i = 0, j = data.prod_arr.length; i < j; i++) {
- var img = 'images/jianhao.png';
- var str = '<span class="ulev3 count aticket" type="text" readonly="true" one_price="' + data.prod_arr[i].prod_price + '" prod_name="' + data.prod_arr[i].prod_name + '" prod_id="' + data.prod_arr[i].prod_id + '">0</span>';
- if(i == 0) {
- img = 'images/jianhao_sel.png';
- str = '<span class="ulev3 count aticket" type="text" readonly="true" one_price="' + data.prod_arr[i].prod_price + '" prod_name="' + data.prod_arr[i].prod_name + '" prod_id="' + data.prod_arr[i].prod_id + '">1</span>'
- }
- temp += '<div class="ub ub-ver disney_div">' +
- '<div style="padding-bottom: 0.12rem;">' + data.prod_arr[i].prod_name + '</div>' +
- '<div class="ub">' +
- '<div class="ub-f1 ub">' +
- '<img class="cut" style="width: 0.22rem;height: 0.22rem;vertical-align: middle;" src="' + img + '"/>' +
- str +
- // '<span class="ulev3 count aticket" type="text" readonly="true" one_price="' + data.prod_arr[i].prod_price + '" prod_name="' + data.prod_arr[i].prod_name + '" prod_id="' + data.prod_arr[i].prod_id + '">0</span>' +
- '<img class="add" style="width: 0.22rem;height: 0.22rem;vertical-align: middle;" src="images/jiahao_sel.png"/>' +
- '</div>' +
- '<div class="ub-f1 ub tx-r">' +
- '<div class="ub-f1 ub ub-pe ub-ae font_price" >¥</div>' +
- '<div class="ulev3 ub ub-ae font_price single_price" data-price="' + data.prod_arr[i].prod_price + '" style="line-height: 1;">' + data.prod_arr[i].prod_price + '<span class="font_price" style="font-size:0.12rem">/张</span></div>' +
- '</div>' +
- '</div>' +
- '</div>'
- }
- $("#tick_type").html(temp);
- //订票须知
- if(data.booking_notice) {
- var booking_notice_arr = data.booking_notice.split('<br/>');
- var bnHTML = '';
- for(var i = 0, m = booking_notice_arr.length; i < m; i++) {
- // bnHTML += `<div class="font_gray">${booking_notice_arr[i]}</div>`;
- bnHTML += '<div class="font_gray">' + booking_notice_arr[i] + '</div>';
- }
- $(".booking_notice").html(bnHTML);
- }
-
- //加
- $(".add").on("touchstart", function() {
- if(pro_cate_id == "3") {
- // var tot_no = 0;
- $(".aticket").each(function(index, domE) {
- total_no += parseInt($(this).text());
- });
- if(total_no == 5) {
- alert("迪士尼最多只能买五张票");
- } else {
- var current = $(this).parent().find(".aticket").text();
- var now_count = parseInt(current) + 1;
- $(this).parent().find(".aticket").text(now_count);
- $(this).parent().find(".cut").attr("src", "images/jianhao_sel.png");
- // countTotal();
- }
- } else {
- var current = $(this).parent().find(".aticket").text();
- var now_count = parseInt(current) + 1;
- $(this).parent().find(".aticket").text(now_count);
- $(this).parent().find(".cut").attr("src", "images/jianhao_sel.png");
- // countTotal();
- }
-
- });
-
- //减
- $(".cut").on("touchstart", function() {
- var current = $(this).parent().find(".aticket").text();
- var now_count = parseInt(current) - 1;
- if(now_count > 0) {
- $(this).parent().find(".aticket").text(now_count);
- } else {
- $(this).parent().find(".aticket").text('0');
- $(this).attr("src", "images/jianhao.png");
- }
- // countTotal();
- })
- }
-
- //总价
- function countTotal() {
- total_price = 0;
- prod_Arr = [];
- prod_info = "";
- total_no = 0;
- var tick_no = '';
- back_prod_arr = [];
- $(".aticket").each(function(index, domE) {
- tick_no = parseInt($(this).text());
- var tick_price = parseFloat($(this).attr("one_price"));
- var back_tick_price = 0;
- var back_prod_id = 0;
- var go_back = $("#if_back").attr("go_back");
- if(go_back == 1) {
- back_tick_price = back_station_prod[index]['prod_price'] - 0;
- back_prod_id = back_station_prod[index]['prod_id'];
- var obj = {
- "prod_id": back_prod_id,
- "prod_count": $(this).text(),
- "prod_name": $(this).attr('prod_name')
- }
- back_prod_arr.push(obj);
- }
- total_price = (total_price * 100 + tick_no * tick_price * 100) / 100;
- total_no += tick_no;
- prod_info = {
- "prod_id": $(this).attr("prod_id"),
- "prod_count": $(this).text(),
- "prod_name": $(this).attr("prod_name")
- }
- prod_Arr.push(prod_info);
- });
- // console.log(total_price);
- // console.log(prod_Arr);
- // console.log(total_no);
-
- }
- //选择去程日期
- $("#go_date_select").on("click", function() {
- $('.model_box').removeClass('fadeInUp');
- $('.model_box').removeClass('animated');
- $('.model_box').removeClass('fadeInDown');
- $("#go_sel_date").text(go_month + "月" + go_day + "日");
- var caType = window.calendar.init.showTypeEnum.show_customer;
- window.calendar.init({
- showType:caType,
- startDate: getDateTime(0),
- chooseDate: run_date,
- showDays:run_date_list
- }, function(year, month, day, ymdString) {
- $('.model_box').addClass('fadeInDown animated');
- setTimeout(function() {
- $('.model').hide();
- $('#body_mod').removeClass('mod_fil');
- }, 400);
- // $(".model_box").animate({
- // height: "hide"
- // }, 400, function() {
- // $(".model").hide();
- // $("#body_mod").removeClass("mod_fil");
- // });
- run_date = ymdString;
- go_year = year;
- go_month = month;
- go_day = day;
- if(run_date > back_run_date) {
- back_run_date = ymdString;
- back_year = year;
- back_month = month;
- back_day = day;
- // $("#back_run_date").text(month + "月" + day + "日");
- $("#back_run_date").text('请选择');
- $("#back_show_class").text("请选择");
- $("#back_show_class").removeAttr("back_time");
- $("#back_show_class").removeAttr("back_run_id");
- $("#back_show_class").removeAttr("back_cate_name");
- back_car_id = "";
-
- }
- $("#go_run_date").text(month + "月" + day + "日");
- $("#go_sel_date").text(month + "月" + day + "日");
- console.log(year, month, day, ymdString);
- // 2017 04 12 2017-04-12
- //重新选择日期后班次要重新选
- $("#go_show_class").text("请选择");
- $("#go_show_class").removeAttr("go_time");
- $("#go_show_class").removeAttr("go_run_id");
- $("#go_show_class").removeAttr("go_cate_name");
- car_id = "";
-
- });
- $(".model").show();
- $('.model_box').show();
- $("#body_mod").addClass("mod_fil");
- $('.model_box').addClass('fadeInUp animated');
- // $(".model_box").animate({
- // height: "show"
- // }, 400);
-
- });
-
- //选择去程班次
- $("#go_classes").on("click", function() {
- $('.model_box_car').removeClass('fadeInUp');
- $('.model_box_car').removeClass('animated');
- $('.model_box_car').removeClass('fadeInDown');
- $('#back_run_date').html('请选择');
- $.ajax({
- url: base_api + "prod/prod/get-bus-stock", //请求地址
- data: {
- pro_cate_id: pro_cate_id,
- date: run_date
- },
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- console.log(data)
- if(data.flag) {
- go_car_html(data.data);
- $(".model_car").show();
- $('.model_box_car').show();
- $("#body_mod").addClass("mod_fil");
- $('.model_box_car').addClass('fadeInUp animated');
- // $(".model_car").show();
- // $("#body_mod").addClass("mod_fil");
- // $(".model_box_car").animate({
- // height: "show"
- // }, 400);
-
- } else {
- if(codeNotLogin == data['code']) {
- alert(infoNotLogin);
- var URL = 'landmark_ticket.html';
- URL = encodeURI(URL);
- location.href = data['url'] + URL;
- } else {
- alert(data['msg']);
- }
- }
- },
- error: function(error) {
- console.log(error);
- }
- });
- });
-
- //替换去程班次信息
- function go_car_html(data) {
- var temp = "";
- var run_status = "";
- var run_count = "";
- for(var key in data.prod_info) {
- var prod_list = data.prod_info[key];
- var p_obj = prod_list[0];
- var may_sel = "";
- var may_info = "";
- var may_col = "";
- var select_car = "";
- run_status = p_obj.run_status;
- run_count = p_obj.count;
- if(run_status == 142) {
- may_sel = "select_kong";
- may_info = "已停运";
- may_col = "text_c_cc";
- select_car = "select_car_off";
- } else if(run_status != "138") {
- may_sel = "select_kong";
- may_info = "已发车";
- may_col = "text_c_cc";
- select_car = "select_car_off";
- } else {
- if(run_count == "0") {
- may_sel = "select_kong";
- may_info = "已售罄";
- may_col = "text_c_cc";
- select_car = "select_car_off";
- } else {
- may_sel = "select_quan";
- may_info = "余票充足";
- may_col = "text_c_80";
- select_car = "select_car_on";
- }
- }
- temp += '<div run_status = "' + p_obj.run_status + '" run_count = "' + run_count + '" cate_name="' + p_obj.station_str + '" id="' + p_obj.run_id + '" go_time="' + p_obj.start_time + '" class="ub ub-ac bor_b_e5 ' + select_car + '">' +
- '<div class="ui_p_t12 ui_p_b12 ui_p_l15 ui_p_r20 ulev1 ' + may_col + '">' + p_obj.start_time + '</div>' +
- '<div class="ub-f1 ' + may_col + '">' + may_info + '</div>' +
- '<div class="ui_p_r15 ui_p_t10 ui_p_b10 ui_p_l15">' +
- '<div class="' + may_sel + ' selected"></div>' +
- '</div>' +
- '</div>'
- }
-
- $("#sel_car").html(temp);
- if($("#" + car_id).attr("run_status") == "138" && $("#" + car_id).attr("run_count") != "0") {
- $("#" + car_id).find(".selected").removeClass("select_quan");
- $("#" + car_id).find(".selected").addClass("select_gou");
- }
- $(".select_car_on").on("click", function() {
- car_id = $(this).attr("id");
- //获取库存
- if(bus_stock==-1){
- bus_stock = $(this).attr('run_count')-0;
- }else{
- var t_stock = $(this).attr('run_count')-0;
- bus_stock = bus_stock>t_stock?t_stock:bus_stock;
- }
- var go_time = $(this).attr("go_time");
- var go_run_id = $(this).attr("id");
- var go_cate_name = $(this).attr("cate_name");
- $("#sel_car").find(".selected").removeClass("select_gou");
- $("#sel_car").find(".selected").addClass("select_quan");
- $(this).find(".selected").removeClass("select_quan");
- $(this).find(".selected").addClass("select_gou");
- $('.model_box_car').addClass('fadeInDown animated');
- setTimeout(function() {
- $('.model_car').hide();
- $('#body_mod').removeClass('mod_fil');
- }, 400);
- // $(".model_box_car").animate({
- // height: "hide"
- // }, 400, function() {
- // $(".model_car").hide();
- // $("#body_mod").removeClass("mod_fil");
- // });
- $("#go_show_class").text(go_time + "发车");
- $("#go_show_class").attr("go_time", go_time);
- $("#go_show_class").attr("go_run_id", go_run_id);
- $("#go_show_class").attr("go_cate_name", go_cate_name);
- });
-
- }
- //、、、、、、、、、、、、、、、、、、、、、去程结束、返程开始、、、、、、、、、、、、、、、、、、//
-
- //选择返程日期
- $("#back_date_select").on("click", function() {
- if($('#go_show_class').html() == '请选择'){
- alert('请选择去程班次');
- return;
- }
- $.ajax({
- url: base_api + "prod/prod/get-bus-sale-date", //请求地址
- data: {
- pro_cate_id: pro_cate_id,
- if_back: '1'
- },
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- ZZLog(data);
- if(data.flag) {
- back_date_list = data.data.list;
- } else {
- alert('未获取到后台数据');
- }
- },
- error: function(error) {
- alert('未获取到后台数据');
- }
- });
- $('.model_box').removeClass('fadeInUp');
- $('.model_box').removeClass('animated');
- $('.model_box').removeClass('fadeInDown');
- $("#go_sel_date").text(back_month + "月" + back_day + "日");
- var baType = window.calendar.init.showTypeEnum.show_customer;
- window.calendar.init({
- showType:baType,
- startDate: run_date,
- chooseDate: back_run_date,
- showDays:back_date_list
- }, function(year, month, day, ymdString) {
- $('.model_box').addClass('fadeInDown animated');
- setTimeout(function() {
- $('.model').hide();
- $('#body_mod').removeClass('mod_fil');
- }, 400);
- // $(".model_box").animate({
- // height: "hide"
- // }, 400, function() {
- // $(".model").hide();
- // $("#body_mod").removeClass("mod_fil");
- // });
- back_run_date = ymdString;
- back_year = year;
- back_month = month;
- back_day = day;
- if(run_date > back_run_date) {
- back_run_date = ymdString;
- $("#back_run_date").text(month + "月" + day + "日");
- }
- $("#back_run_date").text(month + "月" + day + "日");
- $("#go_sel_date").text(month + "月" + day + "日");
-
- $("#back_show_class").text("请选择");
- $("#back_show_class").removeAttr("back_time");
- $("#back_show_class").removeAttr("back_run_id");
- $("#back_show_class").removeAttr("back_cate_name");
- back_car_id = "";
-
- });
- $(".model").show();
- $('.model_box').show();
- $("#body_mod").addClass("mod_fil");
- $('.model_box').addClass('fadeInUp animated');
- // $(".model_box").animate({
- // height: "show"
- // }, 400);
-
- });
-
- //选择返程班次
- $("#back_classes").on("click", function() {
- if($('#go_show_class').html() == '请选择'){
- alert('请选择去程班次');
- return;
- }
- if($('#back_run_date').html() == '请选择'){
- alert('请选择返程日期');
- return;
- }
- $('.model_box_car').removeClass('fadeInUp');
- $('.model_box_car').removeClass('animated');
- $('.model_box_car').removeClass('fadeInDown');
- $.ajax({
- url: base_api + "prod/prod/get-bus-stock", //请求地址
- data: {
- pro_cate_id: pro_cate_id,
- date: back_run_date,
- if_back: "1"
- },
- type: "post",
- dataType: "json",
- async: false,
- success: function(data) {
- console.log(data)
- if(data.flag) {
- back_car_html(data.data);
- $(".model_car").show();
- $('.model_box_car').show();
- $("#body_mod").addClass("mod_fil");
- $('.model_box_car').addClass('fadeInUp animated');
- // $(".model_car").show();
- // $("#body_mod").addClass("mod_fil");
- // $(".model_box_car").animate({
- // height: "show"
- // }, 400);
-
- } else {
- if(codeNotLogin == data['code']) {
- alert(infoNotLogin);
- var URL = 'landmark_ticket.html';
- URL = encodeURI(URL);
- location.href = data['url'] + URL;
- } else {
- alert(data['msg']);
- }
- }
- },
- error: function(error) {
- console.log(error);
- }
- });
- });
-
- //替换返程班次信息
- function back_car_html(data) {
- var temp = "";
- var run_status = "";
- var run_count = "";
- for(var key in data.prod_info) {
- var prod_list = data.prod_info[key];
- var p_obj = prod_list[0];
- var may_sel = "";
- var may_info = "";
- var may_col = "";
- var select_car = "";
- run_status = p_obj.run_status;
- run_count = p_obj.count;
- if(run_status == 142) {
- may_sel = "select_kong";
- may_info = "已停运";
- may_col = "text_c_cc";
- select_car = "select_car_off";
- } else if(run_status != "138") {
- may_sel = "select_kong";
- may_info = "已发车";
- may_col = "text_c_cc";
- select_car = "select_car_off";
- } else {
- if(run_count == "0") {
- may_sel = "select_kong";
- may_info = "已售罄";
- may_col = "text_c_cc";
- select_car = "select_car_off";
- } else {
- may_sel = "select_quan";
- may_info = "余票充足";
- may_col = "text_c_80";
- select_car = "select_car_on";
- }
- }
- var obj = prod_list;
- obj.forEach(function(v, i) {
- v['station_str'] = v['station_str'].replace(/ /g, '');
- })
- temp += '<div dict=' + JSON.stringify(obj) + ' run_status = "' + p_obj.run_status + '" run_count = "' + run_count + '" cate_name="' + p_obj.station_str + '" id="' + p_obj.run_id + '" go_time="' + p_obj.start_time + '" class="ub ub-ac bor_b_e5 ' + select_car + '">' +
- '<div class="ui_p_t12 ui_p_b12 ui_p_l15 ui_p_r20 ulev1 ' + may_col + '">' + p_obj.start_time + '</div>' +
- '<div class="ub-f1 ' + may_col + '">' + may_info + '</div>' +
- '<div class="ui_p_r15 ui_p_t10 ui_p_b10 ui_p_l15">' +
- '<div class="' + may_sel + ' selected"></div>' +
- '</div>' +
- '</div>'
- }
- $("#sel_car").html(temp);
- if($("#" + back_car_id).attr("run_status") == "138" && $("#" + back_car_id).attr("run_count") != "0") {
- $("#" + back_car_id).find(".selected").removeClass("select_quan");
- $("#" + back_car_id).find(".selected").addClass("select_gou");
- }
- $(".select_car_on").on("click", function() {
- back_car_id = $(this).attr("id");
- //获取库存
- if(bus_stock==-1){
- bus_stock = $(this).attr('run_count')-0;
- }else{
- var t_stock = $(this).attr('run_count')-0;
- bus_stock = bus_stock>t_stock?t_stock:bus_stock;
- }
- var back_time = $(this).attr("go_time");
- var back_run_id = $(this).attr("id");
- var back_cate_name = $(this).attr("cate_name");
- //update 201705231337
- back_station_prod = $(this).attr('dict');
- back_station_prod = JSON.parse(back_station_prod);
- back_pro_cate_id = data.pro_cate_id;
- //选择班次的时候将返程的价格显示上去
- $('.single_price').each(function(index, dom) {
- var price = parseFloat($(this).attr('data-price')) - 0;
-
- var price_2 = (parseFloat(price) + parseFloat(back_station_prod[index]['prod_price'])) - 0;
-
- // $(this).attr('data-price', price_2); //false TODO选择返程的班次时更改票种的价格-现定义data-price为单程价格 注释后:始终存为去程的价格
- $(this).html(price_2 + '<span class="font_price" style="font-size:0.12rem">/张</span>');
- })
-
- $("#sel_car").find(".selected").removeClass("select_gou");
- $("#sel_car").find(".selected").addClass("select_quan");
- $(this).find(".selected").removeClass("select_quan");
- $(this).find(".selected").addClass("select_gou");
- $('.model_box_car').addClass('fadeInDown animated');
- setTimeout(function() {
- $('.model_car').hide();
- $('#body_mod').removeClass('mod_fil');
- }, 400);
- // $(".model_box_car").animate({
- // height: "hide"
- // }, 400, function() {
- // $(".model_car").hide();
- // $("#body_mod").removeClass("mod_fil");
- // });
- $("#back_show_class").text(back_time + "发车");
- $("#back_show_class").attr("back_time", back_time);
- $("#back_show_class").attr("back_run_id", back_run_id);
- $("#back_show_class").attr("back_cate_name", back_cate_name);
- });
-
- }
-
- function reserve() {
- countTotal();
- var go_time = $("#go_show_class").attr("go_time");
- var back_time = $("#back_show_class").attr("back_time");
- var go_run_id = $("#go_show_class").attr("go_run_id");
- var back_run_id = $("#back_show_class").attr("back_run_id");
- var go_cate_name = $("#go_show_class").attr("go_cate_name");
- var back_cate_name = $("#back_show_class").attr("back_cate_name");
- var fill_order_20170307 = "";
- go_back = $("#if_back").attr("go_back");
- if(total_no == "0") {
- alert("请选择票种数量");
- } else {
- if(bus_stock<total_no){
- alert('库存不足');
- return;
- }
- if(go_back == "0") {
- if(go_run_id) {
- fill_order_20170307 = {
- "pro_cate_id": pro_cate_id,
- "if_back": go_back, //只有去程 0 往返 1
- "prod_arr": prod_Arr,
- "total_money": total_price,
- "go_info": {
- "go_start_date": run_date,
- "go_start_time": go_time,
- "go_run_id": go_run_id,
- "go_pro_cate_name": go_cate_name
- },
- "back_info": {}
- }
- console.log(fill_order_20170307);
- setStorJson("fill_order_20170307", fill_order_20170307);
- window.location.href = "fill_order.html?" + version;
- } else {
- alert("请选择去程班次");
- }
-
- } else {
- //往返程票价必须一样,所以可以按*2算,白哥说的。
- if(go_run_id && back_run_id) {
- fill_order_20170307 = {
- "pro_cate_id": pro_cate_id,
- "back_pro_cate_id": back_pro_cate_id,
- "if_back": go_back, //只有去程 0 往返 1
- "prod_arr": prod_Arr,
- "back_prod_arr": back_prod_arr, //update 2017-05-23
- "total_money": total_price * 2,
- "go_info": {
- "go_start_date": run_date,
- "go_start_time": go_time,
- "go_run_id": go_run_id,
- "go_pro_cate_name": go_cate_name
- },
- "back_info": {
- "back_start_date": back_run_date,
- "back_start_time": back_time,
- "back_run_id": back_run_id,
- "back_pro_cate_name": back_cate_name
- }
- }
- console.log(fill_order_20170307);
- setStorJson("fill_order_20170307", fill_order_20170307);
- window.location.href = "fill_order.html?" + version;
- } else {
- alert("请选择班次");
- }
-
- }
-
- }
-
- }
-
- //添加或取消返程
- $(".sel_back_btn").on("click", function() {
- go_back = $(this).attr("go_back");
- if(go_back == "0") {
- $("#back_date").animate({
- height: "show"
- }, 200);
- $(this).attr("go_back", "1");
- $(this).text("取消返程");
- $(this).removeClass("sel_back_btn");
- $(this).addClass("cancel_back_btn");
-
- } else {
- if($('#back_show_class').text() != '请选择') {
- $('.single_price').each(function(index, dom) {
- var price = parseFloat($(this).attr('data-price')) + 0;
- // var price_2 = price / 2 + 0; //false
- var price_2 = price - 0; //true
-
- $(this).attr('data-price', price_2);
- $(this).html(price_2 + '<span class="font_price" style="font-size:0.12rem">/张</span>');
- })
- }
- $("#back_date").animate({
- height: "hide"
- }, 200);
- $(this).attr("go_back", "0");
- $(this).text("添加返程");
- $(this).removeClass("cancel_back_btn");
- $(this).addClass("sel_back_btn");
- $("#back_show_class").text("请选择");
- $("#back_show_class").removeAttr("go_time");
- back_car_id = "";
-
- }
- });
|