var login_url = '/accounts/signin'; var forgot_url = '/accounts/forgot'; var emailPlaceholder = 'E-poçtunuzu daxil edin'; var passwordPlaceholder = 'Şifrənizi daxil edin'; var forgotTxt = 'Şifrəni unutmusuz?'; var backForgot = 'Xatırladım'; var signinTxt = 'daxil olun'; var sendForgot = 'Şifrəni sıfırla'; singin_form = new Vue({ delimiters: ['[[', ']]'], el: '#singin_form', data: { email: '', emailPlaceholder: emailPlaceholder, emailError: false, password: '', passwordPlaceholder: passwordPlaceholder, passwordError: false, remember_me: true, forgot_password: false, forgotTxt: forgotTxt, signinTxt: signinTxt, redirect: true, fetching: false }, methods:{ forgot_password_func: function(){ if(this.forgot_password){ this.forgot_password = false; this.forgotTxt = forgotTxt; this.signinTxt = signinTxt; this.emailPlaceholder = emailPlaceholder; this.emailError = false; this.email = ''; }else{ this.forgot_password = true; this.forgotTxt = backForgot; this.signinTxt = sendForgot; this.emailPlaceholder = emailPlaceholder; this.emailError = false; this.email = ''; this.passwordPlaceholder = passwordPlaceholder; this.passwordError = false; this.password = ''; } }, send: function(){ var that = this; console.log(this.fetching) if(this.fetching) return; this.fetching = true; console.log("PASSWORDDDDDD") console.log(that.forgot_password) $.ajax({ url: that.forgot_password ? forgot_url : login_url, type: 'post', cache: false, async: false, dataType: 'json', data: { email: this.email, password: this.password, redirect: that.redirect }, success: function (data, textStatus) { that.fetching = false; if(data.error){ that.emailError = false; that.passwordError = false; if(data.error.email){ that.emailError = true; that.email = ''; that.emailPlaceholder = data.error.email; } if(data.error.passwd){ that.password = ''; that.passwordPlaceholder = data.error.passwd; that.passwordError = true; } } if(data.redirect){ that.emailError = false; that.passwordError = false; window.location.href = data.redirect; } } }); } } }); singup_form = new Vue({ delimiters: ['[[', ']]'], el: '#singup_form', data: { name: '', namePlaceholder: 'Tam adınız', nameError: false, email: '', emailPlaceholder: 'E-poçt', emailError: false, password: '', passwordPlaceholder: 'Şifrə', passwordError: false, redirect: true, }, methods:{ send: function(){ if(this.name == ''){ this.nameError = true; return ; }else{ this.nameError = false; } var that = this; $.ajax({ url: '/accounts/signup', type: 'post', cache: false, async: false, dataType: 'json', data: { full_name: this.name, email: this.email, password1: this.password, redirect: that.redirect }, success: function (data, textStatus) { if(data.error){ if(that.emailError){ that.emailPlaceholder = '' that.emailError = false; } if(that.passwordError){ that.passwordPlaceholder = ''; that.passwordError = false; } if(data.error.email){ that.email = ''; that.emailPlaceholder = data.error.email that.emailError = true; } if(data.error.passwd){ that.password = ''; that.passwordPlaceholder = data.error.passwd that.passwordError = true; } } if(data.redirect){ that.emailError = false; that.passwordError = false; window.location.href = data.redirect; openBasket(); } } }); } } });