code added

This commit is contained in:
2023-04-25 17:00:37 +05:30
parent e922bb6b35
commit 249616bfb6
15 changed files with 324 additions and 156 deletions
+4
View File
@@ -149,6 +149,10 @@ class API_SERVICE_CLASS{
if(response.data.code != '0'){
return failureResFun(response.data)
}
if(response.data.errors?.length){
return failureResFun(response.data)
}
return successResFun(response.data)
} catch (error) {
+149 -103
View File
@@ -1,5 +1,50 @@
let nav_html = `
<header class="header-area section-padding-1 transparent-bar">
navINIT();
function navINIT() {
loadCart();
function loadHelper(src = './dist/js/utils/helpers.js'){
if ($(`script[src="${src}"]`).length > 0) {
return new Promise((resolve) => resolve);
}
return new Promise(function (resolve, reject) {
var s;
s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
async function loadCart(){
let files = ['./dist/js/shoppingcart/addtocart.js'];
await loadHelper();
for(let i=0;i<files.length;i++){
if ($(`script[src="${files[i]}"]`).length > 0) {
continue;
}
try {
await loadHelper(files[i])
console.log("done");
} catch (error) {
console.log(error);
return;
}
}
setLengthCart();
//console.log("hello");
}
let URLNAMENAV = window.location.href;
const isTransparent = URLNAMENAV.includes('login')||URLNAMENAV.includes('orderconfirmation');
let nav_html = `
<header class="header-area section-padding-1 transparent-bar" ${isTransparent ?'style="background:#0A1039"' :''}>
<div class="header-large-device">
<div class="header-bottom sticky-bar">
<div class="container">
@@ -131,112 +176,113 @@ let nav_html = `
</div>
</div>
</div>`;
$("#navbar-head").html(nav_html);
let width = $(window).width();
$(".menu-negative-mrg2,.menu-negative-mrg3,.menu-negative-mrg4").css("width",width);
let ele_page = $("body").hasClass("product_pg");
if(ele_page == true){
$(".header-area").removeClass("bg-white");
$(".main-menu").find("nav ul li a").addClass("text-white");
$(".header-bottom.sticky-bar").removeClass("sticky-bar");
let src =`../dist/assets/imgs/anwi-logo-2.png`;
$(".logo-menu-wrap").find("a img").attr("src",src);
$(".main-body").find("iframe").attr("width",width);
if (width <= 575 && width >= 390) {
$(".main-body").find("iframe").attr({
width: width,
height: 236,
})
} else if(width <= 390 && width >= 270){
$(".main-body").find("iframe").attr({
width: width,
height: 210,
});
} else if (width <= 998 && width > 575) {
$(".main-body").find("iframe").attr({
width: width,
height: 530,
});
} else if(width <= 2720 && width > 1920){
$(".main-body").find("iframe").attr({
width: width,
height: 1440,
});
}else {
$(".main-body").find("iframe").attr({
width: width,
height: 860,
});
}
}
$("a.ram_data").click(function () {
let item_id = $(this).attr("accessories_id");
let loc_path = '/products.html'
if (window.location.pathname.includes(loc_path)) {
window.location.href = `?itemid=${item_id}`
}
else {
window.location.href = `/products.html#itemid=${item_id}`;
}
})
$(".main-menu nav ul").find("li").each(function(){
var current = window.location.pathname;
var $this = $(this).find("a");
if(current != "/"){
if($this.attr('href').indexOf(current) !== -1){
$(this).addClass('active_nav');
$("#navbar-head").html(nav_html);
let width = $(window).width();
$(".menu-negative-mrg2,.menu-negative-mrg3,.menu-negative-mrg4").css("width", width);
let ele_page = $("body").hasClass("product_pg");
if (ele_page == true) {
$(".header-area").removeClass("bg-white");
$(".main-menu").find("nav ul li a").addClass("text-white");
$(".header-bottom.sticky-bar").removeClass("sticky-bar");
let src = `../dist/assets/imgs/anwi-logo-2.png`;
$(".logo-menu-wrap").find("a img").attr("src", src);
$(".main-body").find("iframe").attr("width", width);
if (width <= 575 && width >= 390) {
$(".main-body").find("iframe").attr({
width: width,
height: 236,
})
} else if (width <= 390 && width >= 270) {
$(".main-body").find("iframe").attr({
width: width,
height: 210,
});
} else if (width <= 998 && width > 575) {
$(".main-body").find("iframe").attr({
width: width,
height: 530,
});
} else if (width <= 2720 && width > 1920) {
$(".main-body").find("iframe").attr({
width: width,
height: 1440,
});
} else {
$(".main-body").find("iframe").attr({
width: width,
height: 860,
});
}
}
})
// destroy localstorage data
let loc_path = '/productdetails.html';
if (window.location.pathname.includes(loc_path) === false) {
localStorage.removeItem("product_data");
localStorage.removeItem("top_data")
}
//services pages links and sources
let $body_pg = $("body").hasClass("services_page");
let $hm_pg = "../index.html";
let $nav_img ="../dist/assets/imgs/anwi-logo-1.png";
let $footer_img = "../dist/assets/imgs/anwi-logo-2.png";
let $scrool_top_img = "../dist/assets/imgs/Home/rocket-footer.png";
if($body_pg == true){
$(".header-large-device").find(".logo-menu-wrap .logo").find("a").attr("href",$hm_pg);
$(".header-large-device").find(".logo-menu-wrap .logo").find("a img").attr("src",$nav_img);
$(".mobile-logo").find("a").attr("href",$hm_pg);
$(".mobile-logo").find("a img").attr("src",$nav_img);
$(".main-menu").find("nav ul").find("li a").each(function(){
let $arc = $(this).attr("href");
let $spcial_char = $arc.includes("./");
if($spcial_char === true){
let $refarence = `.${$arc}`
$(this).attr("href",$refarence);
$("a.ram_data").click(function () {
let item_id = $(this).attr("accessories_id");
let loc_path = '/products.html'
if (window.location.pathname.includes(loc_path)) {
window.location.href = `?itemid=${item_id}`
}
$(".same-style").find("a").each(function(){
let $arc1 = $(this).attr("href");
let $spcial_char1 = $arc1.includes("./");
if($spcial_char1 === true){
let $refarence1 = `.${$arc1}`
$(this).attr("href",$refarence1);
else {
window.location.href = `/products.html#itemid=${item_id}`;
}
})
$(".main-menu nav ul").find("li").each(function () {
var current = window.location.pathname;
var $this = $(this).find("a");
if (current != "/") {
if ($this.attr('href').indexOf(current) !== -1) {
$(this).addClass('active_nav');
}
})
});
$(".clickable-mainmenu-wrap").find("nav ul").find("li a").each(function(){
let $arc_mbil = $(this).attr("href");
let $spcial_char_mbil = $arc_mbil.includes("./");
if($spcial_char_mbil === true){
let $refarence_mbil = `.${$arc_mbil}`
$(this).attr("href",$refarence_mbil);
}
});
})
// destroy localstorage data
let loc_path = '/productdetails.html';
if (window.location.pathname.includes(loc_path) === false) {
localStorage.removeItem("product_data");
localStorage.removeItem("top_data")
}
//services pages links and sources
let $body_pg = $("body").hasClass("services_page");
let $hm_pg = "../index.html";
let $nav_img = "../dist/assets/imgs/anwi-logo-1.png";
let $footer_img = "../dist/assets/imgs/anwi-logo-2.png";
let $scrool_top_img = "../dist/assets/imgs/Home/rocket-footer.png";
if ($body_pg == true) {
$(".header-large-device").find(".logo-menu-wrap .logo").find("a").attr("href", $hm_pg);
$(".header-large-device").find(".logo-menu-wrap .logo").find("a img").attr("src", $nav_img);
$(".mobile-logo").find("a").attr("href", $hm_pg);
$(".mobile-logo").find("a img").attr("src", $nav_img);
$(".main-menu").find("nav ul").find("li a").each(function () {
let $arc = $(this).attr("href");
let $spcial_char = $arc.includes("./");
if ($spcial_char === true) {
let $refarence = `.${$arc}`
$(this).attr("href", $refarence);
}
$(".same-style").find("a").each(function () {
let $arc1 = $(this).attr("href");
let $spcial_char1 = $arc1.includes("./");
if ($spcial_char1 === true) {
let $refarence1 = `.${$arc1}`
$(this).attr("href", $refarence1);
}
})
});
$(".clickable-mainmenu-wrap").find("nav ul").find("li a").each(function () {
let $arc_mbil = $(this).attr("href");
let $spcial_char_mbil = $arc_mbil.includes("./");
if ($spcial_char_mbil === true) {
let $refarence_mbil = `.${$arc_mbil}`
$(this).attr("href", $refarence_mbil);
}
});
}
}
+19 -4
View File
@@ -5,10 +5,13 @@ function orderConfirmation(){
getOrderStatus();
}
function orderlistsummary({name,price,qty,total}){
function orderlistsummary({name,price,qty,total,img}){
let priceAmt = '';
let totalAmt = '';
let defaultImg =img ? imgServerNameBuild(img): `./dist/assets/imgs/nophoto.png`;
debugger;
let [priceSysm,priceamt] = getCurrencySymbol(price)
priceAmt = `${priceSysm}${priceamt}`
@@ -20,6 +23,16 @@ function orderConfirmation(){
totalAmt = `${qtySymb}${qtyamt}`
return `<div class="col-sm-6">
<img src="${defaultImg}" alt="" class="w-100 h-100">
</div>
<div class="col-sm-6 d-flex flex-column justify-content-center">
<div class="itemname"><span class="font-weight-500">${name}</span></div>
<div> <span>Unit Price :</span><span class="font-weight-500">${priceAmt}</span> </div>
<div> <span>Quantity :</span><span class="font-weight-500">${qty}</span> </div>
<div> <span>Total Amount :</span> <span class="font-weight-500">${totalAmt}</span></div>
</div>`;
return `
<div class="row">
<div class="col-4">
@@ -112,12 +125,14 @@ function orderConfirmation(){
let orderItemsListHTML = '';
for(let i=0;i<OrderItems.length;i++){
const {ItemName:name,UnitPrice:price,Quantity:qty,UnitPrice:total} = OrderItems[i];
const {ItemName:name,UnitPrice:price,Quantity:qty,UnitPrice:total,ItemImage:img} = OrderItems[i];
debugger;
orderItemsListHTML += orderlistsummary({
name,
price,
qty,
total
total,
img
});
}
let userData = COOKIE_HELPER_ACTIONS.getCookie();
@@ -131,7 +146,7 @@ function orderConfirmation(){
debugger;
localStorage.removeItem(CART_DATA)
setLengthCart();
removeFullLoader();
console.log(resData);
+15 -2
View File
@@ -16,12 +16,21 @@ function startDetails(){
let currentClick = null;
debugger;
if(productId){
updateProductId(productId);
getProductDetails(productId);
appendSpecs(productId)
}else{
window.location.href = "/notfound.html"
}
function updateProductId(val){
$('#productidtag').val(val);
}
function updateItemId(val){
$('#itemidtag').val(val);
}
let specification_wrap_action = {
remove(){
debugger;
@@ -157,13 +166,15 @@ function startDetails(){
appendSpecs(obj.itemid)
$('#skudetailitem').val(obj.sku)
$('.des_productdes').html(obj.itemdescription);
$('#addtocart').attr('data-qty',obj.quantity)
$('#addtocart').attr('data-qty',obj.quantity);
let defaultImg = obj.itemimageurl ? imgServerNameBuild(obj.itemimageurl): `./dist/assets/imgs/nophoto.png`;
console.log(obj.itemimageurl,'obj.itemimageurlobj.itemimageurlobj.itemimageurl');
debugger;
$('.productDetailsMain > img').attr('src',defaultImg);
updateItemId(obj.itemid);
}
function searchComb(){
@@ -229,6 +240,8 @@ debugger;
itemsName += ` ${$(e).html().trim()}`;
});
updateItemId(null);
specification_wrap_action.remove();
$('#skudetailitem').val(-1)
$('.productname').html(itemsName)
@@ -449,7 +462,7 @@ debugger;
tagnames = tagnames.split('|');
$('.optiontaganwi').removeClass('borderselector');
currentComb = itemtagscombinationRes[0];
// updateItemId(itemtagscombinationRes[0].itemid);
for(let i=0;i<tagids.length;i++){
+4 -3
View File
@@ -56,7 +56,7 @@ function ramProductsInit(){
console.log(res);
let html = '';
debugger;
for(let i=0;i<res.length;i++){
html += getRamCardHTML(res[i]);
}
@@ -73,7 +73,8 @@ function ramProductsInit(){
})
}
function getRamCardHTML({itemname,pricelist,itemid,sku}){
function getRamCardHTML({itemname,pricelist,itemid,sku,itemimageurl}){
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];
@@ -86,7 +87,7 @@ function ramProductsInit(){
<div class="product_card_3 shadow ram_card">
<div class="card-item-header">
<div class="card-header-sub-3"><a class=" py-md-1" href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}">
<img src="./dist/assets/imgs/Navbar/ora_ddr4_desktop.png" class="w-100 h-100"></a>
<img src="${img}" class="w-100 h-100"></a>
</div>
</div>
<div class="card-item-body">
+11 -5
View File
@@ -105,7 +105,7 @@ function updateSummaryPriceAdd(){
}
function initAddToCart(){
debugger;
addEventListeners();
function addToCartFun(){
@@ -124,7 +124,9 @@ function initAddToCart(){
quantity:$('#quantity').val(),
img:$('.productDetailsMain img').attr('src'),
sku:$('#skudetailitem').val(),
totalQty:qty
totalQty:qty,
productid:$('#productidtag').val(),
itemid:$('#itemidtag').val()
}
@@ -149,7 +151,9 @@ function initAddToCart(){
quantity: parseInt(data[sku].quantity)+parseInt(quantity),
img:img,
sku:sku,
totalQty:qty
totalQty:qty,
productid:$('#productidtag').val(),
itemid:$('#itemidtag').val()
}
addtoCart(data);
}else{
@@ -159,13 +163,15 @@ function initAddToCart(){
quantity:parseInt(quantity),
img:img,
sku:sku,
totalQty:qty
totalQty:qty,
productid:$('#productidtag').val(),
itemid:$('#itemidtag').val()
}
addtoCart(data);
}
}
debugger;
setLengthCart();
}
+32 -14
View File
@@ -4,6 +4,7 @@ debugger;
function shoppingCartInit() {
shoppingCartAppend();
let DELETE_FILTER = null;
let insufficientQtyActions = {
moreQtyAdd(e){
@@ -40,6 +41,7 @@ function shoppingCartInit() {
$('.emptyShow').removeClass('d-none');
}
setLengthCart();
console.log(products,'products');
for (let product in products) {
html += shoppingCartDesktopHTML({ ...products[product], total: products[product].quantity * products[product].price, id: product });
@@ -118,6 +120,26 @@ function shoppingCartInit() {
}
});
$('.removeitemcartmodal').off('click').click(function (){
setCartData( DELETE_FILTER );
setLengthCart();
shoppingCartAppend();
let len = Object.keys(DELETE_FILTER).length
if(!len){
$('.checkoutbtn').addClass('d-none');
$('.emptyShow').removeClass('d-none');
}else{
$('.checkoutbtn').removeClass('d-none');
$('.emptyShow').addClass('d-none');
}
});
$('.btndeletecart').each(function (i, element) {
$(element).click(function (e) {
const cardId = $(e.target).data('cartid');
@@ -127,24 +149,20 @@ function shoppingCartInit() {
debugger;
const products = data;
const productsFilter = {};
$('#modalremovecart').html(products[cardId].name);
for (let product in products) {
if (product != cardId) productsFilter[product] = products[product];
}
data = productsFilter;
let len = Object.keys(data).length
if(!len){
$('.checkoutbtn').addClass('d-none');
$('.emptyShow').removeClass('d-none');
}else{
$('.checkoutbtn').removeClass('d-none');
$('.emptyShow').addClass('d-none');
}
setCartData(data);
setLengthCart();
shoppingCartAppend();
console.log(data);
DELETE_FILTER = data;
// setCartData(data);
// setLengthCart();
// shoppingCartAppend();
});
});
@@ -199,14 +217,14 @@ function shoppingCartInit() {
</div>`
}
function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total,totalQty }) {
function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total,totalQty,productid,itemid }) {
const [currencySymbol,amt] = getCurrencySymbol(price);
return `
<div class="row bg-white border-bottom py-4 d-flex justify-content-center align-items-center">
<div class="col-md-2 text-center"><img src="${img}" alt="${name}" class="img-fluid"></div>
<div class="col-md-4 ">
<a class="text-decoration-none text-blue fw-600 cursor-pointer" href="/productdetails.html?productId=${id}">${name}</a>
<a class="text-decoration-none text-blue fw-600 cursor-pointer" href="productdetails.html?productId=${productid}#itemid=${itemid}">${name}</a>
<small>${description||''}</small>
<span class="badge d-none text-bg-warning">8 Offers ></span>
</div>
@@ -222,7 +240,7 @@ function shoppingCartInit() {
<p class="fw-bold m-0"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-currency-rupee" viewBox="0 0 16 16">
<path d="M4 3.06h2.726c1.22 0 2.12.575 2.325 1.724H4v1.051h5.051C8.855 7.001 8 7.558 6.788 7.558H4v1.317L8.437 14h2.11L6.095 8.884h.855c2.316-.018 3.465-1.476 3.688-3.049H12V4.784h-1.345c-.08-.778-.357-1.335-.793-1.732H12V2H4v1.06Z"/>
</svg>${total}</p>
<span class="btndeletecart cursor-pointer fw-500 text-danger" data-cartid="${id}">x</span>
<span class="btndeletecart cursor-pointer fw-500 text-danger" data-cartid="${id}" data-bs-toggle="modal" data-bs-target="#deletecartmodal">x</span>
</div>
</div>
<div class="warrenty-sec px-3 sec-space-4 d-none">
+29 -15
View File
@@ -3,6 +3,17 @@ const uid = function(){
return Date.now().toString(36) + Math.random().toString(36).substr(2);
}
function loadScript(src) {
return new Promise(function (resolve, reject) {
var s;
s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
function shuffleArray(array) {
for (let i = array.length - 1; i > 0; i--) {
@@ -29,24 +40,27 @@ function getCurrencySymbol(value=0) {
function toasterHelper(type,message){
// toasterOpts()
debugger;
toasterOpts();
Command: toastr[type](message);
function toasterOpts(){
toastr.options = {
"closeButton": true,
"debug": false,
"newestOnTop": true,
"progressBar": true,
"positionClass": "toast-top-center",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
"closeButton": true,
"debug": false,
"newestOnTop": true,
"progressBar": true,
"positionClass": "toast-top-center",
"preventDuplicates": true,
"onclick": null,
"showDuration": "300",
"hideDuration": "1000",
"timeOut": "5000",
"extendedTimeOut": "1000",
"showEasing": "swing",
"hideEasing": "linear",
"showMethod": "fadeIn",
"hideMethod": "fadeOut"
}
}
}