|
|
|
|
|
|
|
/** loader */
|
|
|
|
function loaderOn() {
|
|
|
|
document.getElementById("loader").style.display = "block";
|
|
|
|
}
|
|
|
|
|
|
|
|
function loaderOff() {
|
|
|
|
document.getElementById("loader").style.display = "none";
|
|
|
|
}
|
|
|
|
function readData() {
|
|
|
|
window.roundTrip = sessionStorage.getItem('roundTrip');
|
|
|
|
window.isReturn = sessionStorage.getItem('isReturn');
|
|
|
|
window.DepartFlightStr = sessionStorage.getItem('DepartFlightStr');
|
|
|
|
window.DepartCabinStr = sessionStorage.getItem('DepartCabinStr');
|
|
|
|
window.ArriveFlightStr = sessionStorage.getItem('ArriveFlightStr');
|
|
|
|
window.ArriveCabinStr = sessionStorage.getItem('ArriveCabinStr');
|
|
|
|
$('#roundTrip').val(roundTrip);
|
|
|
|
$('#isReturn').val(isReturn);
|
|
|
|
$('#DepartFlightStr').val(DepartFlightStr);
|
|
|
|
$('#DepartCabinStr').val(DepartCabinStr);
|
|
|
|
$('#ArriveFlightStr').val(ArriveFlightStr);
|
|
|
|
$('#ArriveCabinStr').val(ArriveCabinStr);
|
|
|
|
window.DepartFlightInfo = sessionStorage.getItem('DepartFlightInfo');
|
|
|
|
window.DepartCabinInfo = sessionStorage.getItem('DepartCabinInfo');
|
|
|
|
window.ArriveFlightInfo = sessionStorage.getItem('ArriveFlightInfo');
|
|
|
|
window.ArriveCabinInfo = sessionStorage.getItem('ArriveCabinInfo');
|
|
|
|
if (!DepartFlightInfo && !ArriveFlightInfo) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (DepartFlightInfo) {
|
|
|
|
DepartFlightInfo = JSON.parse(DepartFlightInfo);
|
|
|
|
DepartCabinInfo = JSON.parse(DepartCabinInfo);
|
|
|
|
let citys = DepartFlightInfo.departCityIataNameEn + " - " + DepartFlightInfo.arriveCityIataNameEn;
|
|
|
|
let iconSrc = "https://data.chinahighlights.com/china-flights/images/icon/" + DepartFlightInfo.airLineIcon + ".gif";
|
|
|
|
$('#selected__one_airlineicon').attr('src', iconSrc);
|
|
|
|
$('#selected__one_airlineicon').attr('alt', DepartFlightInfo.showAirLineCompany);
|
|
|
|
$('#selected__one_airline').html(DepartFlightInfo.showAirLineCompany);
|
|
|
|
$('#selected__one_city').html(citys);
|
|
|
|
$('#selected__one_date').html(DepartFlightInfo.departDate);
|
|
|
|
$('#selected__one_arrdate').html(DepartFlightInfo.arriveDate);
|
|
|
|
$('#selected__one_cabinname').html(DepartCabinInfo.cabinClassNameEn.replace('Class', ''));
|
|
|
|
$('#selected__one_airline').html(DepartFlightInfo.showAirLineCompany);
|
|
|
|
$('#selected__one_flightinfo').html(DepartFlightInfo.flightNo + '/' + DepartFlightInfo.craftType);
|
|
|
|
$('#selected__one_detime').html(DepartFlightInfo.departTime);
|
|
|
|
$('#selected__one_arrtime').html(DepartFlightInfo.arriveTime);
|
|
|
|
$('#selected__one_fromairport').html(DepartFlightInfo.departAirportNameEn + '(' + DepartFlightInfo.departAirportTerminal + ')');
|
|
|
|
$('#selected__one_toairport').html(DepartFlightInfo.arriveAirportNameEn + '(' + DepartFlightInfo.arriveAirportTerminal + ')');
|
|
|
|
$('#selected__one_duration').html(DepartFlightInfo.duration);
|
|
|
|
let stopPic = '/airArrowDirect.png';
|
|
|
|
if (parseInt(DepartFlightInfo.stopNum) > 0) {
|
|
|
|
stopPic = '/airArrowStop.png';
|
|
|
|
let stopinfo = DepartFlightInfo.showStopCityName + "," + DepartFlightInfo.stoparrivalTime + "-" + DepartFlightInfo.stopdepartrueTime;
|
|
|
|
let stopinfoHtml = '<a href="javascript:;" title="' + stopinfo + '">' + DepartFlightInfo.stopCityCode + '</a>';
|
|
|
|
$('#selected__one_stopinfo').html(stopinfoHtml);
|
|
|
|
}
|
|
|
|
$('#selected__one_stoppic').attr('src', 'https://data.chinahighlights.com/css/images/flight'+stopPic);
|
|
|
|
}
|
|
|
|
if (ArriveFlightInfo && roundTrip == 'true') {
|
|
|
|
ArriveFlightInfo = JSON.parse(ArriveFlightInfo);
|
|
|
|
ArriveCabinInfo = JSON.parse(ArriveCabinInfo);
|
|
|
|
let citys = ArriveFlightInfo.departCityIataNameEn + " - " + ArriveFlightInfo.arriveCityIataNameEn;
|
|
|
|
let iconSrc = "https://data.chinahighlights.com/china-flights/images/icon/" + ArriveFlightInfo.airLineIcon + ".gif";
|
|
|
|
$('#selected__two_airlineicon').attr('src', iconSrc);
|
|
|
|
$('#selected__two_airlineicon').attr('alt', ArriveFlightInfo.showAirLineCompany);
|
|
|
|
$('#selected__two_airline').html(ArriveFlightInfo.showAirLineCompany);
|
|
|
|
$('#selected__two_city').html(citys);
|
|
|
|
$('#selected__two_date').html(ArriveFlightInfo.departDate);
|
|
|
|
$('#selected__two_arrdate').html(ArriveFlightInfo.arriveDate);
|
|
|
|
$('#selected__two_cabinname').html(ArriveCabinInfo.cabinClassNameEn.replace('Class', ''));
|
|
|
|
$('#selected__two_airline').html(ArriveFlightInfo.showAirLineCompany);
|
|
|
|
$('#selected__two_flightinfo').html(ArriveFlightInfo.flightNo + '/' + ArriveFlightInfo.craftType);
|
|
|
|
$('#selected__two_detime').html(ArriveFlightInfo.departTime);
|
|
|
|
$('#selected__two_arrtime').html(ArriveFlightInfo.arriveTime);
|
|
|
|
$('#selected__two_fromairport').html(ArriveFlightInfo.departAirportNameEn + '(' + ArriveFlightInfo.departAirportTerminal + ')');
|
|
|
|
$('#selected__two_toairport').html(ArriveFlightInfo.arriveAirportNameEn + '(' + ArriveFlightInfo.arriveAirportTerminal + ')');
|
|
|
|
$('#selected__two_duration').html(ArriveFlightInfo.duration);
|
|
|
|
let stopPic = '/airArrowDirect.png';
|
|
|
|
if (parseInt(ArriveFlightInfo.stopNum) > 0) {
|
|
|
|
stopPic = '/airArrowStop.png';
|
|
|
|
let stopinfo = ArriveFlightInfo.showStopCityName + "," + ArriveFlightInfo.stoparrivalTime + "-" + ArriveFlightInfo.stopdepartrueTime;
|
|
|
|
let stopinfoHtml = '<a href="javascript:;" title="' + stopinfo + '">' + ArriveFlightInfo.stopCityCode + '</a>';
|
|
|
|
$('#selected__two_stopinfo').html(stopinfoHtml);
|
|
|
|
}
|
|
|
|
$('#selected__two_stoppic').attr('src', 'https://data.chinahighlights.com/css/images/flight'+stopPic);
|
|
|
|
$('#selected__two').removeClass('hidden');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function changePassenger(e) {
|
|
|
|
an = parseInt($("#adultNum").val());
|
|
|
|
cn = parseInt($("#childNum").val() || 0);
|
|
|
|
bn = parseInt($("#babyNum").val() || 0);
|
|
|
|
|
|
|
|
//票数
|
|
|
|
var d_seats = a_seats = 99;
|
|
|
|
var d_seatStatus = DepartCabinInfo.seatStatus;//DepartCabinInfo.split('|')[7];
|
|
|
|
if (d_seatStatus != ">9") {
|
|
|
|
d_seats = parseInt(d_seatStatus.replace(/>/, ""));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (roundTrip == "true") {
|
|
|
|
var a_seatStatus = ArriveCabinInfo.seatStatus; //ArriveCabinInfo.split('|')[7];
|
|
|
|
if (a_seatStatus != ">9") {
|
|
|
|
a_seats = parseInt(a_seatStatus.replace(/>/, ""));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var isLimit = false;
|
|
|
|
if ((an + cn) > d_seats) {
|
|
|
|
isLimit = true;
|
|
|
|
} else if (roundTrip == "true") {
|
|
|
|
if (an + cn > a_seatStatus) {
|
|
|
|
isLimit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isLimit) {
|
|
|
|
alert('There aren\'t enough ticket in the flight!');
|
|
|
|
$(e).addClass("errSelect");
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
$(e).removeClass("errSelect");
|
|
|
|
}
|
|
|
|
|
|
|
|
//-------------
|
|
|
|
for (var i = 1; i <= 15; i++) {
|
|
|
|
if (i <= an) {
|
|
|
|
if ($("#adultItem" + i).length < 1) {
|
|
|
|
$("#adultItem1").clone().attr("id", "adultItem" + i).appendTo($("#AdultTb"));
|
|
|
|
$("#adultItem" + i).find("input[name='guestName[]']").attr("id", "guestName" + i).val("");
|
|
|
|
$("#adultItem" + i).find("input[name='guestpassport[]']").attr("id", "guestpassport" + i).val("");
|
|
|
|
$("#adultItem" + i).find("input[name='birthday[]']").attr("id", "birthday" + i).val("")
|
|
|
|
$("#adultItem" + i).find("label.passengertype").html("Adult " + i);
|
|
|
|
$("#birthday" + i).flatpickr({
|
|
|
|
dateFormat: "Y-m-d",
|
|
|
|
minDate: "1919-1-1",
|
|
|
|
maxDate: "today"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#adultItem" + i).remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i <= cn) {
|
|
|
|
if ($("#childItem" + i).length < 1) {
|
|
|
|
$("#adultItem1").clone().attr("id", "childItem" + i).appendTo($("#ChildTb"));
|
|
|
|
$("#childItem" + i).find("input[name='guestName[]']").attr({ "id": "guestNameCHD" + i }).val("");
|
|
|
|
$("#childItem" + i).find("input[name='guestpassport[]']").attr({ "id": "guestpassportCHD" + i }).val("");
|
|
|
|
$("#childItem" + i).find("input[name='birthday[]']").attr({ "id": "birthdayCHD" + i }).val("");
|
|
|
|
$("#childItem" + i).find("label.passengertype").html("Child " + i);
|
|
|
|
$("#birthdayCHD" + i).flatpickr({
|
|
|
|
dateFormat: "Y-m-d",
|
|
|
|
minDate: "1919-1-1",
|
|
|
|
maxDate: "today"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#childItem" + i).remove();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i <= bn) {
|
|
|
|
if ($("#babyItem" + i).length < 1) {
|
|
|
|
$("#adultItem1").clone().attr("id", "babyItem" + i).appendTo($("#BabyTb"));
|
|
|
|
$("#babyItem" + i).find("input[name='guestName[]']").attr({ "id": "guestNameBAB" + i }).val("");
|
|
|
|
$("#babyItem" + i).find("input[name='guestpassport[]']").attr({ "id": "guestpassportBAB" + i }).val("");
|
|
|
|
$("#babyItem" + i).find("input[name='birthday[]']").attr({ "id": "birthdayBAB" + i }).val("");
|
|
|
|
$("#babyItem" + i).find("label.passengertype").html("Baby " + i);
|
|
|
|
$("#birthdayBAB" + i).flatpickr({
|
|
|
|
dateFormat: "Y-m-d",
|
|
|
|
minDate: "1919-1-1",
|
|
|
|
maxDate: "today"
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$("#babyItem" + i).remove();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
calPrice();
|
|
|
|
}
|
|
|
|
function calPrice() {
|
|
|
|
let an = parseInt($("#adultNum").val());
|
|
|
|
let cn = parseInt($("#childNum").val() || 0);
|
|
|
|
let bn = parseInt($("#babyNum").val() || 0);
|
|
|
|
var d_CarFree = parseFloat($("#cardfee").val());
|
|
|
|
|
|
|
|
var total_tiket = DepartCabinInfo.adultPrice * an + DepartCabinInfo.childPrice * cn + DepartCabinInfo.babyPrice * bn;
|
|
|
|
var total_tiket_usd = DepartCabinInfo.adultPrice_usd * an + DepartCabinInfo.childPrice_usd * cn + DepartCabinInfo.babyPrice_usd * bn;
|
|
|
|
var total_tax = DepartCabinInfo.adultTax * an + DepartCabinInfo.adultTax * cn;
|
|
|
|
var total_tax_usd = DepartCabinInfo.adultTax_usd * an + DepartCabinInfo.adultTax_usd * cn;
|
|
|
|
var total_sfree = DepartCabinInfo.serviceFeeAdult * an + DepartCabinInfo.serviceFeeAdult * cn + DepartCabinInfo.serviceFeeBaby * bn;
|
|
|
|
var total_sfree_usd = DepartCabinInfo.serviceFeeAdult_usd * an + DepartCabinInfo.serviceFeeAdult_usd * cn + DepartCabinInfo.serviceFeeBaby_usd * bn;
|
|
|
|
|
|
|
|
var depart_totalprice = Math.ceil((total_tiket + total_tax + total_sfree) * (1 + d_CarFree));
|
|
|
|
var depart_totalprice_usd = Math.ceil((total_tiket_usd + total_tax_usd + total_sfree_usd) * (1 + d_CarFree));
|
|
|
|
|
|
|
|
if (roundTrip == "true") {
|
|
|
|
var r_total_tiket = ArriveCabinInfo.adultPrice * an + ArriveCabinInfo.childPrice * cn + ArriveCabinInfo.babyPrice * bn;
|
|
|
|
var r_total_tiket_usd = ArriveCabinInfo.adultPrice_usd * an + ArriveCabinInfo.childPrice_usd * cn + ArriveCabinInfo.babyPrice_usd * bn;
|
|
|
|
var r_total_tax = ArriveCabinInfo.adultTax * an + ArriveCabinInfo.adultTax * cn;
|
|
|
|
var r_total_tax_usd = ArriveCabinInfo.adultTax_usd * an + ArriveCabinInfo.adultTax_usd * cn;
|
|
|
|
var r_total_sfree = ArriveCabinInfo.serviceFeeAdult * an + ArriveCabinInfo.serviceFeeAdult * cn + ArriveCabinInfo.serviceFeeBaby * bn;
|
|
|
|
var r_total_sfree_usd = ArriveCabinInfo.serviceFeeAdult_usd * an + ArriveCabinInfo.serviceFeeAdult_usd * cn + ArriveCabinInfo.serviceFeeBaby_usd * bn;
|
|
|
|
|
|
|
|
total_tiket += r_total_tiket;
|
|
|
|
total_tiket_usd += r_total_tiket_usd;
|
|
|
|
total_tax += r_total_tax;
|
|
|
|
total_tax_usd += r_total_tax_usd;
|
|
|
|
total_sfree += r_total_sfree;
|
|
|
|
total_sfree_usd += r_total_sfree_usd;
|
|
|
|
|
|
|
|
r_totalprice = Math.ceil((r_total_tiket + r_total_tax + r_total_sfree) * (1 + d_CarFree));
|
|
|
|
r_totalprice_usd = Math.ceil((r_total_tiket_usd + r_total_tax_usd + r_total_sfree_usd) * (1 + d_CarFree));
|
|
|
|
}
|
|
|
|
|
|
|
|
var total_bankfree = Math.ceil((total_tiket + total_tax + total_sfree) * d_CarFree);
|
|
|
|
var total_bankfree_usd = Math.ceil((total_tiket_usd + total_tax_usd + total_sfree_usd) * d_CarFree);
|
|
|
|
var total_allprice = total_tiket + total_tax + total_sfree + total_bankfree;
|
|
|
|
var total_allprice_usd = total_tiket_usd + total_tax_usd + total_sfree_usd + total_bankfree_usd;
|
|
|
|
|
|
|
|
if (cn > 0) {
|
|
|
|
$(".js_childbox").show();
|
|
|
|
} else {
|
|
|
|
$(".js_childbox").hide();
|
|
|
|
}
|
|
|
|
if (bn > 0) {
|
|
|
|
$(".js_babybox").show();
|
|
|
|
} else {
|
|
|
|
$(".js_babybox").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#js_audltprice").html(DepartCabinInfo.adultPrice_usd);
|
|
|
|
$("span.js_audltNum").html(an);
|
|
|
|
$("#js_childprice").html(DepartCabinInfo.childPrice_usd);
|
|
|
|
$("span.js_childNum").html(cn);
|
|
|
|
$("#js_audltTax").html(DepartCabinInfo.adultTax_usd);
|
|
|
|
$("#js_audltSFee").html(DepartCabinInfo.serviceFeeAdult_usd);
|
|
|
|
$("#js_childTax").html(DepartCabinInfo.adultTax_usd);
|
|
|
|
$("#js_ChildSFee").html(DepartCabinInfo.serviceFeeAdult_usd);
|
|
|
|
|
|
|
|
$("span.js_babyNum").html(bn);
|
|
|
|
$("#js_babyprice").html(DepartCabinInfo.babyPrice_usd);
|
|
|
|
$("#js_BabySFee").html(DepartCabinInfo.serviceFreeBaby_usd);
|
|
|
|
//返程
|
|
|
|
if (roundTrip == "true") {
|
|
|
|
$("#js_return").show();
|
|
|
|
$("#js2_audltprice").html(ArriveCabinInfo.adultPrice_usd);
|
|
|
|
$("span.js2_audltNum").html(an);
|
|
|
|
$("#js2_childprice").html(ArriveCabinInfo.childPrice_usd);
|
|
|
|
$("span.js2_childNum").html(cn);
|
|
|
|
$("#js2_audltTax").html(ArriveCabinInfo.adultTax_usd);
|
|
|
|
$("#js2_audltSFee").html(ArriveCabinInfo.serviceFreeAdult_usd);
|
|
|
|
$("#js2_childTax").html(ArriveCabinInfo.adultTax_usd);
|
|
|
|
$("#js2_ChildSFee").html(ArriveCabinInfo.serviceFreeAdult_usd);
|
|
|
|
|
|
|
|
$("span.js2_babyNum").html(bn);
|
|
|
|
$("#js2_babyprice").html(ArriveCabinInfo.babyPrice_usd);
|
|
|
|
$("#js2_BabySFee").html(ArriveCabinInfo.serviceFreeBaby_usd);
|
|
|
|
} else {
|
|
|
|
$("#js_return").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
$("#js_bankfree").html(total_bankfree_usd);
|
|
|
|
$("#js_allprice").html(total_allprice_usd);
|
|
|
|
}
|
|
|
|
function submitflight(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
loaderOn();
|
|
|
|
let formData = new FormData(document.forms['reserveflight']);
|
|
|
|
console.log(Object.fromEntries(formData.entries()));
|
|
|
|
sessionStorage.removeItem('DepartFlightStr');
|
|
|
|
sessionStorage.removeItem('DepartFlightInfo');
|
|
|
|
sessionStorage.removeItem('DepartCabinStr');
|
|
|
|
sessionStorage.removeItem('DepartCabinInfo');
|
|
|
|
sessionStorage.removeItem('ArriveFlightStr');
|
|
|
|
sessionStorage.removeItem('ArriveFlightInfo');
|
|
|
|
sessionStorage.removeItem('ArriveCabinStr');
|
|
|
|
sessionStorage.removeItem('ArriveCabinInfo');
|
|
|
|
sessionStorage.removeItem('roundTrip');
|
|
|
|
sessionStorage.removeItem('isReturn');
|
|
|
|
return document.forms['reserveflight'].submit();
|
|
|
|
}
|
|
|
|
(function ($) {
|
|
|
|
readData();
|
|
|
|
$("#birthday1").flatpickr({
|
|
|
|
dateFormat: "Y-m-d",
|
|
|
|
minDate: "1919-1-1",
|
|
|
|
maxDate: "today"
|
|
|
|
});
|
|
|
|
changePassenger();
|
|
|
|
document.forms['reserveflight'].addEventListener("submit", submitflight, true);
|
|
|
|
|
|
|
|
})(window.jQuery)
|