add new changes
Cette révision appartient à :
Externe
+160
-31
@@ -2,8 +2,61 @@ function ramProductsInit(){
|
||||
let RAM_ID = '';
|
||||
|
||||
async function init(){
|
||||
const id = await getProductIdService();
|
||||
getRamData(id)
|
||||
let id
|
||||
if(location.search==''&&(location.href.includes('laptops')||location.href.includes('allinones'))){
|
||||
id = await getallproductsFun();
|
||||
}else{
|
||||
id = await getProductIdService();
|
||||
}
|
||||
getRamData(id);
|
||||
|
||||
swapSectionsVideo();
|
||||
}
|
||||
|
||||
async function getProductsIds(nameArr){
|
||||
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getallproducts`,true);
|
||||
if(resData.isError){
|
||||
toasterHelper("error","Something went wrong!")
|
||||
return;
|
||||
}
|
||||
|
||||
let res = resData.response;
|
||||
|
||||
res = JSON.parse(res.result);
|
||||
let ids = [];
|
||||
|
||||
for(let i=0;i<nameArr.length;i++){
|
||||
const currName = nameArr[i];
|
||||
let id = res.find((item)=>{
|
||||
if(currName === item.productname){
|
||||
return item.productid;
|
||||
}
|
||||
})
|
||||
if(id){
|
||||
ids.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
return ids;
|
||||
|
||||
}
|
||||
|
||||
async function getallproductsFun(){
|
||||
let laptopStr = ['FYRO Flagship','Zeno Dualbook','Zeno Sleekbook'];
|
||||
let allInOnesStr = ['AIO Zeno','AIO Fyro'];
|
||||
|
||||
|
||||
|
||||
let name = window.location.href;
|
||||
|
||||
name = name.includes('laptops') ?laptopStr : allInOnesStr;
|
||||
|
||||
const ids = await getProductsIds(name);
|
||||
|
||||
console.log(ids);
|
||||
|
||||
return ids;
|
||||
|
||||
}
|
||||
|
||||
function getProductIdService(){
|
||||
@@ -20,67 +73,143 @@ function ramProductsInit(){
|
||||
res = JSON.parse(res.result);
|
||||
|
||||
console.log(res);
|
||||
|
||||
let searchName = window.location.search.split('?')[1];
|
||||
let urlPathName = window.location.pathname;
|
||||
let searchTerm = '';
|
||||
if(urlPathName.includes('ram')){
|
||||
searchTerm = "RAM ORA";
|
||||
}else if(urlPathName.includes('storage')){
|
||||
searchTerm = `SSD ORA`;
|
||||
}else{
|
||||
searchTerm = searchName.replaceAll('%20',' ');
|
||||
}
|
||||
let resultItem = null;
|
||||
|
||||
for(let i=0;i<res.length;i++){
|
||||
if(res[i].productname.includes(searchTerm)){
|
||||
resultItem = res[i];
|
||||
break;
|
||||
let resultItem = [];
|
||||
|
||||
if(searchTerm.toLowerCase() === 'zeno'){
|
||||
for(let i=0;i<res.length;i++){
|
||||
if(res[i].productname.includes("Zeno Sleekbook")||res[i].productname.includes("Zeno Dualbook")){
|
||||
resultItem.push( res[i])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return reslove(resultItem)
|
||||
}else if(searchTerm.toLowerCase() === 'fyro'){
|
||||
for(let i=0;i<res.length;i++){
|
||||
if(res[i].productname.includes("FYRO Flagship")){
|
||||
resultItem.push( res[i]);
|
||||
return reslove(resultItem)
|
||||
}
|
||||
}
|
||||
}else{
|
||||
for(let i=0;i<res.length;i++){
|
||||
if(res[i].productname.includes(searchTerm)){
|
||||
resultItem.push( res[i])
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return reslove(resultItem)
|
||||
}
|
||||
const {productid} = resultItem;
|
||||
RAM_ID = productid;
|
||||
console.log(resultItem);
|
||||
return reslove(productid)
|
||||
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
async function getRamData(id){
|
||||
let resData =await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemtagscombination/productid/${id}`,true);
|
||||
|
||||
if(resData.isError){
|
||||
alert(resData.errorMsg.message);
|
||||
return;
|
||||
}
|
||||
|
||||
let res = resData.response;
|
||||
async function getRamData(ids){
|
||||
let resData;
|
||||
let res
|
||||
let data = [];
|
||||
let windowSearch = window.location.href;
|
||||
for(let i=0;i<ids.length;i++){
|
||||
let id = ids[i].productid;
|
||||
if (windowSearch.includes('laptops')||windowSearch.includes('allinones')) {
|
||||
resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/Bizgaze/integrations/products/getitemwithoutbranch/productid/${id}`, true);
|
||||
}
|
||||
else {
|
||||
resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemtagscombination/productid/${id}`, true);
|
||||
}
|
||||
if(resData.isError){
|
||||
alert(resData.errorMsg.message);
|
||||
return;
|
||||
}
|
||||
|
||||
res = resData.response;
|
||||
|
||||
res = JSON.parse(res.result);
|
||||
res = JSON.parse(res.result);
|
||||
data = [...data,...res];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
console.log(res);
|
||||
console.log(data);
|
||||
let html = '';
|
||||
|
||||
for(let i=0;i<res.length;i++){
|
||||
html += getRamCardHTML(res[i]);
|
||||
for(let i=0;i<data.length;i++){
|
||||
if(data[i].itemname.includes('AIO Fyro - 32')) continue;
|
||||
html += getRamCardHTML(data[i]);
|
||||
}
|
||||
|
||||
$('.product_card_section').html(html);
|
||||
|
||||
$('.ramcard').click(function(e){
|
||||
// $('.ramcard').click(function(e){
|
||||
|
||||
let sku = $(e.target).data('itemid');
|
||||
let itemid = $(e.target).data('itemid');
|
||||
// let sku = $(e.target).data('itemid');
|
||||
// let itemid = $(e.target).data('itemid');
|
||||
|
||||
window.location.href = `/productdetails.html?productId=${RAM_ID}#itemid=${itemid}`
|
||||
// window.location.href = `/productdetails.html?productId=${RAM_ID}#itemid=${itemid}`
|
||||
|
||||
})
|
||||
// })
|
||||
}
|
||||
|
||||
function getRamCardHTML({itemname,pricelist,itemid,sku,itemimageurl}){
|
||||
function getRamCardHTML({itemname,pricelist,itemid,sku,itemimageurl,productid}){
|
||||
let img = itemimageurl ? imgServerNameBuild(itemimageurl) : './dist/assets/imgs/nophoto.png'
|
||||
let tags = itemname.split('-');
|
||||
let ramTech = tags[tags.length-2];
|
||||
let gb = tags[tags.length-1];
|
||||
const [currencySymbol,amount] = getCurrencySymbol(pricelist);
|
||||
let priceAmt = `${currencySymbol} ${amount}`;
|
||||
|
||||
let detailPageName;
|
||||
let addSearch = '?';
|
||||
if (window.location.href.includes('laptops')) {
|
||||
detailPageName = 'laptopdetails';
|
||||
let name = itemname.toLowerCase().includes('zeno') ? 'Zeno' : 'Fyro';
|
||||
addSearch = `?${name}`;
|
||||
} else {
|
||||
detailPageName = 'productdetails';
|
||||
};
|
||||
|
||||
debugger;
|
||||
return `<div class="col-lg-4 col-md-6 mb-4 col-md-6 ram_card cursor-pointer">
|
||||
<div class="card border bg-gray-3 rounded-3 p-1 h-100">
|
||||
|
||||
<a href="/${detailPageName}.html${addSearch}productId=${productid}#itemid=${itemid}" class=""><img src="${img}" alt="${itemname}" class="w-100 h-100 p-5"></a>
|
||||
<div class="card-body">
|
||||
<a href="/${detailPageName}.html${addSearch}productId=${productid}#itemid=${itemid}" class="">
|
||||
<h5 class="card-title satoshi_font mb-0 px-2 text-center font-weight-600">${itemname}</h5>
|
||||
</a>
|
||||
</div>
|
||||
<hr>
|
||||
<ul class="border-0 d-flex h-100 justify-content-between px-md-3 px-4 list-group-flush p-0 text-secondary" style="list-style: none;">
|
||||
<li class="border-0 py-0">
|
||||
<span class="satoshi_font"> <h6>${gb}</h6> <h6>${ramTech}</h6></span>
|
||||
</li>
|
||||
<li class="border-0 py-0">
|
||||
<span class="satoshi_font"><h6>${pricelist?priceAmt:'Comming Soon'}</h6></span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-body text-center">
|
||||
<a href="/${detailPageName}.html?productId=${productid}#itemid=${itemid}" class="btn bg-white font-1-2 px-5 w-100">Details
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>`
|
||||
|
||||
return `<div class="col-lg-4 col-md-6 mb-4 col-md-6 ram_card cursor-pointer">
|
||||
<div class="card border bg-gray-3 rounded-3 p-1 h-100">
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur