405 lines
27 KiB
JavaScript
405 lines
27 KiB
JavaScript
var layer = layui.layer, form = layui.form, upload = layui.upload, laydate = layui.laydate
|
||
initFormFields()
|
||
function initFormFields() {
|
||
$('.layui-form-item').each(function() {
|
||
const labelText = $(this).find('.layui-form-label').text().replace('*', '').trim();
|
||
|
||
// 查找所有需要必填提示的表单元素
|
||
$(this).find('.layui-input-block input, ' +
|
||
'.layui-input-block select, ' +
|
||
'.layui-input-block textarea')
|
||
.each(function() {
|
||
var $field = $(this);
|
||
// 如果已有提示则跳过(保留自定义提示)
|
||
if (!$field.attr('lay-reqtext')) {
|
||
if($field.attr('type') !== 'hidden'){
|
||
$field.attr('lay-verType', 'tips');
|
||
}
|
||
// 设置统一的必填提示
|
||
$field.attr('lay-reqtext', labelText + '不能为空');
|
||
}
|
||
});
|
||
});
|
||
// 重新渲染表单
|
||
form.render();
|
||
}
|
||
//遍历日期选择
|
||
$(".layui-form-item").find(".layui-time").each(function () {
|
||
xvDate({
|
||
target: this,
|
||
});
|
||
});
|
||
$(".layui-form-item").find(".layui-qian").each(function () {
|
||
xvDate({
|
||
target: this,
|
||
max: new Date().toISOString().split('T')[0]
|
||
});
|
||
});
|
||
$(".layui-form-item").find(".layui-year").each(function () {
|
||
laydate.render({
|
||
elem: this, type: 'year'
|
||
});
|
||
});
|
||
$(".layui-form-item").find(".layui-arrive").each(function () {
|
||
xvDate({
|
||
target: this,
|
||
min: new Date().toISOString().split('T')[0],
|
||
done: function(value, date, endDate){
|
||
const isdate = isWithinThreeDays(value)
|
||
if (!isdate){
|
||
layer.alert('泰国移民局规定:外国旅客必须在抵达泰国前3天内填写泰国数字入境卡表格。<br/>申请时间大于3天时,订单将进入预约模式,待申请时间触达规定范围,系统将自动申请好入境卡', {
|
||
icon: 0,
|
||
shadeClose: true,
|
||
title: '注意'
|
||
});
|
||
}
|
||
validateDates();
|
||
}
|
||
});
|
||
});
|
||
$(".layui-form-item").find(".layui-leave").each(function () {
|
||
xvDate({
|
||
target: this,
|
||
min: new Date().toISOString().split('T')[0],
|
||
done: function (value, date, endDate) {
|
||
validateDates();
|
||
}
|
||
});
|
||
});
|
||
|
||
// 验证函数
|
||
function validateDates() {
|
||
var date1 = $('#arrive_date').val();
|
||
var date2 = $('#leave_date').val();
|
||
|
||
if (date1 && date2) {
|
||
var d1 = new Date(date1);
|
||
var d2 = new Date(date2);
|
||
|
||
if (d1 > d2) {
|
||
layer.tips('离境日期不能早于入境日期', '#leave_date');
|
||
$('#leave_date').val('')
|
||
return false;
|
||
}
|
||
var timeDiff = Math.abs(d2 - d1); // 使用 Math.abs() 确保正数
|
||
var daysDiff = Math.floor(timeDiff / (1000 * 60 * 60 * 24));
|
||
$('input[name="is_transit"]').prop('disabled', false);
|
||
if (daysDiff === 0) {
|
||
$('input[name="is_transit"][value="1"]').prop('checked', true);
|
||
$('input[name="is_transit"]').prop('disabled', true);
|
||
$(".data-is_transit_2").hide();
|
||
} else if(daysDiff === 1){
|
||
$('input[name="is_transit"][value="1"]').prop('checked', true);
|
||
$('input[name="is_transit"]').prop('disabled', false);
|
||
$(".data-is_transit_2").hide();
|
||
} else {
|
||
$('input[name="is_transit"][value="0"]').prop('checked', true);
|
||
$('input[name="is_transit"]').prop('disabled', true);
|
||
$(".data-is_transit_2").show();
|
||
}
|
||
form.render('radio'); // 单独渲染radio
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function isWithinThreeDays(dateString) {
|
||
const targetDate = new Date(dateString);
|
||
const currentDate = new Date();
|
||
const threeDaysInMillis = 3 * 24 * 60 * 60 * 1000;
|
||
|
||
// 将时间部分设置为0,以便只比较日期部分
|
||
targetDate.setHours(0, 0, 0, 0);
|
||
currentDate.setHours(0, 0, 0, 0);
|
||
|
||
return targetDate - currentDate <= threeDaysInMillis;
|
||
}
|
||
|
||
//是否选择 默认显示或隐藏
|
||
$("input[type='radio']").each(function () {
|
||
var name = $(this).attr("name");
|
||
var alt = $(this).attr("alt");
|
||
if ($(this).is(":checked")) {
|
||
$(".data-" + alt).show();
|
||
} else {
|
||
$(".data-" + alt).hide();
|
||
}
|
||
})
|
||
//是否radio 必填判断
|
||
form.on("radio", function (data) {
|
||
var name = data.elem.name;
|
||
var type = data.elem.alt;
|
||
$(".data-name-" + name).hide();
|
||
$(".data-" + type).show();
|
||
$(".data-name-" + name).each(function () {
|
||
var that = $(this).find(".layui-required");
|
||
var verify = that.attr("lay-verify");
|
||
if (verify === undefined || verify === null) {
|
||
verify = "";
|
||
}
|
||
var disAble = that.attr("disabled");
|
||
if ($(this).hasClass("data-" + type)) {
|
||
if (disAble === "disabled") {
|
||
|
||
} else if (verify.indexOf("required") >= 0) {
|
||
|
||
} else {
|
||
if (!$(this).attr('class').includes('layui-expect')) {
|
||
verify = verify + "|required";
|
||
that.attr("lay-verify", verify);
|
||
}
|
||
}
|
||
} else {
|
||
if (disAble === "disabled") {
|
||
|
||
} else {
|
||
if (verify.includes("required")) {
|
||
verify = verify.slice(0, verify.length - 9);
|
||
}
|
||
that.val('')
|
||
that.attr("lay-verify", verify);
|
||
}
|
||
}
|
||
})
|
||
});
|
||
//下一步
|
||
form.on('submit', function (data) {
|
||
var className = data.elem.className;
|
||
if (className.includes("btn-next")) {
|
||
if (className.includes("flag")) {
|
||
// if ($('input[name="visit_info"]').val() == '') {
|
||
// layer.msg('前两周内入住的国家/地区不可为空', {icon: 5});
|
||
// return false
|
||
// }
|
||
}
|
||
$(this).hide()
|
||
$(this).parents(".layui-form").next(".layui-form").show();
|
||
var h = $(this).parents(".layui-form").next(".layui-form").offset().top - 100;
|
||
$("html,body").animate({
|
||
scrollTop: h
|
||
}, 500);
|
||
}
|
||
return false;
|
||
});
|
||
// 监听复选框点击
|
||
form.on('checkbox(termsCheckbox)', function (data) {
|
||
if (data.elem.checked) {
|
||
// 弹出条款内容的弹窗
|
||
layer.open({
|
||
type: 1, // 弹窗类型:页面层
|
||
title: '条款与条件及隐私政策', content: `
|
||
<div style="padding: 20px;">
|
||
<h3>条款与条件</h3>
|
||
<p></p><p><span style="font-size: 12px;">通过浏览、访问和使用本网站,您理解并同意此处设置的条款和条件,称为“条款及条件”和“隐私政策”。 通过本网站提交电子签证泰国申请的电子签证申请人将被称为“申请人”、“用户”、“您”。 “我们”、“我们”、“我们的”、“本网站”等术语直接指 本网站 重要的是,您要知道每个人的合法利益都受到保护,我们与您的关系是建立在信任基础上的。 请注意,您必须接受这些服务条款,才能使用我们的网站和我们提供的服务。关于我们的服务我们的服务是作为在线申请服务提供商,用于促进电子签证流程,以便外国国民访问<span style="font-size: 12px; text-wrap-mode: wrap;">泰国</span>。 我们的代理会协助您从<span style="font-size: 12px; text-wrap-mode: wrap;">泰国</span>政府获得您的旅行授权,然后我们会向您提供该授权。 我们的服务包括正确审查您的所有信息、协助填写申请以及检查整个文件的准确性、完整性、拼写和语法审查。 此外,为了处理请求,我们可能会通过电子邮件或电话与您联系以获取更多信息。填写我们网站上提供的申请表后,您的旅行授权文件请求将在专家审查后提交。 您的电子签证申请需要获得<span style="font-size: 12px; text-wrap-mode: wrap;">泰国</span>政府的批准。但是,如果任何详细信息输入错误或不完整,您的申请可能会延迟或被拒。由您或指定的第三方代理人所提供的所有信息,必须是真实和正确的。如果您在填写信息时由您或您的代理人有意提交任何虚假、虚构或伪造的声明或陈述,造成<span style="font-size: 12px; text-wrap-mode: wrap;">泰国</span>电子签证申请被拒,责任由您本人承担。 信息填写完成后,我们根据你所选择的套餐时效反馈结果,提交后信息将不能再更改。</span></p><p><span style="font-size: 12px;">请表明您已阅读并了解上述所提供的信息</span></p><p><br></p><p></p>
|
||
<h3>隐私政策</h3>
|
||
<p></p><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">本应用尊重并保护所有使用服务用户的个人隐私权。为了给您提供更准确、更有个性化的服务,本应用会按照本隐私权政策的规定使用和披露您的个人信息。但本应用将以高度的勤勉、审慎义务对待这些信息。除本隐私权政策另有规定外,在未征得您事先许可的情况下,本应用不会将这些信息对外披露或向第三方提供。本应用会不时更新本隐私权政策。 您在同意本应用服务使用协议之时,即视为您已经同意本隐私权政策全部内容。本隐私权政策属于本应用服务使用协议不可分割的一部分。</p><h3 style="box-sizing: border-box; margin: 2px 0px; padding: 10px 0px 0px; border: 0px; font-weight: 400; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 18px; line-height: 1.1; color: rgb(0, 48, 73); white-space: normal; background-color: rgb(255, 255, 255);">1. 适用范围</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">(a) 在您注册本应用帐号时,您根据本应用要求提供的个人注册信息; (b) 在您使用本应用网络服务,或访问本应用平台网页时,本应用自动接收并记录的您的浏览器和计算机上的信息,包括但不限于您的IP地址、浏览器的类型、使用的语言、访问日期和时间、软硬件特征信息及您需求的网页记录等数据; (c) 本应用通过合法途径从商业伙伴处取得的用户个人数据。 您了解并同意,以下信息不适用本隐私权政策: (a) 您在使用本应用平台提供的搜索服务时输入的关键字信息; (b) 本应用收集到的您在本应用发布的有关信息数据,包括但不限于参与活动、成交信息及评价详情; (c) 违反法律规定或违反本应用规则行为及本应用已对您采取的措施。</p><h3 style="box-sizing: border-box; margin: 2px 0px; padding: 10px 0px 0px; border: 0px; font-weight: 400; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 18px; line-height: 1.1; color: rgb(0, 48, 73); white-space: normal; background-color: rgb(255, 255, 255);">2. 信息使用</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">(a)本应用不会向任何无关第三方提供、出售、出租、分享或交易您的个人信息,除非事先得到您的许可,或该第三方和本应用(含本应用关联公司)单独或共同为您提供服务,且在该服务结束后,其将被禁止访问包括其以前能够访问的所有这些资料。 (b) 本应用亦不允许任何第三方以任何手段收集、编辑、出售或者无偿传播您的个人信息。任何本应用平台用户如从事上述活动,一经发现,本应用有权立即终止与该用户的服务协议。 (c) 为服务用户的目的,本应用可能通过使用您的个人信息,向您提供您感兴趣的信息,包括但不限于向您发出产品和服务信息,或者与本应用合作伙伴共享信息以便他们向您发送有关其产品和服务的信息(后者需要您的事先同意)</p><h3 style="box-sizing: border-box; margin: 2px 0px; padding: 10px 0px 0px; border: 0px; font-weight: 400; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 18px; line-height: 1.1; color: rgb(0, 48, 73); white-space: normal; background-color: rgb(255, 255, 255);">3. 信息披露</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">在如下情况下,本应用将依据您的个人意愿或法律的规定全部或部分的披露您的个人信息: (a) 经您事先同意,向第三方披露; (b)为提供您所要求的产品和服务,而必须和第三方分享您的个人信息; (c) 根据法律的有关规定,或者行政或司法机构的要求,向第三方或者行政、司法机构披露; (d) 如您出现违反中国有关法律、法规或者本应用服务协议或相关规则的情况,需要向第三方披露; (e) 如您是适格的知识产权投诉人并已提起投诉,应被投诉人要求,向被投诉人披露,以便双方处理可能的权利纠纷; (f) 在本应用平台上创建的某一交易中,如交易任何一方履行或部分履行了交易义务并提出信息披露请求的,本应用有权决定向该用户提供其交易对方的联络方式等必要信息,以促成交易的完成或纠纷的解决。 (g) 其它本应用根据法律、法规或者网站政策认为合适的披露。</p><h3 style="box-sizing: border-box; margin: 2px 0px; padding: 10px 0px 0px; border: 0px; font-weight: 400; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 18px; line-height: 1.1; color: rgb(0, 48, 73); white-space: normal; background-color: rgb(255, 255, 255);">4. 信息存储和交换</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">本应用收集的有关您的信息和资料将保存在本应用及(或)其关联公司的服务器上,这些信息和资料可能传送至您所在国家、地区或本应用收集信息和资料所在地的境外并在境外被访问、存储和展示。</p><h3 style="box-sizing: border-box; margin: 2px 0px; padding: 10px 0px 0px; border: 0px; font-weight: 400; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 18px; line-height: 1.1; color: rgb(0, 48, 73); white-space: normal; background-color: rgb(255, 255, 255);">5. Cookie的使用</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">(a) 在您未拒绝接受cookies的情况下,本应用会在您的计算机上设定或取用cookies ,以便您能登录或使用依赖于cookies的本应用平台服务或功能。本应用使用cookies可为您提供更加周到的个性化服务,包括推广服务。 (b) 您有权选择接受或拒绝接受cookies。您可以通过修改浏览器设置的方式拒绝接受cookies。但如果您选择拒绝接受cookies,则您可能无法登录或使用依赖于cookies的本应用网络服务或功能。 (c) 通过本应用所设cookies所取得的有关信息,将适用本政策。</p><h3 style="box-sizing: border-box; margin: 2px 0px; padding: 10px 0px 0px; border: 0px; font-weight: 400; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 18px; line-height: 1.1; color: rgb(0, 48, 73); white-space: normal; background-color: rgb(255, 255, 255);">6. 信息安全</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">(a) 本应用帐号均有安全保护功能,请妥善保管您的用户名及密码信息。本应用将通过对用户密码进行加密等安全措施确保您的信息不丢失,不被滥用和变造。尽管有前述安全措施,但同时也请您注意在信息网络上不存在“完善的安全措施”。 (b) 在使用本应用网络服务进行网上交易时,您不可避免的要向交易对方或潜在的交易对</p><h3 style="box-sizing: border-box; margin: 2px 0px; padding: 10px 0px 0px; border: 0px; font-weight: 400; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 18px; line-height: 1.1; color: rgb(0, 48, 73); white-space: normal; background-color: rgb(255, 255, 255);">7.本隐私政策的更改</h3><p style="box-sizing: border-box; margin-top: 0px; margin-bottom: 0px; padding: 0px; border: 0px; font-family: "Microsoft YaHei", Arial, Helvetica, sans-serif; font-size: 12px; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);">(a)如果决定更改隐私政策,我们会在本政策中、本公司网站中以及我们认为适当的位置发布这些更改,以便您了解我们如何收集、使用您的个人信息,哪些人可以访问这些信息,以及在什么情况下我们会透露这些信息。 (b)本公司保留随时修改本政策的权利,因此请经常查看。如对本政策作出重大更改,本公司会通过网站通知的形式告知。 方披露自己的个人信息,如联络方式或者邮政地址。请您妥善保护自己的个人信息,仅在必要的情形下向他人提供。如您发现自己的个人信息泄密,尤其是本应用用户名及密码发生泄露,请您立即联络本应用客服,以便本应用采取相应措施。</p><p><br></p><p></p>
|
||
</div>
|
||
`, area: ['500px', '300px'], // 弹窗大小
|
||
btn: ['关闭'], // 按钮
|
||
yes: function (index) {
|
||
layer.close(index); // 关闭弹窗
|
||
}
|
||
});
|
||
}
|
||
});
|
||
form.verify({
|
||
// 验证至少选中一个 checkbox
|
||
checkboxRequired: function (value, item) {
|
||
var name = item.getAttribute('name');
|
||
var checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
|
||
var checkboxes_length = document.querySelectorAll(`input[name="${name}"]`).length;
|
||
if (checkboxes.length !== checkboxes_length) {
|
||
return '请勾选声明';
|
||
}
|
||
}, // 验证必须选中一个 radio
|
||
radioRequired: function (value, item) {
|
||
var name = item.getAttribute('name');
|
||
var radios = document.querySelectorAll(`input[name="${name}"]:checked`);
|
||
if (radios.length === 0) {
|
||
return '请选择一个套餐';
|
||
}
|
||
}, radioChecked: function (value, item) { //value:表单的值、item:表单的DOM对象
|
||
var radio = $(item).parent('div').find('input[type=radio]:checked').length;
|
||
if (!radio) {
|
||
return '必须选择一个选项';
|
||
}
|
||
}, checkboxChecked: function (value, item) { //value:表单的值、item:表单的DOM对象
|
||
var name = item.getAttribute('name');
|
||
var checkboxes = document.querySelectorAll(`input[name="${name}"]:checked`);
|
||
if (checkboxes.length === 0) {
|
||
return '必须选择一个选项';
|
||
}
|
||
}, otherReq: function (value, item) {
|
||
var $ = layui.$;
|
||
var verifyName = $(item).attr('name'), verifyType = $(item).attr('type'),
|
||
formElem = $(item).parents('.layui-form')//获取当前所在的form元素,如果存在的话
|
||
, verifyElem = formElem.find('input[name=' + verifyName + ']')//获取需要校验的元素
|
||
, isTrue = verifyElem.is(':checked')//是否命中校验
|
||
, focusElem = verifyElem.next().find('i.layui-icon');//焦点元素
|
||
if (!isTrue || !value) {
|
||
//定位焦点
|
||
focusElem.css(verifyType == 'radio' ? {"color": "#FF5722"} : {"border-color": "#FF5722"});
|
||
//对非输入框设置焦点
|
||
focusElem.first().attr("tabIndex", "1").css("outline", "0").blur(function () {
|
||
focusElem.css(verifyType == 'radio' ? {"color": ""} : {"border-color": ""});
|
||
}).focus();
|
||
return '必填项不能为空';
|
||
}
|
||
}, english: [/^[A-Za-z]+$/, '只能输入英文']
|
||
, engnum: [/^[A-Za-z0-9]+$/, '只能输入字母和数字']
|
||
});
|
||
/* 获取 多选国家 value*/
|
||
var xm = xmSelect.render({
|
||
el: '#visit_country', // 绑定的元素
|
||
name: 'visit_info1', // 表单提交的字段名
|
||
tips: '请选择国家', // 提示信息
|
||
filterable: true, // 支持搜索
|
||
on: function(data){
|
||
// 每次选项变化时更新隐藏字段
|
||
let values = data.arr.map(item => item.value).join('@');
|
||
$('input[name="visit_info"]').val(values)
|
||
}
|
||
});
|
||
|
||
function loadVisitCountryData() {
|
||
var loadIndex = layer.load(0)
|
||
$.ajax({
|
||
url: '/home/visa/getCountry', // 后台接口地址
|
||
method: 'POST', dataType: 'json', success: function (res) {
|
||
layer.close(loadIndex);
|
||
if (res.code === 1) { // 假设返回数据格式为 {code: 200, data: []}
|
||
xm.update({
|
||
data: res.data.map(function (item) {
|
||
return {
|
||
name: item.name, // 显示的文字
|
||
value: item.value // 提交的值
|
||
};
|
||
})
|
||
});
|
||
} else {
|
||
layer.msg('数据加载失败:' + res.message, {icon: 5});
|
||
}
|
||
}, error: function () {
|
||
layer.msg('请求出错,请稍后重试', {icon: 5});
|
||
}
|
||
});
|
||
}
|
||
|
||
// 加载数据
|
||
loadVisitCountryData();
|
||
|
||
form.on('select(travel_purpose_filter)', function (data) {
|
||
if (data.value === 'OTHERS') {
|
||
$('#others_purpose').show();
|
||
$('#others_purpose').find('.layui-required').attr('lay-verify', 'required');
|
||
} else {
|
||
$('#others_purpose').hide();
|
||
$('#others_purpose').find('.layui-required').removeAttr('lay-verify');
|
||
}
|
||
})
|
||
form.on('select(travel_way_filter)', function (data) {
|
||
if (data.value === 'OTHERS') {
|
||
$('#travel_way_others').show();
|
||
$('#travel_way_others').find('.layui-required').attr('lay-verify', 'required');
|
||
} else {
|
||
$('#travel_way_others').hide();
|
||
$('#travel_way_others').find('.layui-required').removeAttr('lay-verify');
|
||
}
|
||
})
|
||
form.on('select(out_travel_way_filter)', function (data) {
|
||
if (data.value === 'OTHERS') {
|
||
$('#out_travel_way_others').show();
|
||
$('#out_travel_way_others').find('.layui-required').attr('lay-verify', 'required');
|
||
} else {
|
||
$('#out_travel_way_others').hide();
|
||
$('#out_travel_way_others').find('.layui-required').removeAttr('lay-verify');
|
||
}
|
||
})
|
||
form.on('select(accommodation_type_filter)', function (data) {
|
||
if (data.value === 'OTHERS') {
|
||
$('#out_accommodation_type').show();
|
||
$('#out_accommodation_type').find('.layui-required').attr('lay-verify', 'required');
|
||
} else {
|
||
$('#out_accommodation_type').hide();
|
||
$('#out_accommodation_type').find('.layui-required').removeAttr('lay-verify');
|
||
}
|
||
})
|
||
form.on('select(hotel_state_select)', function (data) {
|
||
var sub_select = document.getElementById('hotel_city');
|
||
sub_select.innerHTML = '<option value="">请选择城市</option>'; // 清空城市选项
|
||
if ($(data.elem).find("option:selected").data('key')) {
|
||
layer.load(0)
|
||
$.ajax({
|
||
url: "/home/visa/get_sub_city", type: "POST", data: {'id': $(data.elem).find("option:selected").data('key')}, success: function (data) {
|
||
if (data.data.length !== 0) {
|
||
for (var i = 0; i < data.data.length; i++) {
|
||
var option = document.createElement('option');
|
||
option.value = data.data[i].districtNameEn;
|
||
option.text = data.data[i].districtNameEn;
|
||
option.dataset.key = data.data[i].districtCode; // 正确设置 data-key 属性
|
||
sub_select.appendChild(option);
|
||
}
|
||
form.render('select'); // 重新渲染下拉框
|
||
layer.closeAll()
|
||
} else {
|
||
layer.closeAll()
|
||
layer.msg('获取失败', {icon: 5});
|
||
form.render('select'); // 重新渲染下拉框
|
||
return false;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
})
|
||
form.on('select(hotel_city_select)', function (data) {
|
||
var sub_select = document.getElementById('hotel_district');
|
||
sub_select.innerHTML = '<option value="">请选择街道</option>'; // 清空城市选项
|
||
if ($(data.elem).find("option:selected").data('key')) {
|
||
layer.load(0)
|
||
$.ajax({
|
||
url: "/home/visa/get_sub_istrict", type: "POST", data: {'id': $(data.elem).find("option:selected").data('key')}, success: function (data) {
|
||
if (data.data.length !== 0) {
|
||
for (var i = 0; i < data.data.length; i++) {
|
||
var option = document.createElement('option');
|
||
option.value = data.data[i].subdistrictNameEn;
|
||
option.text = data.data[i].subdistrictNameEn;
|
||
sub_select.appendChild(option);
|
||
$('#hotel_zip_code').val(data.data[i].postalCode)
|
||
}
|
||
form.render('select'); // 重新渲染下拉框
|
||
layer.closeAll()
|
||
} else {
|
||
layer.closeAll()
|
||
layer.msg('获取失败', {icon: 5});
|
||
form.render('select'); // 重新渲染下拉框
|
||
return false;
|
||
}
|
||
}
|
||
});
|
||
}
|
||
})
|
||
//监听提交
|
||
form.on('submit(formSubmit)', function (data) {
|
||
var submitVal = "";
|
||
for (var i = 1; i < 4; i++) {
|
||
submitVal = $.extend(submitVal, form.val('Form' + i));
|
||
if (!form.validate('#Form' + i)) {
|
||
return false;
|
||
}
|
||
}
|
||
// if ($('input[name="visit_info"]').val() == '') {
|
||
// layer.msg('前两周内入住的国家/地区不可为空', {icon: 5});
|
||
// return false
|
||
// }
|
||
var load = layer.load(2, {shade: 0.3})
|
||
$.ajax({
|
||
url: "/home/visa/do_apply", type: "POST", data: submitVal, success: function (data) {
|
||
if (data.code === 1) {
|
||
window.location.href = data.url
|
||
} else {
|
||
layer.msg(data.msg, {icon: 5});
|
||
return false
|
||
}
|
||
}
|
||
});
|
||
return false;
|
||
}); |