"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; function goi_sp_tu_api() { return __awaiter(this, void 0, void 0, function* () { return new Promise((resolve, reject) => { return resolve(listproduct_mau); }); }); } function hienthi_sp() { return __awaiter(this, void 0, void 0, function* () { const lay_sp_tu_api = yield goi_sp_tu_api(); // code hien thi danh sach dang dien ra // Usage example: showListProductHome(lay_sp_tu_api, 'started', 'js-holder-list-started'); showListProductHome(lay_sp_tu_api, 'coming', 'js-holder-list-coming'); showListProductHome(lay_sp_tu_api, 'ended', 'js-holder-list-ended'); }); } function showListProductHome(lay_sp_tu_api, status, holderId) { const html = []; const holder = document.getElementById(holderId); lay_sp_tu_api .filter((product) => product.status == status) .forEach(function (product, keyIndex) { html.push(xayhtml(product)); if (status != 'ended' || product.to_time > product.from_time) { const countdownTime = (status == 'started') ? product.to_time : product.from_time; countDown(`js-deal-time-${product.productId}`, countdownTime); } }); if (holder) { holder.innerHTML = html.join(''); } } function xayhtml(product) { var Htmlcheckstatus = ''; if (product.status == 'started') { Htmlcheckstatus = `
Giá Khởi điểm: ${formatPrice(product.starting_price)}đ
Còn lại:
Đấu giá ngay`; } else if (product.status == 'coming') { Htmlcheckstatus = `
Giá Khởi điểm: ${formatPrice(product.starting_price)}đ
Bắt đầu sau:
Xem chi tiết`; } else if (product.to_time < Date.now()) { Htmlcheckstatus = `
Thắng cuộc ${formatPrice(product.starting_price)}đ
Đã kết thúc
Xem chi tiết`; } return `
${product.product_name}
${product.product_name}
Giá gốc: ${formatPrice(product.price)}đ
${Htmlcheckstatus}
`; } hienthi_sp();