更新 VISA-FREE 逻辑

hotfix/paypal-note
Jimmy Liow 2 years ago
parent b7509b2dc1
commit 34f8408fa8

@ -1103,6 +1103,10 @@ ready(el => {
takeATestButton.on('click', () => {
var validateSuccess = true;
var thirdCountry = true;
var qualify2China = true;
var visa72hours = true;
var visa144hours = true;
const departFrom = el('depart_from').value.trim();
const leave4Country = el('leave_for_country').value.trim();
@ -1128,8 +1132,7 @@ ready(el => {
if (arrivalDateVal === '' || departureDateVal === '') return;
if (departFrom === leave4Country) {
console.info('You must be in transit to a third country or region.');
validateSuccess = false;
thirdCountry = false;
error_transit.show();
}
@ -1137,45 +1140,31 @@ ready(el => {
const selectedCountry = nationality.options[nationality.selectedIndex];
const qualifyCountry = selectedCountry.getAttribute('data-qualify');
if (qualifyCountry == null || qualifyCountry != 'enable') {
console.log("You don't qualify to enjoy China's 72-hour or 144-hour visa-free policy.");
validateSuccess = false;
qualify2China = false;
error_eligible.show();
} else {
const arrivalDate = new Date(arrivalDateVal);
const departureDate = new Date(departureDateVal);
}
const diffInDays = calcDiffInDays(arrivalDate, departureDate);
console.log(diffInDays);
if (isNaN(diffInDays) || diffInDays > 6) {
console.log('Your passport nationality is not eligible for the 72/144-hour visa exemption program.');
validateSuccess = false;
error_72hours.show();
}
const arrivalDate = new Date(arrivalDateVal);
const departureDate = new Date(departureDateVal);
const airportOrRailwayStation = el('airport_or_railway_station');
const selectedOption = airportOrRailwayStation.options[airportOrRailwayStation.selectedIndex];
const indexOf72 = selectedOption.getAttribute('data-hour').indexOf('72');
const indexOf144 = selectedOption.getAttribute('data-hour').indexOf('144');
const diffInDays = calcDiffInDays(arrivalDate, departureDate);
if (diffInDays > 0 && diffInDays <= 3 && indexOf72 !== -1) {
validateSuccess = true;
qualify_72hours.show();
} else {
validateSuccess = false;
qualify_72hours.hide();
error_72hours.show();
}
const airportOrRailwayStation = el('airport_or_railway_station');
const selectedOption = airportOrRailwayStation.options[airportOrRailwayStation.selectedIndex];
const indexOf72 = selectedOption.getAttribute('data-hour').indexOf('72');
const indexOf144 = selectedOption.getAttribute('data-hour').indexOf('144');
if (diffInDays < 1 || diffInDays > 2 || indexOf72 == -1) {
visa72hours = false;
error_72hours.show();
}
if (diffInDays > 0 && diffInDays <= 6 && indexOf144 !== -1) {
validateSuccess = true;
qualify_144hours.show();
} else {
validateSuccess = false;
qualify_144hours.hide();
error_72hours.show();
}
if (diffInDays < 1 || diffInDays > 7 || indexOf144 == -1) {
visa144hours = false;
error_72hours.show();
}
validateSuccess = (visa144hours || visa72hours) && qualify2China && thirdCountry;
result_box.show();
if (validateSuccess) {
tip_box.show();

Loading…
Cancel
Save