${(function(){
return `
(function(){
var eventData={};
var phoneAreaCode = "+44";
var user_phone = "1234567890";
var phone_max_length = "14";
function success(eData){
eventData=eData;
const email = eventData.customer.email;
document.getElementById("current_email").innerHTML = email;
localStorage.setItem('current-email',email);
localStorage.setItem('hasLogin',true);
return eventData;
}
function handleRegisterError(eData){
if(eData.errors[0].indexOf("Email has already been taken") > -1){
return Promise.resolve({});
}else{
return Promise.reject({});
}
}
document.getElementById("global-login-popup") && document.getElementById("global-login-popup").addEventListener("click", function(e){
if(e.target?.id != "email_suffix_ul"){
document.getElementById("email_suffix_render").classList.add('hidden');
}
});
function registerInitRemenberMe(){
localStorage.setItem('isRememberme', false);
}
function eyesDisplayClick(){
document.getElementById("popup_password").setAttribute('type', 'password');
}
function eyesHideClick(){
document.getElementById("popup_password").setAttribute('type', 'text');
}
function selectRememberMe(eData){
if(eData.checked){
localStorage.setItem('isRememberme', true);
}else{
localStorage.setItem('isRememberme',false);
}
}
function initEmailInput(){
localStorage.setItem('hasLogin',false);
console.log("hasLogininput",localStorage.getItem('hasLogin'));
var isRememberme = localStorage.getItem('isRememberme');
if(isRememberme == 'true'){
document.getElementById("register_email").value = localStorage.getItem('current-email');
}
}
function setLoginEmail(){
const email = document.getElementById("register_email").value;
return Promise.resolve({email});
}
function changeEmailBySuffix(eData){
document.getElementById("register_email").value = eData + ".com";
let email = document.getElementById("register_email");
if (/[a-zA-Z0-9$+=_\`\-]+(?:\.[a-zA-Z0-9$+=_\`\-]+)*@(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?/.test(email.value)) {
email.classList.remove('user-invalid');
document.getElementById("email_patternMismatch").classList.remove('visible');
}
}
function hiddenEmailSuffix(eData){
var email_prefix = eData.value.split("@")[0] || "";
var email_prefix_gmail = email_prefix+"@gmail";
var email_prefix_yahoo = email_prefix+"@yahoo";
var email_prefix_hotmail = email_prefix+"@hotmail";
var email_prefix_aol = email_prefix+"@aol";
var email_prefix_icloud = email_prefix+"@icloud";
var email_prefix_outlook = email_prefix+"@outlook";
var email_prefix_msn = email_prefix+"@msn";
var email_prefix_comcast = email_prefix+"@comcast";
var email_prefix_live = email_prefix+"@live";
var email_arr = [email_prefix_gmail,email_prefix_yahoo,email_prefix_hotmail,email_prefix_aol,email_prefix_icloud,email_prefix_outlook,email_prefix_msn,email_prefix_comcast,email_prefix_live];
var hasEmail = email_arr.filter((email)=>{
return email.indexOf(eData.value) > -1;
})
if(hasEmail.length == 0){
document.getElementById("email_suffix_render").classList.add('hidden');
}
}
function setRegisterEmail(eData){
document.getElementById("register_email").value = eData.value;
}
function initRememberMeStatus(){
localStorage.setItem('isRememberme', true);
}
function addphone(eData){
user_phone = parseInt(eData.value);
document.getElementById("register_phone_popup").value = user_phone;
document.getElementById("register_real_phone").value = phoneAreaCode + " "+ user_phone;
}
exportFunction('success',success);
exportFunction('registerInitRemenberMe',registerInitRemenberMe);
exportFunction('registerUserExist',handleRegisterError);
exportFunction('addphone',addphone);
exportFunction('eyesDisplayClick',eyesDisplayClick);
exportFunction('eyesHideClick',eyesHideClick);
exportFunction('selectRememberMe',selectRememberMe);
exportFunction('initEmailInput',initEmailInput);
exportFunction('setLoginEmail',setLoginEmail);
exportFunction('changeEmailBySuffix',changeEmailBySuffix);
exportFunction('hiddenEmailSuffix',hiddenEmailSuffix);
exportFunction('setRegisterEmail',setRegisterEmail);
exportFunction('initRememberMeStatus',initRememberMeStatus);
})()
(function(){
function initRememberMeMarkAndGetCoupons(data){
if (localStorage.getItem('isRememberme') == null){
localStorage.setItem('isRememberme', true);
}
//登录成功后,弹优惠券的列表窗
localStorage.setItem('isLoginShowCouponListPopup', true);
//先判断有没有可用券,没有可用券再领取再次补充优惠券
var customer_id = data.customer.id;
return Promise.all([fetch('/api/discount-coupon/coupons/received?available=true&limit=9&login-user-id='+customer_id+'&store-id=818679&cursor=')]).then((res) => {
return Promise.all([res[0].json()])
}).then((resData) => {
if(resData[0].data.length == 0){
//领取再次补充优惠券
var ids = document.getElementById("set-second-coupon-ids").textContent;
ids = JSON.parse(ids);
fetch('/api/discount-coupon/receive/coupons',{
headers: {
'Content-Type': 'application/json'
},
method: 'POST',
credentials: 'same-origin',
body: JSON.stringify(ids)
}).then((res) => {
return res.json();
}).then((resData) => {
if(resData.items.length > 0){
console.log("领取再次补充优惠券成功");
}
});
}
});
}
function fnGetFirstOrderCustomerCoupon(){
var coupon_ids_js = document.getElementById("coupon-id-lists").textContent;
coupon_ids_js = JSON.parse(coupon_ids_js);
return Promise.all([fetch('/api/discount-coupon/coupons?ids[]='+coupon_ids_js.ids)]).then((res) => {
return Promise.all([res[0].json()])
}).then((resData) => {
var only_valid_first_order_customer_coupon = resData[0].data.find((coupon)=>{
return coupon.only_valid_first_order_customer;
})
return only_valid_first_order_customer_coupon;
});
}
exportFunction('initRememberMeMarkAndGetCoupons',initRememberMeMarkAndGetCoupons);
exportFunction('fnGetFirstOrderCustomerCoupon',fnGetFirstOrderCustomerCoupon);
})()
`
})()}