// CHECK FORM RESIGTER function check_field_registor() { var error = ""; var email = document.getElementById("email").value; if (ValidateEmail(email)) error += ValidateEmail(email); var password = document.getElementById("password").value; if (password.length < 6) error += "- Mật khẩu quá yếu\n"; var full_name = document.getElementById("full_name").value; if (full_name.length < 2) error += "- Mời bạn nhập đúng tên\n"; var mobile = document.getElementById("tel").value; if (mobile.length < 9) error += "- Mời bạn nhập đúng số điện thoại\n"; var address = document.getElementById("address").value; if (address.length < 6) error += "- Mời bạn nhập địa chỉ\n"; var pass = $("#password").val(); var pass1 = $("#password1").val(); if (pass1 != pass) { error += "- Mật khẩu không trùng khớp. Xin vui lòng nhập lại!"; } if (error != "") { alert(error); return false; } else { var registerParams = { action_type: "register", info: { email: email, name: full_name, tel: mobile, mobile: mobile, birthday: "", password: password, address: address, }, }; Hura.Ajax.post("customer", registerParams).then(function (data) { //console.log(data); if (data.status == "error" && data.message == "Email exist") { alert("Email đã được đăng ký \n Vui lòng nhập lại! "); } else { alert("Bạn đã đăng ký thành công! Chuyển tiếp sang Đăng nhập."); location.href = "/dang-nhap"; } }); } } // CHECK FORM LOGIN function check_login() { var error = ""; var email = document.getElementById("email").value; if (ValidateEmail(email)) error += ValidateEmail(email); var password = document.getElementById("password").value; if (password.length == 0) error += "- Bạn cần nhập mật khẩu để đăng nhập \n"; if (error != "") { alert(error); return false; } else { Hura.User.login(email, password).then(function (data) { //console.log(data); if (data.status == "error") { alert(data.message); } else { alert("Đăng nhập thành công!"); location.href = "/taikhoan"; } }); } } // CHECK VALIDATION EMAIL function ValidateEmail(emailValue) { var mailformat = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/; if (emailValue.length < 6) return "- Mời bạn nhập email!\n"; else if (!emailValue.match(mailformat)) return "- Email không chính xác, vui lòng nhập lại\n"; } // TOGGLE SHOW PASSWORD function show_hide_pass(password) { var x = $(password).parents(".item").find(".input-pass").attr("type"); if (x === "password") { $(password).parents(".item").find(".input-pass").attr("type", "text"); } else { $(password).parents(".item").find(".input-pass").attr("type", "password"); } } // FORGOT PASSWORD function forgotPassword() { var email = document.getElementById("email_register").value; Hura.Ajax.customPost("/ajax/reset_password_request.php", { email: email, }).then(function (data) { //console.log(data); $("#js-mess").html(data.message); }); } var customerOrderTpl = ` #{%= item.orderId %} {%= item.orderDate %} (Xem chi tiết) {% for (let itemProduct of item.item_list) { %} - {%= itemProduct.item_info.productName %} {% } %} {%= parseInt(item.totalValue).toLocaleString() %} đ {% if (item.status_id === "0") { %}

Đang xử lý

{% } %} `; {% endraw %} // RENDER CUSTOMER ORDER LIST function getOrderList() { Hura.Ajax.post("account", { action_type: "recent-order" }).then(function ( order_list ) { //console.log(order_list); if (order_list.length > 0) { var html = Hura.Template.parse(customerOrderTpl, order_list); Hura.Template.render("#js-customer-order", html); } else { $(".order-page").html(`

Bạn chưa có đơn hàng nào!

`); } }); }