1976 lines
84 KiB
JavaScript
1976 lines
84 KiB
JavaScript
|
||
$(function() {
|
||
const flagPosition ="af:0 0,am:-42 0,ar:-84 0,az:-126 0,be:-168 0,bg:-210 0,bn:-252 0,bs:-294 0,ca:-336 0,ceb:-378 0,cn:-420 0,co:-42 -32,cs:-84 -32,cy:-126 -32,da:-168 -32,de:-210 -32,xh:-252 -32,el:-294 -32,en:-378 -32,eo:-420 -32,es:0 -64,zu:-42 -64,et:-84 -64,eu:-168 -64,fa:-210 -64,fi:-252 -64,fr:-294 -64,yo:-336 -64,fy:-378 -64,ga:-420 -64,gd:0 -96,gl:-42 -96,gu:-84 -96,ha:-126 -96,haw:-168 -96,hi:-210 -96,hmn:-252 -96,hr:-294 -96,ht:-336 -96,hu:-378 -96,hy:-420 -96,id:0 -128,ig:-42 -128,is:-84 -128,it:-126 -128,iw:-168 -128,ja:-210 -128,jw:-252 -128,ka:-294 -128,kk:-336 -128,km:-378 -128,kn:-420 -128,ko:0 -160,ku:-42 -160,ky:-84 -160,la:-126 -160,lb:-168 -160,lo:-210 -160,lt:-252 -160,lv:-294 -160,mg:-336 -160,mi:-378 -160,mk:-420 -160,ml:0 -192,mn:-42 -192,mr:-84 -192,ms:-126 -192,mt:-168 -192,mx:-210 -192,my:-252 -192,ne:-294 -192,nl:-336 -192,no:-378 -192,ny:-420 -192,pa:0 -224,pl:-42 -224,ps:-84 -224,pt:-126 -224,yi:-168 -224,ro:-210 -224,ru:-252 -224,sd:-336 -224,si:-378 -224,sk:-420 -224,sl:0 -256,sm:-42 -256,sn:-84 -256,so:-126 -256,sq:-168 -256,sr:-210 -256,st:-252 -256,su:-294 -256,sv:-336 -256,sw:-378 -256,ta:-420 -256,te:0 -288,tg:-42 -288,th:-84 -288,tl:-126 -288,tr:-168 -288,vi:-210 -288,uk:-252 -288,ur:-294 -288,uz:-336 -288";
|
||
var pathArr = location.pathname.split('/') || [];
|
||
var lang = pathArr[1] || 'en';
|
||
var langList = [];
|
||
|
||
$('.lang-selector .lang-list a').each(function(){
|
||
const dataLang = $(this).data('lang');
|
||
if (dataLang.includes('##')) {
|
||
const dataLangArr = dataLang.split('##') || [];
|
||
langList.push(dataLangArr[1]);
|
||
if (dataLangArr[0]?.includes(location.host)) {
|
||
lang = dataLangArr[1];
|
||
}
|
||
} else {
|
||
langList.push(dataLang);
|
||
}
|
||
});
|
||
|
||
if (langList.includes(lang)) {
|
||
const position = flagPosition.split(',').find(function(flag) {
|
||
const l= flag.split(':')[0];
|
||
if (l === lang) {
|
||
return true;
|
||
}
|
||
})
|
||
if (position) {
|
||
const [left, top] = position.split(':')[1].split(' ').map(function(v) {
|
||
return Number(v);
|
||
});
|
||
console.log($('.lang-selector .current-lang img'), left, top);
|
||
$('.lang-selector .current-lang img').css("object-position",`${left - 6}px ${top - 6}px`);
|
||
$('.lang-selector .current-lang em').text(lang.toUpperCase());
|
||
}
|
||
}
|
||
})
|
||
;
|
||
$(document).ready(function () {
|
||
var phoneCode = [
|
||
{ "areaEn": "Albania", "areaCode": "+355" },
|
||
{ "areaEn": "Algeria", "areaCode": "+213" },
|
||
{ "areaEn": "Afghanistan", "areaCode": "+93" },
|
||
{ "areaEn": "Argentina", "areaCode": "+54" },
|
||
{ "areaEn": "United Arab Emirates", "areaCode": "+971" },
|
||
{ "areaEn": "Aruba", "areaCode": "+297" },
|
||
{ "areaEn": "Oman", "areaCode": "+968" },
|
||
{ "areaEn": "Azerbaijan", "areaCode": "+994" },
|
||
{ "areaEn": "Ascension Island", "areaCode": "+247" },
|
||
{ "areaEn": "Egypt", "areaCode": "+20" },
|
||
{ "areaEn": "Ethiopia", "areaCode": "+251" },
|
||
{ "areaEn": "Ireland", "areaCode": "+353" },
|
||
{ "areaEn": "Estonia", "areaCode": "+372" },
|
||
{ "areaEn": "Andorra", "areaCode": "+376" },
|
||
{ "areaEn": "Angola", "areaCode": "+244" },
|
||
{ "areaEn": "Antigua and Barbuda", "areaCode": "+1" },
|
||
{ "areaEn": "Austria", "areaCode": "+43" },
|
||
{ "areaEn": "Australia", "areaCode": "+61" },
|
||
{ "areaEn": "Macao Special Administrative Region", "areaCode": "+853" },
|
||
{ "areaEn": "Barbados", "areaCode": "+1" },
|
||
{ "areaEn": "Papua New Guinea", "areaCode": "+675" },
|
||
{ "areaEn": "Bahamas", "areaCode": "+1" },
|
||
{ "areaEn": "Pakistan", "areaCode": "+92" },
|
||
{ "areaEn": "Paraguay", "areaCode": "+595" },
|
||
{ "areaEn": "Palestinian National Authority", "areaCode": "+970" },
|
||
{ "areaEn": "Bahrain", "areaCode": "+973" },
|
||
{ "areaEn": "Panama", "areaCode": "+507" },
|
||
{ "areaEn": "Brazil", "areaCode": "+55" },
|
||
{ "areaEn": "Belarus", "areaCode": "+375" },
|
||
{ "areaEn": "Bermuda", "areaCode": "+1" },
|
||
{ "areaEn": "Bulgaria", "areaCode": "+359" },
|
||
{ "areaEn": "Northern Mariana Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Benin", "areaCode": "+229" },
|
||
{ "areaEn": "Belgium", "areaCode": "+32" },
|
||
{ "areaEn": "Iceland", "areaCode": "+354" },
|
||
{ "areaEn": "Poland", "areaCode": "+48" },
|
||
{ "areaEn": "Bosnia and Herzegovina", "areaCode": "+387" },
|
||
{ "areaEn": "Bolivia", "areaCode": "+591" },
|
||
{ "areaEn": "Belize", "areaCode": "+501" },
|
||
{ "areaEn": "Botswana", "areaCode": "+267" },
|
||
{ "areaEn": "Bonaire", "areaCode": "+599" },
|
||
{ "areaEn": "Bhutan", "areaCode": "+975" },
|
||
{ "areaEn": "Burkina Faso", "areaCode": "+226" },
|
||
{ "areaEn": "Burundi", "areaCode": "+257" },
|
||
{ "areaEn": "Bouvet Island", "areaCode": "+47" },
|
||
{ "areaEn": "Korea", "areaCode": "+850" },
|
||
{ "areaEn": "Equatorial Guinea", "areaCode": "+240" },
|
||
{ "areaEn": "Denmark", "areaCode": "+45" },
|
||
{ "areaEn": "Germany", "areaCode": "+49" },
|
||
{ "areaEn": "East Timor", "areaCode": "+670" },
|
||
{ "areaEn": "Togo", "areaCode": "+228" },
|
||
{ "areaEn": "Dominican Republic", "areaCode": "+1809" },
|
||
{ "areaEn": "Dominic", "areaCode": "+1" },
|
||
{ "areaEn": "Russia", "areaCode": "+7" },
|
||
{ "areaEn": "Ecuador", "areaCode": "+593" },
|
||
{ "areaEn": "Eritrea", "areaCode": "+291" },
|
||
{ "areaEn": "France", "areaCode": "+33" },
|
||
{ "areaEn": "Faroe Islands", "areaCode": "+298" },
|
||
{ "areaEn": "French Polynesia", "areaCode": "+689" },
|
||
{ "areaEn": "French Guiana", "areaCode": "+594" },
|
||
{ "areaEn": "Vatican", "areaCode": "+379" },
|
||
{ "areaEn": "Philippines", "areaCode": "+63" },
|
||
{ "areaEn": "Fiji", "areaCode": "+679" },
|
||
{ "areaEn": "Finland", "areaCode": "+358" },
|
||
{ "areaEn": "Cape Verde", "areaCode": "+238" },
|
||
{ "areaEn": "Falkland Islands", "areaCode": "+500" },
|
||
{ "areaEn": "Gambia", "areaCode": "+220" },
|
||
{ "areaEn": "Republic of Congo)", "areaCode": "+242" },
|
||
{ "areaEn": "Congo (Gold)", "areaCode": "+243" },
|
||
{ "areaEn": "Colombia", "areaCode": "+57" },
|
||
{ "areaEn": "Costa Rica", "areaCode": "+506" },
|
||
{ "areaEn": "Guernsey", "areaCode": "+44" },
|
||
{ "areaEn": "Grenada", "areaCode": "+1" },
|
||
{ "areaEn": "Greenland", "areaCode": "+299" },
|
||
{ "areaEn": "Georgia", "areaCode": "+995" },
|
||
{ "areaEn": "Cuba", "areaCode": "+53" },
|
||
{ "areaEn": "Guadeloupe", "areaCode": "+590" },
|
||
{ "areaEn": "Guam", "areaCode": "+1" },
|
||
{ "areaEn": "Guyana", "areaCode": "+592" },
|
||
{ "areaEn": "Kazakhstan", "areaCode": "+7" },
|
||
{ "areaEn": "Haiti", "areaCode": "+509" },
|
||
{ "areaEn": "Korea", "areaCode": "+82" },
|
||
{ "areaEn": "Netherlands", "areaCode": "+31" },
|
||
{ "areaEn": "Netherlands Antilles (front)", "areaCode": "+599" },
|
||
{ "areaEn": "Montenegro", "areaCode": "+382" },
|
||
{ "areaEn": "Honduras", "areaCode": "+504" },
|
||
{ "areaEn": "Kiribati", "areaCode": "+686" },
|
||
{ "areaEn": "Djibouti", "areaCode": "+253" },
|
||
{ "areaEn": "Kyrgyzstan", "areaCode": "+996" },
|
||
{ "areaEn": "Guinea", "areaCode": "+224" },
|
||
{ "areaEn": "Guinea-Bissau", "areaCode": "+245" },
|
||
{ "areaEn": "Canada", "areaCode": "+1" },
|
||
{ "areaEn": "Ghana", "areaCode": "+233" },
|
||
{ "areaEn": "Gabon", "areaCode": "+241" },
|
||
{ "areaEn": "Cambodia", "areaCode": "+855" },
|
||
{ "areaEn": "Czech Republic", "areaCode": "+420" },
|
||
{ "areaEn": "Zimbabwe", "areaCode": "+263" },
|
||
{ "areaEn": "Cameroon", "areaCode": "+237" },
|
||
{ "areaEn": "Qatar", "areaCode": "+974" },
|
||
{ "areaEn": "Cayman Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Cocos Islands (Keeling Islands)", "areaCode": "+61" },
|
||
{ "areaEn": "Comoros Union", "areaCode": "+269" },
|
||
{ "areaEn": "Kosovo", "areaCode": "+383" },
|
||
{ "areaEn": "Cote d'Ivoire", "areaCode": "+225" },
|
||
{ "areaEn": "Kuwait", "areaCode": "+965" },
|
||
{ "areaEn": "Croatia", "areaCode": "+385" },
|
||
{ "areaEn": "Kenya", "areaCode": "+254" },
|
||
{ "areaEn": "Kuco Islands", "areaCode": "+682" },
|
||
{ "areaEn": "Curacao", "areaCode": "+599" },
|
||
{ "areaEn": "Latvia", "areaCode": "+371" },
|
||
{ "areaEn": "Lesotho", "areaCode": "+266" },
|
||
{ "areaEn": "Laos", "areaCode": "+856" },
|
||
{ "areaEn": "Lebanon", "areaCode": "+961" },
|
||
{ "areaEn": "Lithuania", "areaCode": "+370" },
|
||
{ "areaEn": "Liberia", "areaCode": "+231" },
|
||
{ "areaEn": "Libya", "areaCode": "+218" },
|
||
{ "areaEn": "Liechtenstein", "areaCode": "+423" },
|
||
{ "areaEn": "Reunion", "areaCode": "+262" },
|
||
{ "areaEn": "Luxembourg", "areaCode": "+352" },
|
||
{ "areaEn": "Rwanda", "areaCode": "+250" },
|
||
{ "areaEn": "Romania", "areaCode": "+40" },
|
||
{ "areaEn": "Madagascar", "areaCode": "+261" },
|
||
{ "areaEn": "Isle of Man", "areaCode": "+44" },
|
||
{ "areaEn": "Maldives", "areaCode": "+960" },
|
||
{ "areaEn": "Malta", "areaCode": "+356" },
|
||
{ "areaEn": "Malawi", "areaCode": "+265" },
|
||
{ "areaEn": "Malaysia", "areaCode": "+60" },
|
||
{ "areaEn": "Mali", "areaCode": "+223" },
|
||
{ "areaEn": "Marshall Islands", "areaCode": "+692" },
|
||
{ "areaEn": "Martinique", "areaCode": "+596" },
|
||
{ "areaEn": "Mayotte", "areaCode": "+262" },
|
||
{ "areaEn": "Mauritius", "areaCode": "+230" },
|
||
{ "areaEn": "Mauritania", "areaCode": "+222" },
|
||
{ "areaEn": "United States", "areaCode": "+1" },
|
||
{ "areaEn": "US outer island", "areaCode": "+1" },
|
||
{ "areaEn": "United States Virgin Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Mongolia", "areaCode": "+976" },
|
||
{ "areaEn": "Montserrat", "areaCode": "+1" },
|
||
{ "areaEn": "Bangladesh", "areaCode": "+880" },
|
||
{ "areaEn": "Peru", "areaCode": "+51" },
|
||
{ "areaEn": "Micronesia", "areaCode": "+691" },
|
||
{ "areaEn": "Myanmar", "areaCode": "+95" },
|
||
{ "areaEn": "Moldova", "areaCode": "+373" },
|
||
{ "areaEn": "Morocco", "areaCode": "+212" },
|
||
{ "areaEn": "Monaco", "areaCode": "+377" },
|
||
{ "areaEn": "Mozambique", "areaCode": "+258" },
|
||
{ "areaEn": "Mexico", "areaCode": "+52" },
|
||
{ "areaEn": "Namibia", "areaCode": "+264" },
|
||
{ "areaEn": "South Africa", "areaCode": "+27" },
|
||
{ "areaEn": "Antarctica", "areaCode": "+672" },
|
||
{ "areaEn": "South Sudan", "areaCode": "+211" },
|
||
{ "areaEn": "Nauru", "areaCode": "+674" },
|
||
{ "areaEn": "Nepal", "areaCode": "+977" },
|
||
{ "areaEn": "Nicaragua", "areaCode": "+505" },
|
||
{ "areaEn": "Niger", "areaCode": "+227" },
|
||
{ "areaEn": "Nigeria", "areaCode": "+234" },
|
||
{ "areaEn": "Niue", "areaCode": "+683" },
|
||
{ "areaEn": "Norway", "areaCode": "+47" },
|
||
{ "areaEn": "Palau", "areaCode": "+680" },
|
||
{ "areaEn": "Portugal", "areaCode": "+351" },
|
||
{ "areaEn": "The former Yugoslav Republic of Macedonia", "areaCode": "+389" },
|
||
{ "areaEn": "Japan", "areaCode": "+81" },
|
||
{ "areaEn": "Sweden", "areaCode": "+46" },
|
||
{ "areaEn": "Switzerland", "areaCode": "+41" },
|
||
{ "areaEn": "Salvador", "areaCode": "+503" },
|
||
{ "areaEn": "Samoa", "areaCode": "+685" },
|
||
{ "areaEn": "Republic of Serbia", "areaCode": "+381" },
|
||
{ "areaEn": "Sierra Leone", "areaCode": "+232" },
|
||
{ "areaEn": "Senegal", "areaCode": "+221" },
|
||
{ "areaEn": "Cyprus", "areaCode": "+357" },
|
||
{ "areaEn": "Seychelles", "areaCode": "+248" },
|
||
{ "areaEn": "Sabah", "areaCode": "+599" },
|
||
{ "areaEn": "Saudi Arabia", "areaCode": "+966" },
|
||
{ "areaEn": "Christmas Island", "areaCode": "+61" },
|
||
{ "areaEn": "Sao Tome and Principe", "areaCode": "+239" },
|
||
{
|
||
"areaEn": "St. Helena, Ascension and Tristan da Cunha",
|
||
"areaCode": "+290"
|
||
},
|
||
{ "areaEn": "Saint Kitts and Nevis", "areaCode": "+1" },
|
||
{ "areaEn": "Saint Lucia", "areaCode": "+1" },
|
||
{ "areaEn": "San Marino", "areaCode": "+378" },
|
||
{ "areaEn": "Saint Pierre and Miquelon", "areaCode": "+508" },
|
||
{ "areaEn": "Saint Vincent and the Grenadines", "areaCode": "+1" },
|
||
{ "areaEn": "Sint Eustatius", "areaCode": "+599" },
|
||
{ "areaEn": "Sri Lanka", "areaCode": "+94" },
|
||
{ "areaEn": "Slovakia", "areaCode": "+421" },
|
||
{ "areaEn": "Slovenia", "areaCode": "+386" },
|
||
{ "areaEn": "Svalbard", "areaCode": "+47" },
|
||
{ "areaEn": "Swaziland", "areaCode": "+268" },
|
||
{ "areaEn": "Sudan", "areaCode": "+249" },
|
||
{ "areaEn": "Suriname", "areaCode": "+597" },
|
||
{ "areaEn": "Solomon Islands", "areaCode": "+677" },
|
||
{ "areaEn": "Somalia", "areaCode": "+252" },
|
||
{ "areaEn": "Tajikistan", "areaCode": "+992" },
|
||
{ "areaEn": "Taiwan", "areaCode": "+886" },
|
||
{ "areaEn": "Thailand", "areaCode": "+66" },
|
||
{ "areaEn": "Tanzania", "areaCode": "+255" },
|
||
{ "areaEn": "Tonga", "areaCode": "+676" },
|
||
{ "areaEn": "Turks and Caicos Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Tristanda Kunha", "areaCode": "+290" },
|
||
{ "areaEn": "Trinidad and Tobago", "areaCode": "+1" },
|
||
{ "areaEn": "Tunisia", "areaCode": "+216" },
|
||
{ "areaEn": "Tuvalu", "areaCode": "+688" },
|
||
{ "areaEn": "Turkey", "areaCode": "+90" },
|
||
{ "areaEn": "Turkmenistan", "areaCode": "+993" },
|
||
{ "areaEn": "Tokelau", "areaCode": "+690" },
|
||
{ "areaEn": "Wallis and Futuna", "areaCode": "+681" },
|
||
{ "areaEn": "Vanuatu", "areaCode": "+678" },
|
||
{ "areaEn": "Guatemala", "areaCode": "+502" },
|
||
{ "areaEn": "Venezuela", "areaCode": "+58" },
|
||
{ "areaEn": "Brunei", "areaCode": "+673" },
|
||
{ "areaEn": "Uganda", "areaCode": "+256" },
|
||
{ "areaEn": "Ukraine", "areaCode": "+380" },
|
||
{ "areaEn": "Uruguay", "areaCode": "+598" },
|
||
{ "areaEn": "Uzbekistan", "areaCode": "+998" },
|
||
{ "areaEn": "Spain", "areaCode": "+34" },
|
||
{ "areaEn": "Greece", "areaCode": "+30" },
|
||
{ "areaEn": "Hong Kong Special Administrative Region", "areaCode": "+852" },
|
||
{ "areaEn": "Singapore", "areaCode": "+65" },
|
||
{ "areaEn": "New Caledonia", "areaCode": "+687" },
|
||
{ "areaEn": "new Zealand", "areaCode": "+64" },
|
||
{ "areaEn": "Hungary", "areaCode": "+36" },
|
||
{ "areaEn": "Syria", "areaCode": "+963" },
|
||
{ "areaEn": "Jamaica", "areaCode": "+1" },
|
||
{ "areaEn": "Armenia", "areaCode": "+374" },
|
||
{ "areaEn": "Jan Mayen Island", "areaCode": "+47" },
|
||
{ "areaEn": "Yemen", "areaCode": "+967" },
|
||
{ "areaEn": "Iraq", "areaCode": "+964" },
|
||
{ "areaEn": "Iran", "areaCode": "+98" },
|
||
{ "areaEn": "Israel", "areaCode": "+972" },
|
||
{ "areaEn": "Italy", "areaCode": "+39" },
|
||
{ "areaEn": "India", "areaCode": "+91" },
|
||
{ "areaEn": "Indonesia", "areaCode": "+62" },
|
||
{ "areaEn": "United Kingdom", "areaCode": "+44" },
|
||
{ "areaEn": "The British Virgin Islands", "areaCode": "+1" },
|
||
{ "areaEn": "British Indian Ocean Territory", "areaCode": "+44" },
|
||
{ "areaEn": "Jordan", "areaCode": "+962" },
|
||
{ "areaEn": "Vietnam", "areaCode": "+84" },
|
||
{ "areaEn": "Zambia", "areaCode": "+260" },
|
||
{ "areaEn": "Jersey", "areaCode": "+44" },
|
||
{ "areaEn": "Chad", "areaCode": "+235" },
|
||
{ "areaEn": "Gibraltar", "areaCode": "+350" },
|
||
{ "areaEn": "Chile", "areaCode": "+56" },
|
||
{ "areaEn": "Central African Republic", "areaCode": "+236" },
|
||
{ "areaEn": "China", "areaCode": "+86" }
|
||
]
|
||
|
||
var countryList = ["Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bonaire", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo", "Cook Islands", "Costa Rica", "Croatia", "Curaçao", "Cyprus", "Czech Republic", "Côte d'Ivoire", "Denmark", "Djibouti", "Dominica", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kosovo", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestine", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russian Federation", "Rwanda", "Réunion", "Saint Barthélemy", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", "South Sudan", "Spain", "Sri Lanka", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Dominican Republic", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "United States Virgin Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe", "Åaland Islands"]
|
||
|
||
var $INQURY_BOX = $(".crm_inquiry_form_boxcustom_inquiry_form_1778573438106317");
|
||
var crmEmailStr = "Please enter a valid email address";
|
||
var pagetitle = '';
|
||
$('#pagetitle').val(document.title);
|
||
|
||
var crmValidStr = "This field is required";
|
||
var crmFailedStr = "Send failed";
|
||
var apiPath = $('#apiPath').attr('value');
|
||
var siteId = $('#siteId').attr('value');
|
||
var clientId = $('#clientId').attr('value');
|
||
|
||
// bootstrap-select 的默认 data-api 初始化绑定在 window.onload 上:
|
||
// 如果页面里有 iframe(比如 Google Maps)加载卡住,onload 不触发会导致 selectpicker 一直不初始化。
|
||
// 这里在 DOM ready 主动初始化一次,并在插件缺失时回退为原生 select(避免被 CSS 隐藏后无法选择)。
|
||
function initSelectpicker() {
|
||
var $selects = $INQURY_BOX.find('select.selectpicker');
|
||
if (!$selects.length) return;
|
||
|
||
// 插件未加载:移除 class,让原生 select 可见可用(降级)
|
||
if (!(window.jQuery && $.fn && typeof $.fn.selectpicker === 'function')) {
|
||
$selects.removeClass('selectpicker');
|
||
return;
|
||
}
|
||
|
||
// 已加载:只对未初始化的 select 执行一次初始化
|
||
$selects.each(function () {
|
||
var $el = $(this);
|
||
if (!$el.data('selectpicker')) {
|
||
$el.selectpicker($el.data() || {});
|
||
}
|
||
});
|
||
|
||
// 选项可能是 JS 动态 append 的,统一 refresh 一次
|
||
$selects.selectpicker('refresh');
|
||
}
|
||
|
||
$INQURY_BOX.find("[name='product_name']").each(function () {
|
||
var i = $(this);
|
||
var api = apiPath + `/shop-api/External/SearchProduct?clientId=${clientId}&siteId=${siteId}&linkUrl=${window.location.href}`;
|
||
|
||
$.get(api).done(function (response) {
|
||
if (response.code == 0) {
|
||
i.val(response.data.product_name)
|
||
}
|
||
}).fail(function (error) {
|
||
console.log(error);
|
||
});
|
||
})
|
||
|
||
// 单行文本
|
||
$INQURY_BOX.find('.textarea-input, .one-line-input, .phone_number').each(function () {
|
||
var input = $(this);
|
||
var charCount = input.parent().find('.char-count');
|
||
var maxLength = input.prop('maxlength');
|
||
charCount.text(`0/${maxLength}`);
|
||
input.on('input', function () {
|
||
var text = input.val();
|
||
charCount.text(text.length + '/' + maxLength);
|
||
|
||
if (input.attr('name') == 'mobile' && text.length < 5) {
|
||
input.addClass('error')
|
||
input.parent().find(".crmForm-error").remove();
|
||
input.after('<div class="crmForm-error">Minimum 5 characters, please re-enter</div>')
|
||
}
|
||
|
||
if (input.attr('name') == 'mobile' && text.length > 4) {
|
||
var $codeSelect = input.closest('.phone-wrap').find('.phone-code-select');
|
||
if (!$codeSelect.val() && $codeSelect.attr('required')) {
|
||
input.removeClass('error')
|
||
$codeSelect.addClass('error')
|
||
input.parent().find(".crmForm-error").remove();
|
||
input.after('<div class="crmForm-error">This field is required</div>')
|
||
} else {
|
||
input.removeClass('error')
|
||
input.parent().find(".crmForm-error").remove();
|
||
}
|
||
}
|
||
|
||
if (text.length > maxLength) {
|
||
input.val(text.substring(0, maxLength));
|
||
charCount.text(maxLength + '/' + maxLength);
|
||
}
|
||
|
||
})
|
||
});
|
||
|
||
// country下拉
|
||
var $countrySelect = $INQURY_BOX.find('.country-select>select')
|
||
$.each(countryList, function (index, item) {
|
||
let optionElement = $("<option>").attr("value", item).text(item);
|
||
$countrySelect.append(optionElement);
|
||
})
|
||
|
||
// phoneCode - 为每个表单实例填充选项
|
||
var $codeSelects = $INQURY_BOX.find(".phone-wrap .phone-code-select");
|
||
$codeSelects.each(function() {
|
||
var $select = $(this);
|
||
$.each(phoneCode, function (index, item) {
|
||
let optionElement = $("<option>").attr("value", item.areaCode).text(item.areaCode).attr("data-subtext", "(" + item.areaEn + ")");
|
||
$select.append(optionElement);
|
||
});
|
||
});
|
||
|
||
// 兜底:不依赖 window.onload,尽早初始化下拉(避免被 iframe 卡住)
|
||
// 重要:先添加 option,再初始化 selectpicker
|
||
initSelectpicker();
|
||
|
||
// checkbox
|
||
$INQURY_BOX.find('.checkbox-wrap-listen').off('click');
|
||
$INQURY_BOX.find('.checkbox-wrap-listen').on('click', function (event) {
|
||
event.stopPropagation();
|
||
var checkbox = $(this).find('input[type="checkbox"]');
|
||
checkbox.prop('checked', !checkbox.prop('checked'));
|
||
});
|
||
|
||
// 上传附件
|
||
$INQURY_BOX.find("#uploadContainer").on("click", function () {
|
||
$INQURY_BOX.find("#fileInput").click();
|
||
});
|
||
$INQURY_BOX.find("#fileInput").on("change", function () {
|
||
var maxFiles = $(this).attr('data-max');
|
||
var v = $INQURY_BOX.find('.attachment-value').val()
|
||
var uploadedFiles = v ? v.split(',').length : 0;
|
||
// 获取用户选择的文件
|
||
var files = this.files;
|
||
if (uploadedFiles + files.length > maxFiles) {
|
||
this.value = '';
|
||
alert(`Up to ${maxFiles} uploads`);
|
||
return;
|
||
}
|
||
|
||
var uploadUrl = apiPath + `/shop-api/External/UploadFile?clientId=${clientId}&siteId=${siteId}`;
|
||
|
||
for (let i = 0; i < files.length; i++) {
|
||
let formData = new FormData();
|
||
formData.append('file', files[i]);
|
||
formData.append('name', files[i].name);
|
||
let [name, type] = splitFileName(files[i].name)
|
||
|
||
if (files[i].size > 30 * 1024 * 1024) {
|
||
// 文件size大于30m,不上传,直接add item
|
||
var listItemError = $('<div class="attachment-file-item error">')
|
||
listItemError.append($('<i class="iconfont iconfont-File file-icon">'))
|
||
var te = $('<div class="attachment-file-name">')
|
||
te.append($("<div class='attachment-file-name-text'></div>").text(name + "."))
|
||
te.append($("<div class='attachment-file-name-type'></div>").text(type))
|
||
listItemError.append(te)
|
||
listItemError.append($('<i class="iconfont iconfont-shanchu del-icon">'))
|
||
listItemError.append($('<div class="file-error">').text("Maximum 30MB, please re-upload"))
|
||
$INQURY_BOX.find('.attachment-file').append(listItemError);
|
||
} else {
|
||
$.ajax({
|
||
url: uploadUrl,
|
||
type: 'POST',
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
success: function (result) {
|
||
console.log('result', result);
|
||
let r = result.code
|
||
let u = result.data?.url
|
||
var listItem = $(`<div class="attachment-file-item ${r === -1 ? "error" : ""}">`);
|
||
if (type == "jpg" || type == "png" || type == "jpeg") {
|
||
listItem.append($('<img>').attr('src', u))
|
||
} else {
|
||
listItem.append($('<i class="iconfont iconfont-File file-icon">'))
|
||
}
|
||
var te = $('<div class="attachment-file-name">')
|
||
te.append($("<div class='attachment-file-name-text'></div>").text(name + "."))
|
||
te.append($("<div class='attachment-file-name-type'></div>").text(type))
|
||
listItem.append(te)
|
||
listItem.append($('<i class="iconfont iconfont-shanchu del-icon">'))
|
||
$INQURY_BOX.find('.attachment-file').append(listItem);
|
||
|
||
if (r === 0) {
|
||
var o = $INQURY_BOX.find(".attachment-value").val()
|
||
$INQURY_BOX.find(".attachment-value").val(o ? o + ',' + u : u);
|
||
$INQURY_BOX.find(".attachment>.crmForm-error").remove();
|
||
$INQURY_BOX.find(".attachment>input.error").removeClass('error')
|
||
} else {
|
||
// 第一次上传文件失败,需要清空值
|
||
if (!uploadedFiles) {
|
||
$INQURY_BOX.find("#fileInput").val('');
|
||
}
|
||
listItem.append($('<div class="file-error">').text(result.msg))
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error('上传文件时出错:', error);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
// 删除附件
|
||
$INQURY_BOX.find(".attachment-file").on("click", ".del-icon", function () {
|
||
var d = $(this).closest(".attachment-file-item");
|
||
var i = d.index(); d.remove();
|
||
var $attachmentValue = $INQURY_BOX.find(".attachment-value");
|
||
var values = $attachmentValue.val().split(",");
|
||
values.splice(i, 1);
|
||
$attachmentValue.val(values.join(","));
|
||
|
||
if (!$attachmentValue.val()) {
|
||
$INQURY_BOX.find("#fileInput").val('');
|
||
}
|
||
});
|
||
|
||
$INQURY_BOX.find(':input[required]').bind("keyup blur", function () {
|
||
var element = $(this);
|
||
var value = element.val();
|
||
|
||
if (Array.isArray(value)) {
|
||
value = value.join('');
|
||
}
|
||
// 如果输入的全是空格
|
||
if (value && value.trim() === '') {
|
||
element.addClass('error');
|
||
// 移除旧的错误提示
|
||
element.parent().find('.crmForm-error').remove();
|
||
// 添加新的错误提示
|
||
element.after('<div class="crmForm-error">Cannot contain only spaces</div>');
|
||
return;
|
||
}
|
||
|
||
// 如果开头结尾是空格
|
||
if (value && value.startsWith(' ')) {
|
||
element.val(value.trim());
|
||
}
|
||
|
||
// 如果有值且不是纯空格,移除错误状态
|
||
if (value && value.trim() && element.attr("name") !== "mobile") {
|
||
element.removeClass('error');
|
||
element.parent().find('.crmForm-error').remove();
|
||
}
|
||
|
||
// 如果是email,验证邮箱格式
|
||
if (element.attr("name") == "email") {
|
||
_crmEmailVali($(this), crmEmailStr);
|
||
} else {
|
||
_crmEmailVali($(this), crmValidStr);
|
||
}
|
||
|
||
});
|
||
|
||
$INQURY_BOX.find('input[type="checkbox"] , input[type="radio"]').change(function () {
|
||
var element = $(this);
|
||
if (element.is(':checked')) {
|
||
element.parent().parent().find(".crmForm-error").remove();
|
||
}
|
||
});
|
||
|
||
$INQURY_BOX.find('.selectpicker').on('change.bs.select', function (e) {
|
||
if ($(this).val()) {
|
||
$(this).removeClass('error');
|
||
$(this).parent().find(".crmForm-error").remove();
|
||
}
|
||
|
||
if ($(this).attr('name') == 'code' && $(this).val()) {
|
||
var $phoneWrap = $(this).closest('.phone-wrap');
|
||
if ($phoneWrap.find('input.phone_number').val().length > 4) {
|
||
$phoneWrap.find('.crmForm-error').remove();
|
||
}
|
||
}
|
||
});
|
||
|
||
// 提交的校验
|
||
$INQURY_BOX.find("form").submit(function () {
|
||
var form = $(this);
|
||
|
||
if (checkBeforeSubmit(form)) {
|
||
// 验证成功,继续处理表单提交逻辑
|
||
form.find(".create-form-submit").attr("disabled", "disabled").append('<span class="crm-submit-load"></span>');
|
||
var url = apiPath + "/managedata/aifeedback/add.php?";
|
||
var parsedDict = parseQueryString(form.serialize());
|
||
var outputString = generateQueryString(parsedDict);
|
||
var dataObject = Object.fromEntries(new URLSearchParams(outputString));
|
||
dataObject.pagetitle = document.title;
|
||
dataObject.page_link = window.location.href;
|
||
var parseCookie = (value) =>
|
||
value
|
||
.split(';')
|
||
.map(v => v.split('='))
|
||
.reduce((acc, v) => {
|
||
acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1]?.trim());
|
||
return acc;
|
||
}, {});
|
||
dataObject.gclid = parseCookie(document.cookie).gclid || "";
|
||
dataObject.site_session_id = window.matomo_site_id_cookie_key || "";
|
||
var modifiedData = new URLSearchParams(dataObject).toString();
|
||
$.post(url + $.param({ siteId: siteId, clientId: clientId }), modifiedData, function (result) {
|
||
handleSubmitResult(form, result);
|
||
console.log('result', result)
|
||
}, 'json');
|
||
}
|
||
return false;
|
||
});
|
||
|
||
function checkBeforeSubmit(form) {
|
||
// 如果tel长度小于5 直接返回false
|
||
var isTelValid = form.find("input[name='mobile']").val() && form.find("input[name='mobile']").val().length < 5;
|
||
if (isTelValid) {
|
||
return false
|
||
}
|
||
|
||
var isValid = form[0].checkValidity();
|
||
$(form[0].querySelectorAll('.crmForm-error')).remove();
|
||
|
||
if (!isValid) {
|
||
// 验证失败,加error样式和统一错误文案
|
||
var invalidElements = $(form[0].querySelectorAll(':invalid'));
|
||
var radioName = []
|
||
|
||
invalidElements.each(function () {
|
||
var element = $(this);
|
||
element.removeClass('error')
|
||
|
||
// raido
|
||
if (element.is(':radio')) {
|
||
var groupName = element.attr('name');
|
||
if (!radioName.includes(groupName) && $INQURY_BOX.find(':input[name="' + groupName + '"]:checked').length === 0) {
|
||
!radioName.includes(groupName) && radioName.push(groupName)
|
||
element.addClass('error');
|
||
element.parent().last().after('<div class="crmForm-error">This is a required field</div>')
|
||
}
|
||
}
|
||
|
||
if (element.val() == '' || element.val() == null || element.val() == []) {
|
||
element.addClass('error')
|
||
element.after('<div class="crmForm-error">This is a required field</div>')
|
||
}
|
||
});
|
||
}
|
||
|
||
// 检查所有必填输入框
|
||
form.find(':input[required]').each(function () {
|
||
var $input = $(this);
|
||
var value = $input.val();
|
||
|
||
// Check if value is an array and concatenate if necessary
|
||
if (Array.isArray(value)) {
|
||
value = value.join('').trim();
|
||
} else {
|
||
value = value.trim();
|
||
}
|
||
|
||
// 如果全是空格
|
||
if (!value) {
|
||
isValid = false;
|
||
$input.addClass('error');
|
||
// 移除旧的错误提示
|
||
$input.parent().find('.crmForm-error').remove();
|
||
// 添加新的错误提示
|
||
$input.after('<div class="crmForm-error">This is a required field</div>');
|
||
return false;
|
||
}
|
||
});
|
||
|
||
var isCheckboxValid = true;
|
||
var checkboxName = []
|
||
$INQURY_BOX.find(':checkbox').each(function () {
|
||
var element = $(this);
|
||
var groupName = element.attr('name');
|
||
var isrequired = element.parent().attr('data-required')
|
||
|
||
// 检查复选框组是否已经在 checkboxName 数组中,如果不在且未选中任何复选框,则将其添加到数组中
|
||
if (isrequired && !checkboxName.includes(groupName) && $INQURY_BOX.find(':input[name="' + groupName + '"]:checked').length === 0) {
|
||
isCheckboxValid = false;
|
||
checkboxName.push(groupName);
|
||
element.addClass('error');
|
||
element.parent().last().after('<div class="crmForm-error">This is a required field</div>');
|
||
}
|
||
});
|
||
|
||
var isEmialValid = true;
|
||
form.find("input[name='email']").each(function () {
|
||
if (!_crmEmailVali($(this), "Please enter a valid email address")) { isEmialValid = false; }
|
||
});
|
||
return isValid && isCheckboxValid && isEmialValid;
|
||
}
|
||
|
||
function _crmEmailVali(item, text) {
|
||
item.removeClass('error');
|
||
item.parent().find(".crmForm-error").remove();
|
||
var value = $.trim(item.val());
|
||
var re = /[A-Za-z0-9.\-+_]+@[a-z0-9.\-+_]+\.[a-z]{2,3}/;
|
||
if (item.attr("name") == "email") {
|
||
if (item.attr('required') && value == '') { item.after('<div class="crmForm-error">' + text + '</div>'); item.addClass('error'); return false; }
|
||
if (value && !re.test(value)) { text = 'Your email is invalid'; item.after('<div class="crmForm-error">' + text + '</div>'); item.addClass('error'); return false; }
|
||
return true;
|
||
} else if (!value) {
|
||
item.after('<div class="crmForm-error">' + text + '</div>'); return false;
|
||
} else {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function _crmAlertText(type, text) {
|
||
$("body").addClass("crm-body-clear");
|
||
var succ = '<div id="crmMailMask"><div class="crmMailMask-box"><div class="crmMailMask-boxTop">' + text + '</div><div class="crmMailMask-boxBot"><button type="button" class="crmMailMask-close"> OK </button></div></div></div>';
|
||
if (type == 1) {
|
||
$("body").find("#crmMailMask").remove();
|
||
$("body").append(succ);
|
||
}
|
||
$(".crmMailMask-close").click(function () {
|
||
$("#crmMailMask").remove();
|
||
$("body").removeClass("crm-body-clear");
|
||
});
|
||
}
|
||
|
||
function handleSubmitResult(form, result) {
|
||
try {
|
||
form.find(".create-form-submit").removeAttr("disabled").find(".crm-submit-load").remove();
|
||
if (result.code == '0') {
|
||
form[0].reset();
|
||
resetOtherData();
|
||
$('.click-popup').removeClass('is-visible');
|
||
|
||
$INQURY_BOX.find('.char-count').each(function (_index, element) {
|
||
var $element = $(element);
|
||
var t = $element.text();
|
||
var parts = t.split('/');
|
||
if (!parts[0]) {
|
||
parts[0] = '0';
|
||
$element.text(parts.join('/'));
|
||
}
|
||
});
|
||
|
||
if (typeof gtag_report_conversion === "function") {
|
||
gtag_report_conversion();
|
||
} else {
|
||
console.log('不存在谷歌表单函数');
|
||
}
|
||
var lang = '';
|
||
var currentLang = $(':visible').filter('.current-lang em');
|
||
if (currentLang.length > 0) {
|
||
lang = currentLang.eq(0).text().trim().toLowerCase();
|
||
} else {
|
||
lang = $('html').attr('lang');
|
||
}
|
||
|
||
if ($INQURY_BOX.data('attr-download-pop')) {
|
||
// dispatch custom event to notify the parent to handle the success callback
|
||
const event = new CustomEvent('inquirySuccessCallback', { detail: { formInquiry: $INQURY_BOX } });
|
||
document.dispatchEvent(event);
|
||
|
||
$('.click-popup-download').removeClass('is-visible');
|
||
if (localStorage.getItem('download_src')) {
|
||
window.open(localStorage.getItem('download_src'), '_blank');
|
||
} else {
|
||
console.log('download_src is not set');
|
||
}
|
||
} else {
|
||
window.location.href = lang ? `/${lang}/inquiry_success`: '/inquiry_success';
|
||
}
|
||
} else {
|
||
_crmAlertText(1, crmFailedStr);
|
||
}
|
||
} catch (error) {
|
||
_crmAlertText(1, error.message || crmFailedStr);
|
||
}
|
||
}
|
||
|
||
|
||
function parseQueryString(queryString) {
|
||
var parsedDict = {};
|
||
var pairs = queryString.split('&');
|
||
for (pair of pairs) {
|
||
var [key, value] = pair.split('=');
|
||
var decodedKey = decodeURIComponent(key);
|
||
var decodedValue = decodeURIComponent(value);
|
||
if (decodedKey in parsedDict) {
|
||
if (Array.isArray(parsedDict[decodedKey])) {
|
||
parsedDict[decodedKey].push(decodedValue);
|
||
} else {
|
||
parsedDict[decodedKey] = [parsedDict[decodedKey], decodedValue];
|
||
}
|
||
} else {
|
||
parsedDict[decodedKey] = decodedValue;
|
||
}
|
||
}
|
||
|
||
// code和phone合并
|
||
if (parsedDict.code || parsedDict.mobile) {
|
||
parsedDict.mobile = "" + parsedDict.code + parsedDict.mobile
|
||
delete parsedDict.code;
|
||
}
|
||
|
||
return parsedDict;
|
||
}
|
||
|
||
function generateQueryString(parsedDict) {
|
||
var pairs = [];
|
||
for (const [key, value] of Object.entries(parsedDict)) {
|
||
pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
||
}
|
||
return pairs.join('&');
|
||
}
|
||
|
||
function splitFileName(string) {
|
||
const parts = string.split('.'); // 将字符串按句点分割成数组
|
||
const type = parts.pop(); // 弹出数组的最后一个元素
|
||
const name = parts.join('.'); // 将剩余的部分重新组合成字符串
|
||
return [name, type];
|
||
}
|
||
|
||
function resetOtherData() {
|
||
// 插件缺失时无需 refresh(并且调用会报错)
|
||
if (!(window.jQuery && $.fn && typeof $.fn.selectpicker === 'function')) {
|
||
// 删除附件的item
|
||
$INQURY_BOX.find(".attachment-file").empty();
|
||
$(".click-popup").removeClass("is-visible");
|
||
return;
|
||
}
|
||
|
||
// 获取选择框元素
|
||
var selectElement = $INQURY_BOX.find('.mul-select-wrap .selectpicker');
|
||
selectElement.each(function () {
|
||
var sl = $(this);
|
||
sl.val(''); sl.selectpicker('refresh');
|
||
})
|
||
// 删除code
|
||
var phonecode = $INQURY_BOX.find(".phone-wrap .selectpicker");
|
||
phonecode.each(function () {
|
||
var c = $(this);
|
||
c.val(''); c.selectpicker('refresh');
|
||
})
|
||
// 删除附件的item
|
||
$INQURY_BOX.find(".attachment-file").empty();
|
||
$(".click-popup").removeClass("is-visible");
|
||
}
|
||
});
|
||
// 询盘点击弹出
|
||
jQuery(document).ready(function ($) {
|
||
if (typeof cdPopupFlag !== 'undefined') return;
|
||
cdPopupFlag = 1;
|
||
|
||
//open popup
|
||
$('.cd-popup-trigger').on('click', function() {
|
||
var index = $('.cd-popup-trigger').index(this);
|
||
$('.click-popup').removeClass('is-visible');
|
||
$('.click-popup').eq(index).addClass('is-visible');
|
||
});
|
||
// mobile popup
|
||
$('.m-cd-popup-trigger').on('click', function() {
|
||
$('.click-popup').removeClass('is-visible');
|
||
$('.click-popup').eq(0).addClass('is-visible');
|
||
});
|
||
// three party
|
||
$('.fix-cd-popup-trigger').on('click', function() {
|
||
$('.click-popup').removeClass('is-visible');
|
||
$('.click-popup').eq(0).addClass('is-visible');
|
||
});
|
||
|
||
//close popup
|
||
$('.click-popup').on('click', function (event) {
|
||
if ($(event.target).is('.cd-popup-close') || $(event.target).is('.click-popup')) {
|
||
event.preventDefault();
|
||
$(this).removeClass('is-visible');
|
||
}
|
||
});
|
||
|
||
//close popup when clicking the esc keyboard button
|
||
$(document).keyup(function (event) {
|
||
if (event.which == '27') {
|
||
$('.click-popup').removeClass('is-visible');
|
||
}
|
||
});
|
||
|
||
//open popup
|
||
$('.cd-popup-trigger-download').on('click', function() {
|
||
localStorage.setItem('download_src', $(this).data('src'));
|
||
$('.click-popup').removeClass('is-visible');
|
||
$('.click-popup-download').addClass('is-visible');
|
||
});
|
||
|
||
//close popup
|
||
$('.click-popup-download').on('click', function (event) {
|
||
if ($(event.target).is('.cd-popup-close') || $(event.target).is('.click-popup-download')) {
|
||
event.preventDefault();
|
||
$(this).removeClass('is-visible');
|
||
localStorage.setItem('download_src', '');
|
||
}
|
||
});
|
||
|
||
//close popup when clicking the esc keyboard button
|
||
$(document).keyup(function (event) {
|
||
if (event.which == '27') {
|
||
$('.click-popup-download').removeClass('is-visible');
|
||
localStorage.setItem('download_src', '');
|
||
}
|
||
});
|
||
});;
|
||
var initFilter = 'all';
|
||
const DESIGN_WIDTH = 1920;
|
||
const BASE_REM = 32;
|
||
const MIN_FONT_SIZE = 12;
|
||
const MAX_FONT_SIZE = 48;
|
||
|
||
function debounce(fn, delay = 100) {
|
||
let timer = null;
|
||
return () => {
|
||
clearTimeout(timer);
|
||
timer = setTimeout(() => fn(), delay);
|
||
};
|
||
}
|
||
|
||
function restoreNavLinkPlain(wrap) {
|
||
var inner = wrap.querySelector('.nav-link-marquee-inner');
|
||
if (!inner) return;
|
||
var seg = wrap.querySelector('.nav-link-marquee-seg');
|
||
var txt = seg ? seg.textContent : '';
|
||
wrap.innerHTML = '';
|
||
var t = document.createElement('span');
|
||
t.className = 'nav-link-text';
|
||
t.textContent = txt;
|
||
wrap.appendChild(t);
|
||
}
|
||
|
||
function setupNavLinkMarqueeForLink(link) {
|
||
var wrap = link.querySelector('.nav-link-text-wrap');
|
||
if (!wrap) return;
|
||
restoreNavLinkPlain(wrap);
|
||
link.classList.remove('nav-link--marquee');
|
||
var textEl = wrap.querySelector('.nav-link-text');
|
||
if (!textEl) return;
|
||
if (textEl.scrollWidth <= wrap.clientWidth + 1) return;
|
||
var txt = textEl.textContent;
|
||
var inner = document.createElement('span');
|
||
inner.className = 'nav-link-marquee-inner';
|
||
var seg1 = document.createElement('span');
|
||
seg1.className = 'nav-link-marquee-seg';
|
||
seg1.textContent = txt;
|
||
var seg2 = document.createElement('span');
|
||
seg2.className = 'nav-link-marquee-seg';
|
||
seg2.setAttribute('aria-hidden', 'true');
|
||
seg2.textContent = txt;
|
||
inner.appendChild(seg1);
|
||
inner.appendChild(seg2);
|
||
wrap.innerHTML = '';
|
||
wrap.appendChild(inner);
|
||
link.classList.add('nav-link--marquee');
|
||
var half = inner.scrollWidth / 2;
|
||
var pxPerSec = 35;
|
||
inner.style.animationDuration = Math.max(6, half / pxPerSec) + 's';
|
||
}
|
||
|
||
function initNavLinkMarquee() {
|
||
var desktop = window.matchMedia('(min-width: 992px)').matches;
|
||
var selector = desktop
|
||
? '.yuedong_head .yuedong-head-menu .navbar-collapse .nav-item > .nav-link'
|
||
: '.yuedong_head .mobile-menu .nav-item > .nav-link';
|
||
document.querySelectorAll(selector).forEach(function (link) {
|
||
setupNavLinkMarqueeForLink(link);
|
||
});
|
||
}
|
||
|
||
function setRemUnit() {
|
||
let screenWidth = document.documentElement.clientWidth || window.innerWidth;
|
||
if (screenWidth > 1630) {
|
||
screenWidth = 1920
|
||
} else if (screenWidth > 1500) {
|
||
screenWidth = 1820
|
||
} else if (screenWidth > 1200) {
|
||
screenWidth = 1440
|
||
} else if (screenWidth > 992) {
|
||
screenWidth = 1200
|
||
} else {
|
||
screenWidth = 992
|
||
}
|
||
let fontSize = screenWidth / (DESIGN_WIDTH / BASE_REM);
|
||
fontSize = Math.max(MIN_FONT_SIZE, Math.min(MAX_FONT_SIZE, fontSize));
|
||
document.documentElement.style.fontSize = `${fontSize}px`;
|
||
}
|
||
|
||
setRemUnit();
|
||
|
||
window.addEventListener('resize', debounce(setRemUnit));
|
||
window.addEventListener('orientationchange', debounce(setRemUnit));
|
||
$(function () {
|
||
$('.input-wrap-box input[name*="mobile"]').attr('type', 'number').attr('name', 'mobile');
|
||
$('.input-wrap-box input[name*="phone"]').attr('type', 'number').attr('name', 'mobile');
|
||
$('.input-wrap-box input[name*="tel"]').attr('type', 'number').attr('name', 'mobile');
|
||
$('.input-wrap-box input[name*="Whatsapp"]').attr('type', 'number').attr('name', 'mobile');
|
||
var previousIcon = `
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="7" height="13" viewBox="0 0 7 13" fill="none">
|
||
<path d="M6.5 12.5L0.5 6.5L6.5 0.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
||
</svg>
|
||
`;
|
||
|
||
var nextIcon = `
|
||
<svg xmlns="http://www.w3.org/2000/svg" width="7" height="13" viewBox="0 0 7 13" fill="none">
|
||
<path d="M0.5 12.5L6.5 6.5L0.5 0.5" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
||
</svg>
|
||
`;
|
||
|
||
var $firstPage = $('#pagesize ul li:first-child a');
|
||
var $lastPage = $('#pagesize ul li:last-child a');
|
||
if ($firstPage.length) {
|
||
$firstPage.html(previousIcon);
|
||
}
|
||
if ($lastPage.length) {
|
||
$lastPage.html(nextIcon);
|
||
}
|
||
if ($(".yuedong-counter").length) {
|
||
$(".yuedong-counter").counterUp({
|
||
delay: 20,
|
||
time: 3000,
|
||
});
|
||
}
|
||
if ($(window).width() < 992) {
|
||
$(".navbar-collapse .hasSubNav").on("click", function (e) {
|
||
e.preventDefault()
|
||
e.stopPropagation()
|
||
$(this).siblings('.dropdown-menu').toggleClass('d-block')
|
||
});
|
||
|
||
$(".navbar-collapse .hasSubNav span").on("click", function (e) {
|
||
e.stopPropagation()
|
||
var href = $(this).parent('a').attr('href')
|
||
if (href && href !== '#' && href !== '') {
|
||
window.location.href = href
|
||
}
|
||
});
|
||
|
||
$(".navbar-collapse .dropdown-submenu").on("click", function (e) {
|
||
e.preventDefault()
|
||
e.stopPropagation()
|
||
$(this).children('.dropdown-menu').toggleClass('d-block')
|
||
});
|
||
$(".navbar-collapse .dropdown-submenu span").on("click", function (e) {
|
||
e.stopPropagation()
|
||
var href = $(this).parent('a').attr('href')
|
||
if (href && href !== '#' && href !== '') {
|
||
window.location.href = href
|
||
}
|
||
});
|
||
}
|
||
|
||
$('.navbar-toggler').on('click', function () {
|
||
$('.mobile-menu').toggleClass('show');
|
||
});
|
||
$('.collapse .qico-guanbi').on('click', function () {
|
||
$('.mobile-menu').removeClass('show');
|
||
});
|
||
$('.head-search em').click(function () {
|
||
$('.serchbox').addClass('active');
|
||
});
|
||
$('.serchbox').click(function () {
|
||
$('.serchbox').removeClass('active');
|
||
});
|
||
$('.serchbox form').click(function (e) {
|
||
e.preventDefault();
|
||
e.stopPropagation();
|
||
});
|
||
$('.serchbox .submit_btn').click(function () {
|
||
var formData = $(this).parents('.serchbox').find('form').serialize();
|
||
window.location.href = `/search?${formData}`;
|
||
});
|
||
|
||
$(window).scroll(function () {
|
||
if ($(this).scrollTop() > 100) {
|
||
$(".yuedong-head-menu").addClass("fixed-top")
|
||
} else {
|
||
$(".yuedong-head-menu").removeClass("fixed-top");
|
||
}
|
||
if (
|
||
document.body.scrollTop > 150 ||
|
||
document.documentElement.scrollTop > 150
|
||
) {
|
||
$("#scroll-top").addClass("active");
|
||
} else {
|
||
$("#scroll-top").removeClass("active");
|
||
}
|
||
});
|
||
|
||
$("#scroll-top").on("click", function () {
|
||
$("html, body").animate({ scrollTop: 0 }, 1000);
|
||
return false;
|
||
});
|
||
|
||
$("#go-back").on("click", function () {
|
||
window.history.go(-1);
|
||
return false;
|
||
});
|
||
|
||
initNavLinkMarquee();
|
||
$(window).on('resize', debounce(initNavLinkMarquee));
|
||
$(window).on('load', function () {
|
||
initNavLinkMarquee();
|
||
});
|
||
});;
|
||
$(document).ready(function () {
|
||
new Swiper('.yuedong_banner_swiper', {
|
||
slidesPerView: 1,
|
||
loop: true,
|
||
effect: 'fade',
|
||
fadeEffect: {
|
||
crossFade: true,
|
||
},
|
||
autoplay: {
|
||
delay: 5000,
|
||
disableOnInteraction: false,
|
||
},
|
||
navigation: {
|
||
nextEl: '.yuedong_banner_swiper .swiper-button-next',
|
||
prevEl: '.yuedong_banner_swiper .swiper-button-prev',
|
||
},
|
||
});
|
||
});;
|
||
$(document).ready(function () {
|
||
new Swiper('.yuedong_goods_type_swiper', {
|
||
slidesPerView: 1,
|
||
spaceBetween: 24,
|
||
loop: true,
|
||
autoplay: {
|
||
delay: 3000,
|
||
disableOnInteraction: false,
|
||
},
|
||
effect: 'slide',
|
||
navigation: {
|
||
nextEl: '.yuedong_goods_type_main .swiper-button-prev',
|
||
prevEl: '.yuedong_goods_type_main .swiper-button-next',
|
||
},
|
||
});
|
||
});
|
||
;
|
||
$(function () {
|
||
if (typeof Swiper === 'undefined') return;
|
||
|
||
if (!$('.yuedong_home_partner_swiper').length) return;
|
||
|
||
// Swiper 的 pagination.el 必须传原生 DOM 元素(不能直接传 jQuery 对象)
|
||
const $swiper = $('.yuedong_home_partner_swiper').first();
|
||
const swiperEl = $swiper[0];
|
||
const $pagination = $swiper
|
||
.closest('.yuedong_home_partner_cards_wrap')
|
||
.find('.swiper-pagination')
|
||
.first();
|
||
const paginationEl = $pagination[0];
|
||
|
||
if (!swiperEl || !paginationEl) return;
|
||
|
||
new Swiper(swiperEl, {
|
||
slidesPerView: 6,
|
||
spaceBetween: 31,
|
||
speed: 600,
|
||
loop: true,
|
||
autoplay: {
|
||
delay: 3000,
|
||
disableOnInteraction: false,
|
||
},
|
||
pagination: {
|
||
el: paginationEl,
|
||
clickable: true,
|
||
},
|
||
breakpoints: {
|
||
1280: {
|
||
slidesPerView: 6,
|
||
},
|
||
1200: {
|
||
slidesPerView: 5,
|
||
},
|
||
992: {
|
||
slidesPerView: 4,
|
||
},
|
||
768: {
|
||
slidesPerView: 3,
|
||
},
|
||
320: {
|
||
slidesPerView: 2,
|
||
},
|
||
}
|
||
});
|
||
});
|
||
;
|
||
$(document).ready(function () {
|
||
var phoneCode = [
|
||
{ "areaEn": "Albania", "areaCode": "+355" },
|
||
{ "areaEn": "Algeria", "areaCode": "+213" },
|
||
{ "areaEn": "Afghanistan", "areaCode": "+93" },
|
||
{ "areaEn": "Argentina", "areaCode": "+54" },
|
||
{ "areaEn": "United Arab Emirates", "areaCode": "+971" },
|
||
{ "areaEn": "Aruba", "areaCode": "+297" },
|
||
{ "areaEn": "Oman", "areaCode": "+968" },
|
||
{ "areaEn": "Azerbaijan", "areaCode": "+994" },
|
||
{ "areaEn": "Ascension Island", "areaCode": "+247" },
|
||
{ "areaEn": "Egypt", "areaCode": "+20" },
|
||
{ "areaEn": "Ethiopia", "areaCode": "+251" },
|
||
{ "areaEn": "Ireland", "areaCode": "+353" },
|
||
{ "areaEn": "Estonia", "areaCode": "+372" },
|
||
{ "areaEn": "Andorra", "areaCode": "+376" },
|
||
{ "areaEn": "Angola", "areaCode": "+244" },
|
||
{ "areaEn": "Antigua and Barbuda", "areaCode": "+1" },
|
||
{ "areaEn": "Austria", "areaCode": "+43" },
|
||
{ "areaEn": "Australia", "areaCode": "+61" },
|
||
{ "areaEn": "Macao Special Administrative Region", "areaCode": "+853" },
|
||
{ "areaEn": "Barbados", "areaCode": "+1" },
|
||
{ "areaEn": "Papua New Guinea", "areaCode": "+675" },
|
||
{ "areaEn": "Bahamas", "areaCode": "+1" },
|
||
{ "areaEn": "Pakistan", "areaCode": "+92" },
|
||
{ "areaEn": "Paraguay", "areaCode": "+595" },
|
||
{ "areaEn": "Palestinian National Authority", "areaCode": "+970" },
|
||
{ "areaEn": "Bahrain", "areaCode": "+973" },
|
||
{ "areaEn": "Panama", "areaCode": "+507" },
|
||
{ "areaEn": "Brazil", "areaCode": "+55" },
|
||
{ "areaEn": "Belarus", "areaCode": "+375" },
|
||
{ "areaEn": "Bermuda", "areaCode": "+1" },
|
||
{ "areaEn": "Bulgaria", "areaCode": "+359" },
|
||
{ "areaEn": "Northern Mariana Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Benin", "areaCode": "+229" },
|
||
{ "areaEn": "Belgium", "areaCode": "+32" },
|
||
{ "areaEn": "Iceland", "areaCode": "+354" },
|
||
{ "areaEn": "Poland", "areaCode": "+48" },
|
||
{ "areaEn": "Bosnia and Herzegovina", "areaCode": "+387" },
|
||
{ "areaEn": "Bolivia", "areaCode": "+591" },
|
||
{ "areaEn": "Belize", "areaCode": "+501" },
|
||
{ "areaEn": "Botswana", "areaCode": "+267" },
|
||
{ "areaEn": "Bonaire", "areaCode": "+599" },
|
||
{ "areaEn": "Bhutan", "areaCode": "+975" },
|
||
{ "areaEn": "Burkina Faso", "areaCode": "+226" },
|
||
{ "areaEn": "Burundi", "areaCode": "+257" },
|
||
{ "areaEn": "Bouvet Island", "areaCode": "+47" },
|
||
{ "areaEn": "Korea", "areaCode": "+850" },
|
||
{ "areaEn": "Equatorial Guinea", "areaCode": "+240" },
|
||
{ "areaEn": "Denmark", "areaCode": "+45" },
|
||
{ "areaEn": "Germany", "areaCode": "+49" },
|
||
{ "areaEn": "East Timor", "areaCode": "+670" },
|
||
{ "areaEn": "Togo", "areaCode": "+228" },
|
||
{ "areaEn": "Dominican Republic", "areaCode": "+1809" },
|
||
{ "areaEn": "Dominic", "areaCode": "+1" },
|
||
{ "areaEn": "Russia", "areaCode": "+7" },
|
||
{ "areaEn": "Ecuador", "areaCode": "+593" },
|
||
{ "areaEn": "Eritrea", "areaCode": "+291" },
|
||
{ "areaEn": "France", "areaCode": "+33" },
|
||
{ "areaEn": "Faroe Islands", "areaCode": "+298" },
|
||
{ "areaEn": "French Polynesia", "areaCode": "+689" },
|
||
{ "areaEn": "French Guiana", "areaCode": "+594" },
|
||
{ "areaEn": "Vatican", "areaCode": "+379" },
|
||
{ "areaEn": "Philippines", "areaCode": "+63" },
|
||
{ "areaEn": "Fiji", "areaCode": "+679" },
|
||
{ "areaEn": "Finland", "areaCode": "+358" },
|
||
{ "areaEn": "Cape Verde", "areaCode": "+238" },
|
||
{ "areaEn": "Falkland Islands", "areaCode": "+500" },
|
||
{ "areaEn": "Gambia", "areaCode": "+220" },
|
||
{ "areaEn": "Republic of Congo)", "areaCode": "+242" },
|
||
{ "areaEn": "Congo (Gold)", "areaCode": "+243" },
|
||
{ "areaEn": "Colombia", "areaCode": "+57" },
|
||
{ "areaEn": "Costa Rica", "areaCode": "+506" },
|
||
{ "areaEn": "Guernsey", "areaCode": "+44" },
|
||
{ "areaEn": "Grenada", "areaCode": "+1" },
|
||
{ "areaEn": "Greenland", "areaCode": "+299" },
|
||
{ "areaEn": "Georgia", "areaCode": "+995" },
|
||
{ "areaEn": "Cuba", "areaCode": "+53" },
|
||
{ "areaEn": "Guadeloupe", "areaCode": "+590" },
|
||
{ "areaEn": "Guam", "areaCode": "+1" },
|
||
{ "areaEn": "Guyana", "areaCode": "+592" },
|
||
{ "areaEn": "Kazakhstan", "areaCode": "+7" },
|
||
{ "areaEn": "Haiti", "areaCode": "+509" },
|
||
{ "areaEn": "Korea", "areaCode": "+82" },
|
||
{ "areaEn": "Netherlands", "areaCode": "+31" },
|
||
{ "areaEn": "Netherlands Antilles (front)", "areaCode": "+599" },
|
||
{ "areaEn": "Montenegro", "areaCode": "+382" },
|
||
{ "areaEn": "Honduras", "areaCode": "+504" },
|
||
{ "areaEn": "Kiribati", "areaCode": "+686" },
|
||
{ "areaEn": "Djibouti", "areaCode": "+253" },
|
||
{ "areaEn": "Kyrgyzstan", "areaCode": "+996" },
|
||
{ "areaEn": "Guinea", "areaCode": "+224" },
|
||
{ "areaEn": "Guinea-Bissau", "areaCode": "+245" },
|
||
{ "areaEn": "Canada", "areaCode": "+1" },
|
||
{ "areaEn": "Ghana", "areaCode": "+233" },
|
||
{ "areaEn": "Gabon", "areaCode": "+241" },
|
||
{ "areaEn": "Cambodia", "areaCode": "+855" },
|
||
{ "areaEn": "Czech Republic", "areaCode": "+420" },
|
||
{ "areaEn": "Zimbabwe", "areaCode": "+263" },
|
||
{ "areaEn": "Cameroon", "areaCode": "+237" },
|
||
{ "areaEn": "Qatar", "areaCode": "+974" },
|
||
{ "areaEn": "Cayman Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Cocos Islands (Keeling Islands)", "areaCode": "+61" },
|
||
{ "areaEn": "Comoros Union", "areaCode": "+269" },
|
||
{ "areaEn": "Kosovo", "areaCode": "+383" },
|
||
{ "areaEn": "Cote d'Ivoire", "areaCode": "+225" },
|
||
{ "areaEn": "Kuwait", "areaCode": "+965" },
|
||
{ "areaEn": "Croatia", "areaCode": "+385" },
|
||
{ "areaEn": "Kenya", "areaCode": "+254" },
|
||
{ "areaEn": "Kuco Islands", "areaCode": "+682" },
|
||
{ "areaEn": "Curacao", "areaCode": "+599" },
|
||
{ "areaEn": "Latvia", "areaCode": "+371" },
|
||
{ "areaEn": "Lesotho", "areaCode": "+266" },
|
||
{ "areaEn": "Laos", "areaCode": "+856" },
|
||
{ "areaEn": "Lebanon", "areaCode": "+961" },
|
||
{ "areaEn": "Lithuania", "areaCode": "+370" },
|
||
{ "areaEn": "Liberia", "areaCode": "+231" },
|
||
{ "areaEn": "Libya", "areaCode": "+218" },
|
||
{ "areaEn": "Liechtenstein", "areaCode": "+423" },
|
||
{ "areaEn": "Reunion", "areaCode": "+262" },
|
||
{ "areaEn": "Luxembourg", "areaCode": "+352" },
|
||
{ "areaEn": "Rwanda", "areaCode": "+250" },
|
||
{ "areaEn": "Romania", "areaCode": "+40" },
|
||
{ "areaEn": "Madagascar", "areaCode": "+261" },
|
||
{ "areaEn": "Isle of Man", "areaCode": "+44" },
|
||
{ "areaEn": "Maldives", "areaCode": "+960" },
|
||
{ "areaEn": "Malta", "areaCode": "+356" },
|
||
{ "areaEn": "Malawi", "areaCode": "+265" },
|
||
{ "areaEn": "Malaysia", "areaCode": "+60" },
|
||
{ "areaEn": "Mali", "areaCode": "+223" },
|
||
{ "areaEn": "Marshall Islands", "areaCode": "+692" },
|
||
{ "areaEn": "Martinique", "areaCode": "+596" },
|
||
{ "areaEn": "Mayotte", "areaCode": "+262" },
|
||
{ "areaEn": "Mauritius", "areaCode": "+230" },
|
||
{ "areaEn": "Mauritania", "areaCode": "+222" },
|
||
{ "areaEn": "United States", "areaCode": "+1" },
|
||
{ "areaEn": "US outer island", "areaCode": "+1" },
|
||
{ "areaEn": "United States Virgin Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Mongolia", "areaCode": "+976" },
|
||
{ "areaEn": "Montserrat", "areaCode": "+1" },
|
||
{ "areaEn": "Bangladesh", "areaCode": "+880" },
|
||
{ "areaEn": "Peru", "areaCode": "+51" },
|
||
{ "areaEn": "Micronesia", "areaCode": "+691" },
|
||
{ "areaEn": "Myanmar", "areaCode": "+95" },
|
||
{ "areaEn": "Moldova", "areaCode": "+373" },
|
||
{ "areaEn": "Morocco", "areaCode": "+212" },
|
||
{ "areaEn": "Monaco", "areaCode": "+377" },
|
||
{ "areaEn": "Mozambique", "areaCode": "+258" },
|
||
{ "areaEn": "Mexico", "areaCode": "+52" },
|
||
{ "areaEn": "Namibia", "areaCode": "+264" },
|
||
{ "areaEn": "South Africa", "areaCode": "+27" },
|
||
{ "areaEn": "Antarctica", "areaCode": "+672" },
|
||
{ "areaEn": "South Sudan", "areaCode": "+211" },
|
||
{ "areaEn": "Nauru", "areaCode": "+674" },
|
||
{ "areaEn": "Nepal", "areaCode": "+977" },
|
||
{ "areaEn": "Nicaragua", "areaCode": "+505" },
|
||
{ "areaEn": "Niger", "areaCode": "+227" },
|
||
{ "areaEn": "Nigeria", "areaCode": "+234" },
|
||
{ "areaEn": "Niue", "areaCode": "+683" },
|
||
{ "areaEn": "Norway", "areaCode": "+47" },
|
||
{ "areaEn": "Palau", "areaCode": "+680" },
|
||
{ "areaEn": "Portugal", "areaCode": "+351" },
|
||
{ "areaEn": "The former Yugoslav Republic of Macedonia", "areaCode": "+389" },
|
||
{ "areaEn": "Japan", "areaCode": "+81" },
|
||
{ "areaEn": "Sweden", "areaCode": "+46" },
|
||
{ "areaEn": "Switzerland", "areaCode": "+41" },
|
||
{ "areaEn": "Salvador", "areaCode": "+503" },
|
||
{ "areaEn": "Samoa", "areaCode": "+685" },
|
||
{ "areaEn": "Republic of Serbia", "areaCode": "+381" },
|
||
{ "areaEn": "Sierra Leone", "areaCode": "+232" },
|
||
{ "areaEn": "Senegal", "areaCode": "+221" },
|
||
{ "areaEn": "Cyprus", "areaCode": "+357" },
|
||
{ "areaEn": "Seychelles", "areaCode": "+248" },
|
||
{ "areaEn": "Sabah", "areaCode": "+599" },
|
||
{ "areaEn": "Saudi Arabia", "areaCode": "+966" },
|
||
{ "areaEn": "Christmas Island", "areaCode": "+61" },
|
||
{ "areaEn": "Sao Tome and Principe", "areaCode": "+239" },
|
||
{
|
||
"areaEn": "St. Helena, Ascension and Tristan da Cunha",
|
||
"areaCode": "+290"
|
||
},
|
||
{ "areaEn": "Saint Kitts and Nevis", "areaCode": "+1" },
|
||
{ "areaEn": "Saint Lucia", "areaCode": "+1" },
|
||
{ "areaEn": "San Marino", "areaCode": "+378" },
|
||
{ "areaEn": "Saint Pierre and Miquelon", "areaCode": "+508" },
|
||
{ "areaEn": "Saint Vincent and the Grenadines", "areaCode": "+1" },
|
||
{ "areaEn": "Sint Eustatius", "areaCode": "+599" },
|
||
{ "areaEn": "Sri Lanka", "areaCode": "+94" },
|
||
{ "areaEn": "Slovakia", "areaCode": "+421" },
|
||
{ "areaEn": "Slovenia", "areaCode": "+386" },
|
||
{ "areaEn": "Svalbard", "areaCode": "+47" },
|
||
{ "areaEn": "Swaziland", "areaCode": "+268" },
|
||
{ "areaEn": "Sudan", "areaCode": "+249" },
|
||
{ "areaEn": "Suriname", "areaCode": "+597" },
|
||
{ "areaEn": "Solomon Islands", "areaCode": "+677" },
|
||
{ "areaEn": "Somalia", "areaCode": "+252" },
|
||
{ "areaEn": "Tajikistan", "areaCode": "+992" },
|
||
{ "areaEn": "Taiwan", "areaCode": "+886" },
|
||
{ "areaEn": "Thailand", "areaCode": "+66" },
|
||
{ "areaEn": "Tanzania", "areaCode": "+255" },
|
||
{ "areaEn": "Tonga", "areaCode": "+676" },
|
||
{ "areaEn": "Turks and Caicos Islands", "areaCode": "+1" },
|
||
{ "areaEn": "Tristanda Kunha", "areaCode": "+290" },
|
||
{ "areaEn": "Trinidad and Tobago", "areaCode": "+1" },
|
||
{ "areaEn": "Tunisia", "areaCode": "+216" },
|
||
{ "areaEn": "Tuvalu", "areaCode": "+688" },
|
||
{ "areaEn": "Turkey", "areaCode": "+90" },
|
||
{ "areaEn": "Turkmenistan", "areaCode": "+993" },
|
||
{ "areaEn": "Tokelau", "areaCode": "+690" },
|
||
{ "areaEn": "Wallis and Futuna", "areaCode": "+681" },
|
||
{ "areaEn": "Vanuatu", "areaCode": "+678" },
|
||
{ "areaEn": "Guatemala", "areaCode": "+502" },
|
||
{ "areaEn": "Venezuela", "areaCode": "+58" },
|
||
{ "areaEn": "Brunei", "areaCode": "+673" },
|
||
{ "areaEn": "Uganda", "areaCode": "+256" },
|
||
{ "areaEn": "Ukraine", "areaCode": "+380" },
|
||
{ "areaEn": "Uruguay", "areaCode": "+598" },
|
||
{ "areaEn": "Uzbekistan", "areaCode": "+998" },
|
||
{ "areaEn": "Spain", "areaCode": "+34" },
|
||
{ "areaEn": "Greece", "areaCode": "+30" },
|
||
{ "areaEn": "Hong Kong Special Administrative Region", "areaCode": "+852" },
|
||
{ "areaEn": "Singapore", "areaCode": "+65" },
|
||
{ "areaEn": "New Caledonia", "areaCode": "+687" },
|
||
{ "areaEn": "new Zealand", "areaCode": "+64" },
|
||
{ "areaEn": "Hungary", "areaCode": "+36" },
|
||
{ "areaEn": "Syria", "areaCode": "+963" },
|
||
{ "areaEn": "Jamaica", "areaCode": "+1" },
|
||
{ "areaEn": "Armenia", "areaCode": "+374" },
|
||
{ "areaEn": "Jan Mayen Island", "areaCode": "+47" },
|
||
{ "areaEn": "Yemen", "areaCode": "+967" },
|
||
{ "areaEn": "Iraq", "areaCode": "+964" },
|
||
{ "areaEn": "Iran", "areaCode": "+98" },
|
||
{ "areaEn": "Israel", "areaCode": "+972" },
|
||
{ "areaEn": "Italy", "areaCode": "+39" },
|
||
{ "areaEn": "India", "areaCode": "+91" },
|
||
{ "areaEn": "Indonesia", "areaCode": "+62" },
|
||
{ "areaEn": "United Kingdom", "areaCode": "+44" },
|
||
{ "areaEn": "The British Virgin Islands", "areaCode": "+1" },
|
||
{ "areaEn": "British Indian Ocean Territory", "areaCode": "+44" },
|
||
{ "areaEn": "Jordan", "areaCode": "+962" },
|
||
{ "areaEn": "Vietnam", "areaCode": "+84" },
|
||
{ "areaEn": "Zambia", "areaCode": "+260" },
|
||
{ "areaEn": "Jersey", "areaCode": "+44" },
|
||
{ "areaEn": "Chad", "areaCode": "+235" },
|
||
{ "areaEn": "Gibraltar", "areaCode": "+350" },
|
||
{ "areaEn": "Chile", "areaCode": "+56" },
|
||
{ "areaEn": "Central African Republic", "areaCode": "+236" },
|
||
{ "areaEn": "China", "areaCode": "+86" }
|
||
]
|
||
|
||
var countryList = ["Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bonaire", "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo", "Cook Islands", "Costa Rica", "Croatia", "Curaçao", "Cyprus", "Czech Republic", "Côte d'Ivoire", "Denmark", "Djibouti", "Dominica", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guernsey", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iraq", "Ireland", "Isle of Man", "Israel", "Italy", "Jamaica", "Japan", "Jersey", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kosovo", "Kuwait", "Kyrgyzstan", "Lao People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macao", "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montenegro", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", "Norway", "Oman", "Pakistan", "Palau", "Palestine", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", "Romania", "Russian Federation", "Rwanda", "Réunion", "Saint Barthélemy", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia", "Saint Martin (French part)", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia", "Seychelles", "Sierra Leone", "Singapore", "Sint Maarten (Dutch part)", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", "South Sudan", "Spain", "Sri Lanka", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Dominican Republic", "Timor-Leste", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "United States Virgin Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands", "Wallis and Futuna", "Western Sahara", "Yemen", "Zambia", "Zimbabwe", "Åaland Islands"]
|
||
|
||
var $INQURY_BOX = $(".crm_inquiry_form_boxcustom_inquiry_form_1775784272599444");
|
||
var crmEmailStr = "Please enter a valid email address";
|
||
var pagetitle = '';
|
||
$('#pagetitle').val(document.title);
|
||
|
||
var crmValidStr = "This field is required";
|
||
var crmFailedStr = "Send failed";
|
||
var apiPath = $('#apiPath').attr('value');
|
||
var siteId = $('#siteId').attr('value');
|
||
var clientId = $('#clientId').attr('value');
|
||
|
||
// bootstrap-select 的默认 data-api 初始化绑定在 window.onload 上:
|
||
// 如果页面里有 iframe(比如 Google Maps)加载卡住,onload 不触发会导致 selectpicker 一直不初始化。
|
||
// 这里在 DOM ready 主动初始化一次,并在插件缺失时回退为原生 select(避免被 CSS 隐藏后无法选择)。
|
||
function initSelectpicker() {
|
||
var $selects = $INQURY_BOX.find('select.selectpicker');
|
||
if (!$selects.length) return;
|
||
|
||
// 插件未加载:移除 class,让原生 select 可见可用(降级)
|
||
if (!(window.jQuery && $.fn && typeof $.fn.selectpicker === 'function')) {
|
||
$selects.removeClass('selectpicker');
|
||
return;
|
||
}
|
||
|
||
// 已加载:只对未初始化的 select 执行一次初始化
|
||
$selects.each(function () {
|
||
var $el = $(this);
|
||
if (!$el.data('selectpicker')) {
|
||
$el.selectpicker($el.data() || {});
|
||
}
|
||
});
|
||
|
||
// 选项可能是 JS 动态 append 的,统一 refresh 一次
|
||
$selects.selectpicker('refresh');
|
||
}
|
||
|
||
$INQURY_BOX.find("[name='product_name']").each(function () {
|
||
var i = $(this);
|
||
var api = apiPath + `/shop-api/External/SearchProduct?clientId=${clientId}&siteId=${siteId}&linkUrl=${window.location.href}`;
|
||
|
||
$.get(api).done(function (response) {
|
||
if (response.code == 0) {
|
||
i.val(response.data.product_name)
|
||
}
|
||
}).fail(function (error) {
|
||
console.log(error);
|
||
});
|
||
})
|
||
|
||
// 单行文本
|
||
$INQURY_BOX.find('.textarea-input, .one-line-input, .phone_number').each(function () {
|
||
var input = $(this);
|
||
var charCount = input.parent().find('.char-count');
|
||
var maxLength = input.prop('maxlength');
|
||
charCount.text(`0/${maxLength}`);
|
||
input.on('input', function () {
|
||
var text = input.val();
|
||
charCount.text(text.length + '/' + maxLength);
|
||
|
||
if (input.attr('name') == 'mobile' && text.length < 5) {
|
||
input.addClass('error')
|
||
input.parent().find(".crmForm-error").remove();
|
||
input.after('<div class="crmForm-error">Minimum 5 characters, please re-enter</div>')
|
||
}
|
||
|
||
if (input.attr('name') == 'mobile' && text.length > 4) {
|
||
if (!$INQURY_BOX.find('#phoneCode').val() && $INQURY_BOX.find('#phoneCode').attr('required')) {
|
||
input.removeClass('error')
|
||
$INQURY_BOX.find('#phoneCode').addClass('error')
|
||
input.parent().find(".crmForm-error").remove();
|
||
input.after('<div class="crmForm-error">This field is required</div>')
|
||
} else {
|
||
input.removeClass('error')
|
||
input.parent().find(".crmForm-error").remove();
|
||
}
|
||
}
|
||
|
||
if (text.length > maxLength) {
|
||
input.val(text.substring(0, maxLength));
|
||
charCount.text(maxLength + '/' + maxLength);
|
||
}
|
||
|
||
})
|
||
});
|
||
|
||
// country下拉
|
||
var $countrySelect = $INQURY_BOX.find('.country-select>select')
|
||
$.each(countryList, function (index, item) {
|
||
let optionElement = $("<option>").attr("value", item).text(item);
|
||
$countrySelect.append(optionElement);
|
||
})
|
||
|
||
// phoneCode
|
||
var $codeSelect = $INQURY_BOX.find(".phone-wrap #phoneCode");
|
||
$.each(phoneCode, function (index, item) {
|
||
let optionElement = $("<option>").attr("value", item.areaCode).text(item.areaCode).attr("data-subtext", "(" + item.areaEn + ")");
|
||
$codeSelect.append(optionElement);
|
||
});
|
||
|
||
// 兜底:不依赖 window.onload,尽早初始化下拉(避免被 iframe 卡住)
|
||
initSelectpicker();
|
||
|
||
// checkbox
|
||
$INQURY_BOX.find('.checkbox-wrap-listen').off('click');
|
||
$INQURY_BOX.find('.checkbox-wrap-listen').on('click', function (event) {
|
||
event.stopPropagation();
|
||
var checkbox = $(this).find('input[type="checkbox"]');
|
||
checkbox.prop('checked', !checkbox.prop('checked'));
|
||
});
|
||
|
||
// 上传附件
|
||
$INQURY_BOX.find("#uploadContainer").on("click", function () {
|
||
$INQURY_BOX.find("#fileInput").click();
|
||
});
|
||
$INQURY_BOX.find("#fileInput").on("change", function () {
|
||
var maxFiles = $(this).attr('data-max');
|
||
var v = $INQURY_BOX.find('.attachment-value').val()
|
||
var uploadedFiles = v ? v.split(',').length : 0;
|
||
// 获取用户选择的文件
|
||
var files = this.files;
|
||
if (uploadedFiles + files.length > maxFiles) {
|
||
this.value = '';
|
||
alert(`Up to ${maxFiles} uploads`);
|
||
return;
|
||
}
|
||
|
||
var uploadUrl = apiPath + `/shop-api/External/UploadFile?clientId=${clientId}&siteId=${siteId}`;
|
||
|
||
for (let i = 0; i < files.length; i++) {
|
||
let formData = new FormData();
|
||
formData.append('file', files[i]);
|
||
formData.append('name', files[i].name);
|
||
let [name, type] = splitFileName(files[i].name)
|
||
|
||
if (files[i].size > 30 * 1024 * 1024) {
|
||
// 文件size大于30m,不上传,直接add item
|
||
var listItemError = $('<div class="attachment-file-item error">')
|
||
listItemError.append($('<i class="iconfont iconfont-File file-icon">'))
|
||
var te = $('<div class="attachment-file-name">')
|
||
te.append($("<div class='attachment-file-name-text'></div>").text(name + "."))
|
||
te.append($("<div class='attachment-file-name-type'></div>").text(type))
|
||
listItemError.append(te)
|
||
listItemError.append($('<i class="iconfont iconfont-shanchu del-icon">'))
|
||
listItemError.append($('<div class="file-error">').text("Maximum 30MB, please re-upload"))
|
||
$INQURY_BOX.find('.attachment-file').append(listItemError);
|
||
} else {
|
||
$.ajax({
|
||
url: uploadUrl,
|
||
type: 'POST',
|
||
data: formData,
|
||
processData: false,
|
||
contentType: false,
|
||
success: function (result) {
|
||
console.log('result', result);
|
||
let r = result.code
|
||
let u = result.data?.url
|
||
var listItem = $(`<div class="attachment-file-item ${r === -1 ? "error" : ""}">`);
|
||
if (type == "jpg" || type == "png" || type == "jpeg") {
|
||
listItem.append($('<img>').attr('src', u))
|
||
} else {
|
||
listItem.append($('<i class="iconfont iconfont-File file-icon">'))
|
||
}
|
||
var te = $('<div class="attachment-file-name">')
|
||
te.append($("<div class='attachment-file-name-text'></div>").text(name + "."))
|
||
te.append($("<div class='attachment-file-name-type'></div>").text(type))
|
||
listItem.append(te)
|
||
listItem.append($('<i class="iconfont iconfont-shanchu del-icon">'))
|
||
$INQURY_BOX.find('.attachment-file').append(listItem);
|
||
|
||
if (r === 0) {
|
||
var o = $INQURY_BOX.find(".attachment-value").val()
|
||
$INQURY_BOX.find(".attachment-value").val(o ? o + ',' + u : u);
|
||
$INQURY_BOX.find(".attachment>.crmForm-error").remove();
|
||
$INQURY_BOX.find(".attachment>input.error").removeClass('error')
|
||
} else {
|
||
// 第一次上传文件失败,需要清空值
|
||
if (!uploadedFiles) {
|
||
$INQURY_BOX.find("#fileInput").val('');
|
||
}
|
||
listItem.append($('<div class="file-error">').text(result.msg))
|
||
}
|
||
},
|
||
error: function (xhr, status, error) {
|
||
console.error('上传文件时出错:', error);
|
||
}
|
||
});
|
||
}
|
||
}
|
||
});
|
||
|
||
// 删除附件
|
||
$INQURY_BOX.find(".attachment-file").on("click", ".del-icon", function () {
|
||
var d = $(this).closest(".attachment-file-item");
|
||
var i = d.index(); d.remove();
|
||
var $attachmentValue = $INQURY_BOX.find(".attachment-value");
|
||
var values = $attachmentValue.val().split(",");
|
||
values.splice(i, 1);
|
||
$attachmentValue.val(values.join(","));
|
||
|
||
if (!$attachmentValue.val()) {
|
||
$INQURY_BOX.find("#fileInput").val('');
|
||
}
|
||
});
|
||
|
||
$INQURY_BOX.find(':input[required]').bind("keyup blur", function () {
|
||
var element = $(this);
|
||
var value = element.val();
|
||
|
||
if (Array.isArray(value)) {
|
||
value = value.join('');
|
||
}
|
||
// 如果输入的全是空格
|
||
if (value && value.trim() === '') {
|
||
element.addClass('error');
|
||
// 移除旧的错误提示
|
||
element.parent().find('.crmForm-error').remove();
|
||
// 添加新的错误提示
|
||
element.after('<div class="crmForm-error">Cannot contain only spaces</div>');
|
||
return;
|
||
}
|
||
|
||
// 如果开头结尾是空格
|
||
if (value && value.startsWith(' ')) {
|
||
element.val(value.trim());
|
||
}
|
||
|
||
// 如果有值且不是纯空格,移除错误状态
|
||
if (value && value.trim() && element.attr("name") !== "mobile") {
|
||
element.removeClass('error');
|
||
element.parent().find('.crmForm-error').remove();
|
||
}
|
||
|
||
// 如果是email,验证邮箱格式
|
||
if (element.attr("name") == "email") {
|
||
_crmEmailVali($(this), crmEmailStr);
|
||
} else {
|
||
_crmEmailVali($(this), crmValidStr);
|
||
}
|
||
|
||
});
|
||
|
||
$INQURY_BOX.find('input[type="checkbox"] , input[type="radio"]').change(function () {
|
||
var element = $(this);
|
||
if (element.is(':checked')) {
|
||
element.parent().parent().find(".crmForm-error").remove();
|
||
}
|
||
});
|
||
|
||
$INQURY_BOX.find('.selectpicker').on('change.bs.select', function (e) {
|
||
if ($(this).val()) {
|
||
$(this).removeClass('error');
|
||
$(this).parent().find(".crmForm-error").remove();
|
||
}
|
||
|
||
if ($(this).attr('name') == 'code' && $(this).val() && $INQURY_BOX.find(".phone-wrap input").val().length > 4) {
|
||
// 判断字符
|
||
$INQURY_BOX.find(".phone-wrap .crmForm-error").remove()
|
||
}
|
||
});
|
||
|
||
// 提交的校验
|
||
$INQURY_BOX.find("form").submit(function () {
|
||
var form = $(this);
|
||
|
||
if (checkBeforeSubmit(form)) {
|
||
// 验证成功,继续处理表单提交逻辑
|
||
form.find(".create-form-submit").attr("disabled", "disabled").append('<span class="crm-submit-load"></span>');
|
||
var url = apiPath + "/managedata/aifeedback/add.php?";
|
||
var parsedDict = parseQueryString(form.serialize());
|
||
var outputString = generateQueryString(parsedDict);
|
||
var dataObject = Object.fromEntries(new URLSearchParams(outputString));
|
||
dataObject.pagetitle = document.title;
|
||
dataObject.page_link = window.location.href;
|
||
var parseCookie = (value) =>
|
||
value
|
||
.split(';')
|
||
.map(v => v.split('='))
|
||
.reduce((acc, v) => {
|
||
acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1]?.trim());
|
||
return acc;
|
||
}, {});
|
||
dataObject.gclid = parseCookie(document.cookie).gclid || "";
|
||
dataObject.site_session_id = window.matomo_site_id_cookie_key || "";
|
||
var modifiedData = new URLSearchParams(dataObject).toString();
|
||
$.post(url + $.param({ siteId: siteId, clientId: clientId }), modifiedData, function (result) {
|
||
handleSubmitResult(form, result);
|
||
console.log('result', result)
|
||
}, 'json');
|
||
}
|
||
return false;
|
||
});
|
||
|
||
function checkBeforeSubmit(form) {
|
||
// 如果tel长度小于5 直接返回false
|
||
var isTelValid = form.find("input[name='mobile']").val() && form.find("input[name='mobile']").val().length < 5;
|
||
if (isTelValid) {
|
||
return false
|
||
}
|
||
|
||
var isValid = form[0].checkValidity();
|
||
$(form[0].querySelectorAll('.crmForm-error')).remove();
|
||
|
||
if (!isValid) {
|
||
// 验证失败,加error样式和统一错误文案
|
||
var invalidElements = $(form[0].querySelectorAll(':invalid'));
|
||
var radioName = []
|
||
|
||
invalidElements.each(function () {
|
||
var element = $(this);
|
||
element.removeClass('error')
|
||
|
||
// raido
|
||
if (element.is(':radio')) {
|
||
var groupName = element.attr('name');
|
||
if (!radioName.includes(groupName) && $INQURY_BOX.find(':input[name="' + groupName + '"]:checked').length === 0) {
|
||
!radioName.includes(groupName) && radioName.push(groupName)
|
||
element.addClass('error');
|
||
element.parent().last().after('<div class="crmForm-error">This is a required field</div>')
|
||
}
|
||
}
|
||
|
||
if (element.val() == '' || element.val() == null || element.val() == []) {
|
||
element.addClass('error')
|
||
element.after('<div class="crmForm-error">This is a required field</div>')
|
||
}
|
||
});
|
||
}
|
||
|
||
// 检查所有必填输入框
|
||
form.find(':input[required]').each(function () {
|
||
var $input = $(this);
|
||
var value = $input.val();
|
||
|
||
// Check if value is an array and concatenate if necessary
|
||
if (Array.isArray(value)) {
|
||
value = value.join('').trim();
|
||
} else {
|
||
value = value.trim();
|
||
}
|
||
|
||
// 如果全是空格
|
||
if (!value) {
|
||
isValid = false;
|
||
$input.addClass('error');
|
||
// 移除旧的错误提示
|
||
$input.parent().find('.crmForm-error').remove();
|
||
// 添加新的错误提示
|
||
$input.after('<div class="crmForm-error">This is a required field</div>');
|
||
return false;
|
||
}
|
||
});
|
||
|
||
var isCheckboxValid = true;
|
||
var checkboxName = []
|
||
$INQURY_BOX.find(':checkbox').each(function () {
|
||
var element = $(this);
|
||
var groupName = element.attr('name');
|
||
var isrequired = element.parent().attr('data-required')
|
||
|
||
// 检查复选框组是否已经在 checkboxName 数组中,如果不在且未选中任何复选框,则将其添加到数组中
|
||
if (isrequired && !checkboxName.includes(groupName) && $INQURY_BOX.find(':input[name="' + groupName + '"]:checked').length === 0) {
|
||
isCheckboxValid = false;
|
||
checkboxName.push(groupName);
|
||
element.addClass('error');
|
||
element.parent().last().after('<div class="crmForm-error">This is a required field</div>');
|
||
}
|
||
});
|
||
|
||
var isEmialValid = true;
|
||
form.find("input[name='email']").each(function () {
|
||
if (!_crmEmailVali($(this), "Please enter a valid email address")) { isEmialValid = false; }
|
||
});
|
||
return isValid && isCheckboxValid && isEmialValid;
|
||
}
|
||
|
||
function _crmEmailVali(item, text) {
|
||
item.removeClass('error');
|
||
item.parent().find(".crmForm-error").remove();
|
||
var value = $.trim(item.val());
|
||
var re = /[A-Za-z0-9.\-+_]+@[a-z0-9.\-+_]+\.[a-z]{2,3}/;
|
||
if (item.attr("name") == "email") {
|
||
if (item.attr('required') && value == '') { item.after('<div class="crmForm-error">' + text + '</div>'); item.addClass('error'); return false; }
|
||
if (value && !re.test(value)) { text = 'Your email is invalid'; item.after('<div class="crmForm-error">' + text + '</div>'); item.addClass('error'); return false; }
|
||
return true;
|
||
} else if (!value) {
|
||
item.after('<div class="crmForm-error">' + text + '</div>'); return false;
|
||
} else {
|
||
return true;
|
||
}
|
||
}
|
||
|
||
function _crmAlertText(type, text) {
|
||
$("body").addClass("crm-body-clear");
|
||
var succ = '<div id="crmMailMask"><div class="crmMailMask-box"><div class="crmMailMask-boxTop">' + text + '</div><div class="crmMailMask-boxBot"><button type="button" class="crmMailMask-close"> OK </button></div></div></div>';
|
||
if (type == 1) {
|
||
$("body").find("#crmMailMask").remove();
|
||
$("body").append(succ);
|
||
}
|
||
$(".crmMailMask-close").click(function () {
|
||
$("#crmMailMask").remove();
|
||
$("body").removeClass("crm-body-clear");
|
||
});
|
||
}
|
||
|
||
function handleSubmitResult(form, result) {
|
||
try {
|
||
form.find(".create-form-submit").removeAttr("disabled").find(".crm-submit-load").remove();
|
||
if (result.code == '0') {
|
||
form[0].reset();
|
||
resetOtherData();
|
||
$('.click-popup').removeClass('is-visible');
|
||
|
||
$INQURY_BOX.find('.char-count').each(function (_index, element) {
|
||
var $element = $(element);
|
||
var t = $element.text();
|
||
var parts = t.split('/');
|
||
if (!parts[0]) {
|
||
parts[0] = '0';
|
||
$element.text(parts.join('/'));
|
||
}
|
||
});
|
||
|
||
if (typeof gtag_report_conversion === "function") {
|
||
gtag_report_conversion();
|
||
} else {
|
||
console.log('不存在谷歌表单函数');
|
||
}
|
||
var lang = '';
|
||
var currentLang = $(':visible').filter('.current-lang em');
|
||
if (currentLang.length > 0) {
|
||
lang = currentLang.eq(0).text().trim().toLowerCase();
|
||
} else {
|
||
lang = $('html').attr('lang');
|
||
}
|
||
|
||
if ($INQURY_BOX.data('attr-download-pop')) {
|
||
// dispatch custom event to notify the parent to handle the success callback
|
||
const event = new CustomEvent('inquirySuccessCallback', { detail: { formInquiry: $INQURY_BOX } });
|
||
document.dispatchEvent(event);
|
||
|
||
$('.click-popup-download').removeClass('is-visible');
|
||
if (localStorage.getItem('download_src')) {
|
||
window.open(localStorage.getItem('download_src'), '_blank');
|
||
} else {
|
||
console.log('download_src is not set');
|
||
}
|
||
} else {
|
||
window.location.href = lang ? `/${lang}/inquiry_success`: '/inquiry_success';
|
||
}
|
||
} else {
|
||
_crmAlertText(1, crmFailedStr);
|
||
}
|
||
} catch (error) {
|
||
_crmAlertText(1, error.message || crmFailedStr);
|
||
}
|
||
}
|
||
|
||
|
||
function parseQueryString(queryString) {
|
||
var parsedDict = {};
|
||
var pairs = queryString.split('&');
|
||
for (pair of pairs) {
|
||
var [key, value] = pair.split('=');
|
||
var decodedKey = decodeURIComponent(key);
|
||
var decodedValue = decodeURIComponent(value);
|
||
if (decodedKey in parsedDict) {
|
||
if (Array.isArray(parsedDict[decodedKey])) {
|
||
parsedDict[decodedKey].push(decodedValue);
|
||
} else {
|
||
parsedDict[decodedKey] = [parsedDict[decodedKey], decodedValue];
|
||
}
|
||
} else {
|
||
parsedDict[decodedKey] = decodedValue;
|
||
}
|
||
}
|
||
|
||
// code和phone合并
|
||
if (parsedDict.code || parsedDict.mobile) {
|
||
parsedDict.mobile = "" + parsedDict.code + parsedDict.mobile
|
||
delete parsedDict.code;
|
||
}
|
||
|
||
return parsedDict;
|
||
}
|
||
|
||
function generateQueryString(parsedDict) {
|
||
var pairs = [];
|
||
for (const [key, value] of Object.entries(parsedDict)) {
|
||
pairs.push(`${encodeURIComponent(key)}=${encodeURIComponent(value)}`);
|
||
}
|
||
return pairs.join('&');
|
||
}
|
||
|
||
function splitFileName(string) {
|
||
const parts = string.split('.'); // 将字符串按句点分割成数组
|
||
const type = parts.pop(); // 弹出数组的最后一个元素
|
||
const name = parts.join('.'); // 将剩余的部分重新组合成字符串
|
||
return [name, type];
|
||
}
|
||
|
||
function resetOtherData() {
|
||
// 插件缺失时无需 refresh(并且调用会报错)
|
||
if (!(window.jQuery && $.fn && typeof $.fn.selectpicker === 'function')) {
|
||
// 删除附件的item
|
||
$INQURY_BOX.find(".attachment-file").empty();
|
||
$(".click-popup").removeClass("is-visible");
|
||
return;
|
||
}
|
||
|
||
// 获取选择框元素
|
||
var selectElement = $INQURY_BOX.find('.mul-select-wrap .selectpicker');
|
||
selectElement.each(function () {
|
||
var sl = $(this);
|
||
sl.val(''); sl.selectpicker('refresh');
|
||
})
|
||
// 删除code
|
||
var phonecode = $INQURY_BOX.find(".phone-wrap .selectpicker");
|
||
phonecode.each(function () {
|
||
var c = $(this);
|
||
c.val(''); c.selectpicker('refresh');
|
||
})
|
||
// 删除附件的item
|
||
$INQURY_BOX.find(".attachment-file").empty();
|
||
$(".click-popup").removeClass("is-visible");
|
||
}
|
||
});
|
||
$(document).ready(function() {
|
||
var swiper = new Swiper('.yuedong_hot_case_list', {
|
||
loop: true,
|
||
speed: 1000,
|
||
autoplay: {
|
||
delay: 5000,
|
||
disableOnInteraction: false,
|
||
},
|
||
slidesPerView: 1,
|
||
spaceBetween: 10,
|
||
navigation: {
|
||
nextEl: '.yuedong_hot_case .swiper-button-next',
|
||
prevEl: '.yuedong_hot_case .swiper-button-prev',
|
||
},
|
||
});
|
||
});;
|
||
$(function() {
|
||
new Swiper('.yuedong_hot_sports_list', {
|
||
slidesPerView: 1,
|
||
spaceBetween: 30,
|
||
loop: true,
|
||
autoplay: {
|
||
delay: 5000,
|
||
disableOnInteraction: false,
|
||
},
|
||
pagination: {
|
||
el: '.yuedong_hot_sports .swiper-pagination',
|
||
clickable: true,
|
||
},
|
||
});
|
||
}); |