444 lines
17 KiB
JavaScript
444 lines
17 KiB
JavaScript
"use strict";
|
||
//
|
||
const List_product = [
|
||
{
|
||
productId: 22,
|
||
product_name: 'Combo Bàn phím và Chuột không dây MOFII CANDY Milk Tea',
|
||
productUrl: '/',
|
||
image: 'https://mygear.vn/media/product/589-1.jpg',
|
||
price: 1250000,
|
||
retail_price: 500000,
|
||
quantity: 20,
|
||
sale_quantity: 10,
|
||
quantity_member: 5,
|
||
from_time: 1703213170286,
|
||
to_time: 1703955500000,
|
||
status: 'started',
|
||
category_info: [
|
||
{
|
||
id: 1,
|
||
name_category: 'Chuột'
|
||
},
|
||
{
|
||
id: 2,
|
||
name_category: 'Bàn phím'
|
||
},
|
||
],
|
||
list_group: [
|
||
{
|
||
group_id: 1,
|
||
name_group: 'Hura săn sale',
|
||
product_id: 1,
|
||
productUrl: '/',
|
||
product_image: 'https://mygear.vn/media/product/589-1.jpg',
|
||
product_name: 'Combo Bàn phím và Chuột không dây MOFII CANDY Milk Tea',
|
||
price: 3190000,
|
||
quantity: 20,
|
||
sale_quantity: 10,
|
||
quantity_member: 5,
|
||
retail_price: 2190000,
|
||
to_time: 1703955600000,
|
||
list_member: [
|
||
{
|
||
id_member: 1,
|
||
name_member: 'Hồng Vũ',
|
||
email_member: 'hongvt@hurasoft.com'
|
||
}, {
|
||
id_member: 2,
|
||
name_member: 'Ánh trần',
|
||
email_member: 'anhtt@hurasoft.com'
|
||
}, {
|
||
id_member: 3,
|
||
name_member: 'Đức Quân',
|
||
email_member: 'ducnq@hurasoft.com'
|
||
},
|
||
]
|
||
}
|
||
]
|
||
}, {
|
||
productId: 2,
|
||
product_name: 'Chuột không dây logitech M590 Wireless Bluetooth',
|
||
productUrl: '/',
|
||
image: 'https://mygear.vn/media/product/1634-chu---t-kh--ng-d--y-logitech-m590-wireless-bluetooth.jpg',
|
||
price: 570000,
|
||
retail_price: 300000,
|
||
quantity: 30,
|
||
sale_quantity: 10,
|
||
quantity_member: 5,
|
||
from_time: 1703213170286,
|
||
to_time: 1703955600000,
|
||
status: 'started',
|
||
category_info: [
|
||
{
|
||
id: 1,
|
||
name_category: 'Chuột'
|
||
},
|
||
{
|
||
id: 2,
|
||
name_category: 'Bàn phím'
|
||
},
|
||
],
|
||
list_group: []
|
||
}, {
|
||
productId: 3,
|
||
product_name: 'Bàn phím cơ VGN VXE75 Trans Purple RGB (Bluetooth, 2.4GHz Wireless, Type-A)',
|
||
productUrl: '/',
|
||
image: 'https://mygear.vn/media/product/4793-vgn-vxe75-trans-purple.jpg',
|
||
price: 3190000,
|
||
retail_price: 2190000,
|
||
quantity: 30,
|
||
sale_quantity: 10,
|
||
quantity_member: 5,
|
||
from_time: 1703782800000,
|
||
to_time: 1703955600000,
|
||
status: 'coming',
|
||
category_info: [
|
||
{
|
||
id: 2,
|
||
name_category: 'Bàn phím'
|
||
},
|
||
],
|
||
list_group: []
|
||
}, {
|
||
productId: 4,
|
||
product_name: 'Màn hình Gaming Samsung Odyssey G5 LS27CG510EEXXV 27" QHD VA 165Hz (HDMI,Displayport)',
|
||
productUrl: '/',
|
||
image: 'https://mygear.vn/media/product/3761-samsung-odyssey-g5-ls27cg510eexxv.jpg',
|
||
price: 4700000,
|
||
retail_price: 4500000,
|
||
quantity: 30,
|
||
sale_quantity: 30,
|
||
quantity_member: 5,
|
||
from_time: 1703213170286,
|
||
to_time: 1703955600000,
|
||
status: 'out_stock',
|
||
category_info: [
|
||
{
|
||
id: 5,
|
||
name_category: 'Màn hình'
|
||
},
|
||
],
|
||
list_group: []
|
||
}, {
|
||
productId: 5,
|
||
product_name: 'Kit bàn phím cơ MonsGeek M1 QMK (Full Nhôm – Mạch xuôi – QMK / VIA – PCB Stab) - (Silver)',
|
||
productUrl: '/',
|
||
image: 'https://mygear.vn/media/product/3613-monsgeek-m1-qmk-6.jpg',
|
||
price: 2290000,
|
||
retail_price: 2000000,
|
||
quantity: 20,
|
||
sale_quantity: 20,
|
||
quantity_member: 5,
|
||
from_time: 1703213170286,
|
||
to_time: 1703955600000,
|
||
status: 'out_stock',
|
||
category_info: [
|
||
{
|
||
id: 2,
|
||
name_category: 'Bàn phím'
|
||
},
|
||
],
|
||
list_group: [],
|
||
}
|
||
];
|
||
const User = [
|
||
{
|
||
leaderId: 1,
|
||
leaderName: 'Hiếu Nguyễn',
|
||
leaderEmail: 'hieunguyen@hurasoft.com',
|
||
list_group: [
|
||
{
|
||
group_id: 1,
|
||
name_group: 'Hura săn sale',
|
||
product_id: 33,
|
||
productUrl: '/',
|
||
product_image: 'https://mygear.vn/media/product/589-1.jpg',
|
||
product_name: 'Combo Bàn phím và Chuột không dây MOFII CANDY Milk Tea',
|
||
price: 3190000,
|
||
retail_price: 2190000,
|
||
quantity: 20,
|
||
sale_quantity: 10,
|
||
quantity_member: 5,
|
||
to_time: 1703955500000,
|
||
list_member: [
|
||
{
|
||
id_member: 1,
|
||
name_member: 'Hồng Vũ',
|
||
email_member: 'hongvt@hurasoft.com'
|
||
}, {
|
||
id_member: 2,
|
||
name_member: 'Ánh trần',
|
||
email_member: 'anhtt@hurasoft.com'
|
||
}, {
|
||
id_member: 3,
|
||
name_member: 'Đức Quân',
|
||
email_member: 'ducnq@hurasoft.com'
|
||
}
|
||
]
|
||
}
|
||
]
|
||
}
|
||
];
|
||
function formatPrice(price) {
|
||
var b = price.toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, "$1.").toString();
|
||
var len = b.length;
|
||
b = b.substring(0, len - 3);
|
||
return b;
|
||
}
|
||
function countDown(iid, endTime) {
|
||
const updateCountdown = () => {
|
||
const now = Date.now();
|
||
const distance = endTime - now;
|
||
if (distance > 0) {
|
||
const [days, hours, minutes, seconds] = getTimeComponents(distance);
|
||
displayCountdown(iid, days, hours, minutes, seconds);
|
||
}
|
||
else {
|
||
clearInterval(timer);
|
||
}
|
||
};
|
||
// Initial update to avoid delay
|
||
updateCountdown();
|
||
const timer = setInterval(updateCountdown, 1000);
|
||
}
|
||
function getTimeComponents(distance) {
|
||
const days = Math.floor(distance / (1000 * 60 * 60 * 24));
|
||
const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
|
||
const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
|
||
const seconds = Math.floor((distance % (1000 * 60)) / 1000);
|
||
return [days, hours, minutes, seconds];
|
||
}
|
||
function displayCountdown(iid, days, hours, minutes, seconds) {
|
||
const element = document.querySelector(`.${iid}`);
|
||
if (element) {
|
||
if (days > 0) {
|
||
element.innerHTML = `
|
||
<b>${formatTimeComponent(days)}</b>
|
||
<b>${formatTimeComponent(hours)}</b>
|
||
<b>${formatTimeComponent(minutes)}</b>
|
||
<b>${formatTimeComponent(seconds)}</b>`;
|
||
}
|
||
else {
|
||
element.innerHTML = `
|
||
<b>${formatTimeComponent(hours)}</b>
|
||
<b>${formatTimeComponent(minutes)}</b>
|
||
<b>${formatTimeComponent(seconds)}</b>`;
|
||
}
|
||
}
|
||
}
|
||
function formatTimeComponent(component) {
|
||
return component <= 9 ? '0' + component : component.toString();
|
||
}
|
||
function formatTime(timestamp) {
|
||
const date = new Date(timestamp);
|
||
const formattedTime = date.toLocaleString('en-US', { day: 'numeric', month: 'numeric', year: 'numeric', hour: 'numeric', minute: 'numeric', second: 'numeric' });
|
||
return formattedTime;
|
||
}
|
||
function formatName(name) {
|
||
// Extract the first letter and capitalize it
|
||
const formattedName = name.charAt(0).toUpperCase();
|
||
return formattedName;
|
||
}
|
||
const AddGroupTemplate = `
|
||
<a href="javascript:void(0)" class="btn-close"
|
||
onclick="$('.global-popup').removeClass('active');closeBackground()">
|
||
<i class="fa fa-times"></i>
|
||
</a>
|
||
<div class="content" id="js-load-add-group">
|
||
<h2 class="title">Đặt tên nhóm của bạn</h2>
|
||
<div class="note">
|
||
Chào Bạn, Hiện tại còn 6 sản phẩm Chuột máy tính. Nhanh chóng tạo nhóm ngay để được mua sản phẩm với
|
||
giá hấp dẫn.
|
||
</div>
|
||
<input type="text" class="name-group" placeholder="Nhập tên nhóm" />
|
||
<i class="vd">Vd: Hurasort săn sale Noel</i>
|
||
<a href="javascript:void(0)" class="btn-add-group" onclick="showContentPopup('share_group')">
|
||
<i class="fa fa-angle-double-right"></i>
|
||
<span>Tạo nhóm</span>
|
||
<i class="fa fa-angle-double-left"></i>
|
||
</a>
|
||
</div>
|
||
`;
|
||
const ShareGroupTemplate = `
|
||
<a href="javascript:void(0)" class="btn-close"
|
||
onclick="$('.global-popup').removeClass('active');closeBackground()">
|
||
<i class="fa fa-times"></i>
|
||
</a>
|
||
<div class="content">
|
||
<h2 class="title">Chúc mừng bạn!</h2>
|
||
<div class="note">
|
||
Nhóm được tạo thành công, vui lòng check mail để xem chi tiết thông tin nhóm của bạn!
|
||
</div>
|
||
<div class="box-share-link d-flex align-items">
|
||
<div class="info-link">
|
||
<span>Link nhóm:</span>
|
||
<a href="" class="blue" id="linkshare">https://adman.vn/group-order?id=2431177</a>
|
||
</div>
|
||
<a href="javascript:void(0)" onclick="copyLink()" class="btn-copy">
|
||
<i class="fa fa-copy"></i>
|
||
Copy
|
||
</a>
|
||
</div>
|
||
<div class="list-btn-share d-flex align-items">
|
||
<b>Share:</b>
|
||
<div class="d-flex align-items">
|
||
<a href="">
|
||
<img src="./assets/images/icon-facebook.png" alt="icon facebook">
|
||
</a>
|
||
<a href="">
|
||
<img src="./assets/images/icon-zalo.png" alt="icon zalo">
|
||
</a>
|
||
<a href="">
|
||
<img src="./assets/images/icon-email.png" alt="icon email">
|
||
</a>
|
||
</div>
|
||
</div>
|
||
<div class="form-add-email">
|
||
<p>Hoặc bạn có thể mời bạn bè của bạn bằng cách nhập email</p>
|
||
<div class="content-email" id="list-email-share">
|
||
<input type="text" id="email1" placeholder="Email 1">
|
||
<input type="text" id="email2" placeholder="Email 2">
|
||
</div>
|
||
<a href="javascript:void(0)" class="add-email" onclick="addEmail()">
|
||
+ Thêm email
|
||
</a>
|
||
</div>
|
||
|
||
<a href="javascript:void(0)" class="btn-add-member" onclick="ShowPopupGlobal('waiting_join')">
|
||
Gửi email thông báo
|
||
</a>
|
||
</div>
|
||
`;
|
||
const JoinProductTemplate = `
|
||
<a href="javascript:void(0)" class="btn-close" onclick="closeBackground()">
|
||
<i class="fa fa-times"></i>
|
||
</a>
|
||
<div class="content">
|
||
<div class="avatar-leader">v</div>
|
||
<b class="title-member text-center">Hồng vừa mời bạn tham gia nhóm Hura săn sale Noel</b>
|
||
<div class="box-info-product">
|
||
<div class="product-item d-flex">
|
||
<a href="" class="product-image">
|
||
<img src="./assets/images/image-sp.png" alt="">
|
||
<div class="box-qnt d-flex align-items space-center">
|
||
<span class="sl">Sl: 30</span>
|
||
<span class="conlai">Còn lại: 10</span>
|
||
</div>
|
||
</a>
|
||
<div class="product-info">
|
||
<a href="" class="product-name line-clamp-2">Combo Bàn phím và Chuột không dây MOFII CANDY
|
||
Milk
|
||
Tea/ Nâu Combo Bàn phím và Chuột không dây MOFII CANDY Milk Tea/ Nâu</a>
|
||
<div class="box-price d-flex align-items">
|
||
<div class="retail_price">
|
||
199.000đ
|
||
</div>
|
||
<span class="red">Khi mua nhóm 5 người</span>
|
||
</div>
|
||
|
||
<div class="list-memeber d-flex align-items">
|
||
<div class="box-memeber d-flex">
|
||
<a href="javascript:void(0)" class="item">
|
||
v
|
||
</a>
|
||
<a href="javascript:void(0)" class="item add">
|
||
+
|
||
</a>
|
||
</div>
|
||
<div class="note-member">
|
||
Cần thêm <b style="color: var(--color-global);">02</b> thành viên
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="note-member text-center">
|
||
Bạn có 10 phút để tham gia nhóm, mau chóng ấn chọn
|
||
Tham gia nhóm để có cơ hội mua hàng với giá siêu ưu đãi nhé!
|
||
</div>
|
||
<a href="javascript:void(0)" class="btn-member-add-group">
|
||
<b>Tham gia nhóm</b>
|
||
<div class="product-time-holder d-flex" id="js-time-join">
|
||
<b>20</b>
|
||
<b>11</b>
|
||
<b>30</b>
|
||
</div>
|
||
</a>
|
||
</div>
|
||
`;
|
||
const SuccessMemberTemplate = `
|
||
<a href="javascript:void(0)" class="btn-close"
|
||
onclick="$('.global-popup').removeClass('active');closeBackground()">
|
||
<i class="fa fa-times"></i>
|
||
</a>
|
||
<div class="content">
|
||
<h2 class="title">Chúc mừng bạn</h2>
|
||
<div class="note">
|
||
Đã tham gia nhóm thành công
|
||
</div>
|
||
<div class="txt">
|
||
Nhóm Hurasoft săn sale Noel đã đủ số lượng thành viên thành công mở khóa ưu đãi sản phẩm!
|
||
</div>
|
||
<b class="name-leader">
|
||
Người thanh toán: Hồng
|
||
</b>
|
||
<p>Thông tin thanh toán sẽ được gửi qua email của bạn.</p>
|
||
<a href="javascript:void(0)" class="btn-blue">
|
||
ok
|
||
</a>
|
||
</div>
|
||
`;
|
||
const InfoPayProductTemplate = `
|
||
<a href="javascript:void(0)" class="btn-close"
|
||
onclick="$('.global-popup').removeClass('active');closeBackground()">
|
||
<i class="fa fa-times"></i>
|
||
</a>
|
||
<div class="content">
|
||
<h2 class="title">Chúc mừng nhóm Hurasoft săn sale</h2>
|
||
<div class="note">Nhóm đã đủ số lượng thành viên để tham gia mua sản phẩm với giá ưu đãi</div>
|
||
<div class="info-pay">
|
||
<div class="title">Thông tin thanh toán</div>
|
||
<div class="cnt d-flex align-items">
|
||
<div class="left">
|
||
<img src="./assets/images/qr-pay.png" alt="pay">
|
||
</div>
|
||
<div class="right">
|
||
<span>NGUYỄN THỊ DUYÊN:</span>
|
||
<span>Ngân hàng: ACB</span>
|
||
<span>Số tài khoản: 7960888888</span>
|
||
<span>Nội dung thanh toán: Tên nhóm của bạn + SĐT</span>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="box-timeout-pay">
|
||
<div class="d-flex flex-wrap space-center">
|
||
<span>Bạn vui lòng thanh toán trước</span>
|
||
<div class="product-time-holder d-flex" id="js-time-join">
|
||
<b>20</b>
|
||
<b>11</b>
|
||
<b>30</b>
|
||
</div>
|
||
<div style="width: 100%;text-align: center;">Để được hưởng ưu đãi nhóm</div>
|
||
</div>
|
||
</div>
|
||
<div class="box-cskh">
|
||
Thanh toán xong hãy chụp lại giao dịch. CSKH <b>19002223</b> sẽ liên hệ xác nhận lại với bạn
|
||
</div>
|
||
<a href="javascript:void(0)" class="btn-blue">
|
||
ok
|
||
</a>
|
||
</div>
|
||
`;
|
||
const OutTimeJoinTpl = `
|
||
<a href="javascript:void(0)" class="btn-close"
|
||
onclick="$('.global-popup').removeClass('active');closeBackground()">
|
||
<i class="fa fa-times"></i>
|
||
</a>
|
||
<div class="content">
|
||
<h2 class="title">Thời gian tham gia nhóm Hurasoft săn sale Noel đã hết hạn!</h2>
|
||
<div class="note">Bạn vui lòng tham gia nhóm khác hoặc tự tạo nhóm để mua sản phẩm chuột máy tính ABC với giá ưu đãi nha</div>
|
||
</div>
|
||
`;
|
||
function XayHtmlPopup() {
|
||
}
|