code added
This commit is contained in:
Vendored
+28
-29
@@ -1,7 +1,9 @@
|
||||
// let SERVERNAME = 'https://anwi.bizgaze.app';
|
||||
//let SERVERNAME = 'https://anwi.bizgaze.app';
|
||||
let SERVERNAME = 'https://beta.bizgaze.app';
|
||||
//let SERVERNAME = 'http://localhost:3088';
|
||||
const STAT = 'b276960fddf84e8cb63de6e32d31529b';
|
||||
|
||||
|
||||
|
||||
async function getStatAPIService(url,data={}){
|
||||
let config = {
|
||||
url,
|
||||
@@ -33,14 +35,13 @@ async function postStatAPIService(url,data={}){
|
||||
}
|
||||
|
||||
|
||||
async function postAPIServiceWarranty(url,data={}){
|
||||
let SERVERURL = 'https://anwi.bizgaze.app';
|
||||
async function postAPIService(url,data={}){
|
||||
let config = {
|
||||
url:`${SERVERURL}/${url}`,
|
||||
url:`${SERVERNAME}/${url}`,
|
||||
method:'post',
|
||||
data:data,
|
||||
headers: {
|
||||
'Authorization': `Basic 6cdcfe22-1623-4740-97e0-363d518c0e8a`,
|
||||
'Authorization': `Basic fffe5440-5be6-4c07-876f-113c13de7382`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
@@ -48,27 +49,15 @@ async function postAPIServiceWarranty(url,data={}){
|
||||
|
||||
return response;
|
||||
}
|
||||
async function postAPIService(url,data={}){
|
||||
let SERVERURL = 'https://beta.bizgaze.app';
|
||||
//let SERVERURL = 'http://localhost:3088';
|
||||
let config = {
|
||||
url:`${SERVERURL}/${url}`,
|
||||
method:'post',
|
||||
data:data,
|
||||
}
|
||||
let response = await axios(config);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
async function postAPIServiceLocal(url,data={}){
|
||||
let config = {
|
||||
url:`${SERVERNAME}/${url}`,
|
||||
method:'post',
|
||||
data:JSON.stringify(data),
|
||||
data:JSON.stringify(data ),
|
||||
headers: {
|
||||
'Authorization': `Basic c86af480-b5ef-43af-8ce9-503e5b831e2e`,
|
||||
'Authorization': `Basic fffe5440-5be6-4c07-876f-113c13de7382`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
@@ -77,12 +66,12 @@ async function postAPIServiceLocal(url,data={}){
|
||||
return response;
|
||||
}
|
||||
async function getAPIServiceLocal(url){
|
||||
let SERVERURL = 'https://anwi.bizgaze.app';
|
||||
let config = {
|
||||
url:`${SERVERURL}/${url}`,
|
||||
url:`${SERVERNAME}/${url}`,
|
||||
method:'get',
|
||||
|
||||
headers: {
|
||||
'Authorization': `Basic ed40b74d-561a-47af-b03b-4f29c5ff6937`,
|
||||
'Authorization': `Basic fffe5440-5be6-4c07-876f-113c13de7382`,
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
}
|
||||
@@ -126,7 +115,7 @@ class API_SERVICE_CLASS{
|
||||
if(!cookieData) return window.location.href = "/"
|
||||
}
|
||||
let token = isStat ?`stat ${this.statToken}` : `Basic ${cookieData.token}`;
|
||||
// let token = isStat ?`stat ${this.statToken}` : `Basic ${this.token}`;
|
||||
this.token = token;
|
||||
let successResFun = this.buildSuccessResponse;
|
||||
let failureResFun = this.buildFailureResponse;
|
||||
let config = {
|
||||
@@ -150,7 +139,7 @@ class API_SERVICE_CLASS{
|
||||
return successResFun(response.data)
|
||||
}
|
||||
if(response.data.code == '417'){
|
||||
window.location.href = '/index.html'
|
||||
// window.location.href = '/index.html'
|
||||
return failureResFun(response.data)
|
||||
}
|
||||
if(response.data.code != '0'){
|
||||
@@ -168,7 +157,6 @@ class API_SERVICE_CLASS{
|
||||
|
||||
}
|
||||
|
||||
|
||||
buildURL(url){
|
||||
return `${this.baseURL}/${url}`;
|
||||
}
|
||||
@@ -243,6 +231,10 @@ class API_SERVICE_CLASS{
|
||||
if(!cookieData){
|
||||
return justGetAPIService('/Account/Session/Validate')
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -277,8 +269,10 @@ class COOKIE_HELPER_CLASS{
|
||||
|
||||
removeCookie(token){
|
||||
Cookies.remove(token)
|
||||
}
|
||||
async validateToken() {
|
||||
}
|
||||
|
||||
|
||||
async validateToken(){
|
||||
return await API_SERVICES_ACTIONS.getAPIService(`Account/Session/Validate`)
|
||||
}
|
||||
}
|
||||
@@ -290,6 +284,8 @@ const COOKIE_HELPER_ACTIONS ={
|
||||
setCookie :COOKIE_HELPER.setCookie,
|
||||
removeAuthCookie:COOKIE_HELPER.removeCookie.bind(null,AUTH)
|
||||
}
|
||||
|
||||
|
||||
function setCookieManual(token){
|
||||
Cookies.set(AUTH,{
|
||||
token,
|
||||
@@ -299,9 +295,9 @@ function setCookieManual(token){
|
||||
|
||||
async function checkValidAuth(cb,redirect=undefined){
|
||||
debugger;
|
||||
|
||||
document.querySelector('auth-loader').show();
|
||||
const res = await COOKIE_HELPER.validateToken();
|
||||
debugger
|
||||
if(!res.response){
|
||||
if(redirect){
|
||||
window.location.href =redirect;
|
||||
@@ -318,3 +314,6 @@ async function checkValidAuth(cb,redirect=undefined){
|
||||
cb();
|
||||
},300);
|
||||
}
|
||||
|
||||
|
||||
// setCookieManual('6eb70fee-35ef-4ca2-95cd-01ebdd616eb1');
|
||||
Vendored
+1
@@ -131,6 +131,7 @@ function initLogin() {
|
||||
COOKIE_HELPER_ACTIONS.setCookie({
|
||||
token: res.data.result.sessionId,
|
||||
userid: res.data.result.userId,
|
||||
...res.data.result
|
||||
});
|
||||
// setInitLoginLocal();
|
||||
window.localStorage.setItem("Useremail", userEmail);
|
||||
|
||||
+32
-1
@@ -100,7 +100,20 @@ template.innerHTML = `
|
||||
</style>
|
||||
<div class="overlayanwiAuth ">
|
||||
|
||||
<div style="
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
width:40px;
|
||||
display:none;
|
||||
">
|
||||
|
||||
<span>
|
||||
<?xml version="1.0" encoding="utf-8"?><svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 122.88 116.31" style="enable-background:new 0 0 122.88 116.31" xml:space="preserve"><g><path d="M4.06,12.67C1.87,12.67,0,10.8,0,8.51c0-2.19,1.87-4.06,4.06-4.06h5.62c0.1,0,0.31,0,0.42,0c3.75,0.1,7.08,0.83,9.88,2.6 c3.12,1.98,5.41,4.99,6.66,9.47c0,0.1,0,0.21,0.1,0.31L27.78,21h2.34V4.12c0-2.27,1.85-4.12,4.12-4.12h21.67 c2.27,0,4.12,1.85,4.12,4.12v10.02c3.42-3.41,8.06-5.5,13.18-5.5c2.22,0,4.36,0.4,6.34,1.12c4.08-4.33,9.87-7.04,16.29-7.04 c10.96,0,20.07,7.88,21.99,18.28h0.99c2.29,0,4.06,1.87,4.06,4.06c0,0.42-0.11,0.83-0.21,1.25l-10.61,42.76 c-0.42,1.87-2.08,3.12-3.95,3.12l0,0H41.51c1.46,5.41,2.91,8.32,4.89,9.68c2.39,1.56,6.56,1.66,13.53,1.56h0.1l0,0h47.03 c2.29,0,4.06,1.87,4.06,4.06c0,2.29-1.87,4.06-4.06,4.06H60.04l0,0c-8.64,0.1-13.94-0.1-18.21-2.91 c-4.37-2.91-6.66-7.91-8.95-16.96l0,0L18.94,18.92c0-0.1,0-0.1-0.1-0.21c-0.62-2.29-1.66-3.85-3.12-4.68 c-1.46-0.94-3.43-1.35-5.72-1.35c-0.1,0-0.21,0-0.31,0H4.06L4.06,12.67L4.06,12.67z M84.38,37.69c0-1.28,1.27-2.32,2.83-2.32 c1.56,0,2.83,1.04,2.83,2.32v15.69c0,1.28-1.27,2.32-2.83,2.32c-1.56,0-2.83-1.04-2.83-2.32V37.69L84.38,37.69z M67.43,37.69 c0-1.28,1.27-2.32,2.83-2.32c1.56,0,2.83,1.04,2.83,2.32v15.69c0,1.28-1.27,2.32-2.83,2.32c-1.56,0-2.83-1.04-2.83-2.32V37.69 L67.43,37.69z M50.49,37.69c0-1.28,1.27-2.32,2.83-2.32c1.56,0,2.83,1.04,2.83,2.32v15.69c0,1.28-1.27,2.32-2.83,2.32 c-1.56,0-2.83-1.04-2.83-2.32V37.69L50.49,37.69z M85.57,13.37c2.31,2.05,4.14,4.66,5.29,7.63h19.85 c-1.68-6.65-7.7-11.58-14.87-11.58C91.89,9.42,88.29,10.91,85.57,13.37L85.57,13.37z M92.21,29.11L92.21,29.11l-38.01,0l0,0H30.07 l0,0l9.26,34.86h65.65l8.63-34.86H92.21L92.21,29.11z M55.31,21c0.11-0.29,0.23-0.57,0.35-0.85V7.2c0-1.64-1.35-2.99-2.99-2.99 H37.71c-1.64,0-2.99,1.34-2.99,2.99V21H55.31L55.31,21z M94.89,96.33c5.52,0,9.99,4.47,9.99,9.99s-4.47,9.99-9.99,9.99 c-5.51,0-9.99-4.47-9.99-9.99S89.38,96.33,94.89,96.33L94.89,96.33L94.89,96.33z M51.09,96.33c5.51,0,9.99,4.47,9.99,9.99 s-4.47,9.99-9.99,9.99s-9.99-4.47-9.99-9.99S45.57,96.33,51.09,96.33L51.09,96.33L51.09,96.33z"/></g>
|
||||
</svg>
|
||||
</span>
|
||||
</div>
|
||||
<div class="authloaderanwi">
|
||||
<div class='loader' id='lrd1'></div>
|
||||
</div>
|
||||
@@ -111,9 +124,27 @@ template.innerHTML = `
|
||||
class AuthLoader extends HTMLElement {
|
||||
constructor() {
|
||||
super();
|
||||
console.log(this.payment);
|
||||
this._shadowRoot = this.attachShadow({ 'mode': 'open' });
|
||||
this._shadowRoot.appendChild(template.content.cloneNode(true));
|
||||
}
|
||||
|
||||
static get observedAttributes() {
|
||||
return ['payment'];
|
||||
}
|
||||
|
||||
// define getters and setters for attributes
|
||||
get payment() {
|
||||
return this.getAttribute('payment');
|
||||
}
|
||||
|
||||
set payment(val) {
|
||||
if (val) {
|
||||
this.setAttribute('payment', val);
|
||||
} else {
|
||||
this.removeAttribute('payment');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
show(){
|
||||
@@ -122,7 +153,7 @@ class AuthLoader extends HTMLElement {
|
||||
}
|
||||
|
||||
hide(){
|
||||
// $('.overlayanwiAuth').addClass('display','none');
|
||||
//$('.overlayanwiAuth').addClass('display','none');
|
||||
this._shadowRoot.querySelector('.overlayanwiAuth').style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+18
@@ -0,0 +1,18 @@
|
||||
const ALL_ADDRESS_LOCAL = 'ALL_ADDRESS_LOCAL';
|
||||
|
||||
function setAddressLocal(payload){
|
||||
let addressList = getAddressLocal();
|
||||
addressList = addressList?addressList:[];
|
||||
localStorage.setItem(ALL_ADDRESS_LOCAL,JSON.stringify({...addressList,...payload}))
|
||||
}
|
||||
|
||||
function getAddressLocal(){
|
||||
let res = localStorage.getItem(ALL_ADDRESS_LOCAL)
|
||||
if(!res) return null;
|
||||
|
||||
return JSON.parse(res);
|
||||
}
|
||||
|
||||
function removeAddressLocal(){
|
||||
localStorage.removeItem(ALL_ADDRESS_LOCAL);
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
const INIT_LOGIN_AUTH = 'INIT_LOGIN_AUTH';
|
||||
|
||||
function setInitLoginLocal(){
|
||||
localStorage.setItem(INIT_LOGIN_AUTH,true);
|
||||
}
|
||||
|
||||
function getInitLoginLocal(){
|
||||
return JSON.parse(localStorage.getItem(INIT_LOGIN_AUTH));
|
||||
}
|
||||
|
||||
|
||||
function removeInitLoginLocal(){
|
||||
localStorage.setItem(INIT_LOGIN_AUTH,false);
|
||||
}
|
||||
Vendored
+9
-3
@@ -1,7 +1,9 @@
|
||||
let nav_html = `
|
||||
<header class="header-area section-padding-1 transparent-bar">
|
||||
<div class="header-large-device">
|
||||
<div class="header-bottom sticky-bar">
|
||||
<div class="header-bottom sticky-bar" style="
|
||||
background: #ed3838;
|
||||
">
|
||||
<div class="container">
|
||||
<div class="header-bottom-flex">
|
||||
<div class="logo-menu-wrap d-flex">
|
||||
@@ -29,7 +31,9 @@ let nav_html = `
|
||||
<a href="./myaccount.html" class="my_avatar"><i class="fa-solid fa-user"></i></a>
|
||||
</div>
|
||||
<div class="same-style header-cart">
|
||||
<a class="cart-active1" href="#"><i class="fa-solid fa-cart-shopping"></i></a>
|
||||
<a class="cart-active1 position-relative" href="./shopping-cart.html"><i class="fa-solid fa-cart-shopping"></i>
|
||||
<span class="position-absolute cartnumcount d-none" style="top:-27%;right:-80%">0</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -61,7 +65,9 @@ let nav_html = `
|
||||
<a href="./myaccount.html" class="my_avatar"><i class="fa-solid fa-user"></i></a>
|
||||
</div>
|
||||
<div class="same-style header-cart">
|
||||
<a class="cart-active1" href="#"><i class="fa-solid fa-cart-shopping"></i></a>
|
||||
<a class="cart-active1 position-relative" href="./shopping-cart.html"><i class="fa-solid fa-cart-shopping"></i>
|
||||
<span class="position-absolute cartnumcount d-none" style="top:-27%;right:-80%">0</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Vendored
+145
@@ -0,0 +1,145 @@
|
||||
function orderConfirmation(){
|
||||
init();
|
||||
function init(){
|
||||
addFullLoader();
|
||||
getOrderStatus();
|
||||
}
|
||||
|
||||
function orderlistsummary({name,price,qty,total}){
|
||||
let priceAmt = '';
|
||||
let totalAmt = '';
|
||||
|
||||
|
||||
let [priceSysm,priceamt] = getCurrencySymbol(price)
|
||||
priceAmt = `${priceSysm}${priceamt}`
|
||||
|
||||
|
||||
|
||||
let [qtySymb,qtyamt] = getCurrencySymbol(qty*price)
|
||||
|
||||
|
||||
totalAmt = `${qtySymb}${qtyamt}`
|
||||
|
||||
return `
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<img class="w-100 h-100" src="http://127.0.0.1:5504/dist/assets/imgs/Navbar/Accessiories-2.png" alt="">
|
||||
</div>
|
||||
<div class="col-6 d-flex justify-content-center align-items-center">
|
||||
<div class="itemname">${name}</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3 d-flex align-items-center justify-content-center">
|
||||
${priceAmt}
|
||||
</div>
|
||||
<div class="col-2 d-flex align-items-center justify-content-center">
|
||||
${qty}
|
||||
</div>
|
||||
<div class="col-3 text-end">
|
||||
${totalAmt}
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function addFullLoader(){
|
||||
document.querySelector('auth-loader').show();
|
||||
}
|
||||
|
||||
function removeFullLoader(){
|
||||
document.querySelector('auth-loader').hide();
|
||||
}
|
||||
|
||||
async function getOrderStatus(){
|
||||
|
||||
const searchParams = window.location.search.split('&');
|
||||
let orderId = searchParams[0].split('=')[1];
|
||||
|
||||
debugger;
|
||||
let orderRes = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/hyperfusionpaymentgateway/gethyperfusionpaymentdetails/orderid/${orderId}`);
|
||||
if(orderRes.isError){
|
||||
removeFullLoader();
|
||||
return;
|
||||
}
|
||||
console.log(orderRes);
|
||||
//payment_group
|
||||
|
||||
orderRes = JSON.parse(orderRes.response.result)[0];
|
||||
$('.paymentmethodconfirm').html(orderRes.payment_group)
|
||||
if(orderRes.payment_status === 'FAILED'){
|
||||
$('.ordercontainerconfirmError').removeClass('d-none');
|
||||
$('.successorderconfirm').addClass('d-none');
|
||||
removeFullLoader();
|
||||
return;
|
||||
}
|
||||
|
||||
const res = await API_SERVICES_ACTIONS.postAPIService(`apis/v4/bizgaze/transact/orders/updatepaymenttransactionstatus/refid/${orderId}`,null);
|
||||
|
||||
console.log(res,'ress');
|
||||
|
||||
if(res.isError){
|
||||
console.log(res);
|
||||
$('.ordercontainerconfirmError').removeClass('d-none');
|
||||
$('.successorderconfirm').addClass('d-none');
|
||||
removeFullLoader();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if(!res.response.message.toLowerCase().includes('success')){
|
||||
console.log(res);
|
||||
$('.ordercontainerconfirmError').removeClass('d-none');
|
||||
$('.successorderconfirm').addClass('d-none');
|
||||
removeFullLoader();
|
||||
return;
|
||||
}
|
||||
|
||||
let resData = JSON.parse(res.response.result);
|
||||
|
||||
const {NetTotal,TaxAmount,OrderItems,CreatedDate,OrderNo
|
||||
} = resData;
|
||||
let [netcurrencySymbol,netamount] = getCurrencySymbol(NetTotal);
|
||||
$('.totalordersummary').html(`${netcurrencySymbol}${netamount}`);
|
||||
|
||||
{
|
||||
let [ordercurrencySymbol,orderamount] = getCurrencySymbol(TaxAmount);
|
||||
$('.totaltaxsummary').html(`${ordercurrencySymbol}${orderamount}`);
|
||||
}
|
||||
|
||||
let orderItemsListHTML = '';
|
||||
|
||||
for(let i=0;i<OrderItems.length;i++){
|
||||
const {ItemName:name,UnitPrice:price,Quantity:qty,UnitPrice:total} = OrderItems[i];
|
||||
orderItemsListHTML += orderlistsummary({
|
||||
name,
|
||||
price,
|
||||
qty,
|
||||
total
|
||||
});
|
||||
}
|
||||
let userData = COOKIE_HELPER_ACTIONS.getCookie();
|
||||
let {name} = userData;
|
||||
$('.username').html(name);
|
||||
$('.orderlistconfirm').html(orderItemsListHTML);
|
||||
|
||||
$('.createdDateConfirm').html(CreatedDate);
|
||||
|
||||
$('.ordernumber').html(OrderNo);
|
||||
debugger;
|
||||
localStorage.removeItem(CART_DATA)
|
||||
|
||||
|
||||
removeFullLoader();
|
||||
console.log(resData);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
checkValidAuth(orderConfirmation)
|
||||
+469
@@ -0,0 +1,469 @@
|
||||
function startDetails(){
|
||||
// http://127.0.0.1:5502/productdetails.html?productId=106633230000024
|
||||
let productId = window.location.search.split('=')[1].split('&')[0];
|
||||
console.log(productId);
|
||||
let itemtagscombinationRes = null;
|
||||
let labels = {};
|
||||
let isThereInLabel = {};
|
||||
let currentComb = null;
|
||||
|
||||
let group = {};
|
||||
|
||||
let currentClick = null;
|
||||
debugger;
|
||||
if(productId){
|
||||
getProductDetails(productId);
|
||||
appendSpecs(productId)
|
||||
}else{
|
||||
window.location.href = "/notfound.html"
|
||||
}
|
||||
|
||||
let specification_wrap_action = {
|
||||
remove(){
|
||||
debugger;
|
||||
$('.specification-wrap').addClass('d-none');
|
||||
},
|
||||
|
||||
add(){
|
||||
$('.specification-wrap').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
let description_action = {
|
||||
addVal(value){
|
||||
$('.description-wrap > p').html(value);
|
||||
},
|
||||
|
||||
removeVal(value){
|
||||
$('.description-wrap > p').html('');
|
||||
}
|
||||
}
|
||||
|
||||
function getSpecsItemHTML({name,des,itemid,id}){
|
||||
return ` <tr id="${id}" data-specitemid="${itemid}">
|
||||
<td style="width:200px">${name}</td>
|
||||
<td class="">${des}</td>
|
||||
</tr>`;
|
||||
}
|
||||
|
||||
async function appendSpecs(id){
|
||||
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemspecifications/itemid/${id}`,true);
|
||||
|
||||
if(resData.isError){
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const res = resData.response;
|
||||
console.log(JSON.parse(res.result));
|
||||
const data = JSON.parse(res.result);
|
||||
console.log(data);
|
||||
let html = '';
|
||||
for(let i=0;i<data.length;i++){
|
||||
const {specificationname,specificationitemid,itemid,description} = data[i];
|
||||
html += getSpecsItemHTML({
|
||||
name:specificationname,id:specificationitemid,itemid,des:description
|
||||
});
|
||||
}
|
||||
debugger;
|
||||
|
||||
$('.append-specs').html(html)
|
||||
}
|
||||
|
||||
|
||||
function getParentHTML(name,productid,id,isMain){
|
||||
return `<div class="pb-2 $${name?.replace(" ",'')}-parent">
|
||||
<h5 class="py-2 smallHeadingProductDetails">${name}</h5>
|
||||
<div class="d-flex gap-2 ${id}container" data-tagid="${id}">
|
||||
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
function onClickHandler(e) {
|
||||
|
||||
$(e).parent().find('.borderselector').removeClass('borderselector');
|
||||
|
||||
$(e).addClass('borderselector')
|
||||
|
||||
}
|
||||
|
||||
function getChildHTML(tagid,name,isTrue){
|
||||
return `
|
||||
<div data-type="${tagid}-${name}" data-tagiditem="${tagid}" class="specsmallcard optiontaganwi ${isTrue?'borderselector':''} card small-font p-3">
|
||||
${name}
|
||||
</div>
|
||||
`
|
||||
}
|
||||
|
||||
function addeventlisteners(){
|
||||
|
||||
$('.optiontaganwi').each(function (i,el){
|
||||
$(el).click(function (e){
|
||||
|
||||
$(e.target).parent().find('.borderselector').removeClass('borderselector');
|
||||
$(e.target).addClass('borderselector')
|
||||
searchComb();
|
||||
currentClick = e.target;
|
||||
// getAllCombination();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function searchComb(){
|
||||
let valuesSelected = [];
|
||||
|
||||
|
||||
$('#addtocart').removeClass('disabled');
|
||||
$('.msgErrorDetailsItem').addClass('d-none');
|
||||
$('.borderselector').each(function (i,el){
|
||||
let val = $(el).html();
|
||||
valuesSelected.push(val.trim());
|
||||
});
|
||||
|
||||
let labelRecord = {};
|
||||
|
||||
for(let label in labels){
|
||||
labelRecord[label] = false;
|
||||
}
|
||||
|
||||
console.log(labelRecord);
|
||||
specification_wrap_action.add();
|
||||
console.log(group);
|
||||
let unFiler = null;
|
||||
for(let i=0;i<itemtagscombinationRes.length;i++){
|
||||
const currItem = itemtagscombinationRes[i];
|
||||
const {tagnames} = currItem;
|
||||
|
||||
|
||||
let isTrue = true;
|
||||
let labelFilter = labelRecord;
|
||||
|
||||
for(let i=0;i<valuesSelected.length;i++){
|
||||
|
||||
if(!tagnames.includes(valuesSelected[i])){
|
||||
isTrue = false
|
||||
|
||||
unFiler = labelFilter;
|
||||
break;
|
||||
}
|
||||
labelFilter[group[valuesSelected[i]]] = true;
|
||||
}
|
||||
|
||||
if(isTrue){
|
||||
console.log(itemtagscombinationRes[i],'itemtagscombinationRes[i]');
|
||||
const {quantity} = itemtagscombinationRes[i];
|
||||
if(quantity>=$('#quantity').val() && quantity>=1){
|
||||
currentComb = itemtagscombinationRes[i];
|
||||
$('.productname').html(itemtagscombinationRes[i].itemname)
|
||||
$('.price').html(itemtagscombinationRes[i].pricelist);
|
||||
// location.hash = itemtagscombinationRes[i].itemname.trim();
|
||||
appendSpecs(itemtagscombinationRes[i].itemid)
|
||||
history.replaceState(null, null, `#itemid=${itemtagscombinationRes[i].itemid}#${itemtagscombinationRes[i].itemname.trim()}`);
|
||||
let searchparms = location.search;
|
||||
debugger;
|
||||
|
||||
|
||||
|
||||
// const regex = /sku="(\w+)"/g;
|
||||
// const newParams = searchparms.replace("sku", `$1${itemtagscombinationRes[i].sku}$2`);
|
||||
// location.search = newParams;
|
||||
$('#skudetailitem').val(itemtagscombinationRes[i].sku)
|
||||
}else{
|
||||
debugger;
|
||||
let name = itemtagscombinationRes[i].itemname.split('-')[0];
|
||||
$('#addtocart').addClass('disabled');
|
||||
let itemsName = name;
|
||||
$('.borderselector').each(function (i,e){
|
||||
itemsName += ` ${$(e).html().trim()}`;
|
||||
});
|
||||
|
||||
specification_wrap_action.remove();
|
||||
$('#skudetailitem').val(-1)
|
||||
$('.productname').html(itemsName)
|
||||
history.replaceState(null, null, `#`);
|
||||
|
||||
$('.msgErrorDetailsItem').removeClass('d-none');
|
||||
$('.price').html('');
|
||||
}
|
||||
|
||||
initAddToCart()
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let name = itemtagscombinationRes[0].itemname.split('-')[0];
|
||||
let itemsName = name;
|
||||
$('.borderselector').each(function (i,e){
|
||||
itemsName += `- ${$(e).html().trim()}`;
|
||||
})
|
||||
specification_wrap_action.remove();
|
||||
$('.productname').html(itemsName)
|
||||
$('#skudetailitem').val(-1)
|
||||
$('.price').html('');
|
||||
$('#addtocart').addClass('disabled');
|
||||
$('.msgErrorDetailsItem').removeClass('d-none');
|
||||
|
||||
initAddToCart()
|
||||
}
|
||||
|
||||
function getAllCombination(){
|
||||
const currClickAttr = $(currentClick).html().trim();
|
||||
|
||||
let isThere = [];
|
||||
for(let item in isThereInLabel){
|
||||
let {tagnames} = isThereInLabel[item];
|
||||
if(tagnames.includes(currClickAttr)){
|
||||
isThere.push( isThereInLabel[item])
|
||||
}
|
||||
}
|
||||
let selected = [];
|
||||
$('.borderselector').each(function (i,e){
|
||||
selected.push($(e).html().trim())
|
||||
});
|
||||
|
||||
// console.log(selected);
|
||||
// console.log(isThere);
|
||||
|
||||
let ishashObj = {};
|
||||
|
||||
for(let i=0;i<isThere.length;i++){
|
||||
let {tagnames,tagids} = isThere[i];
|
||||
tagnames = tagnames.split('|');
|
||||
tagids = tagids.split('|');
|
||||
|
||||
for(let j=0;j<tagnames.length;j++){
|
||||
if(!ishashObj[tagnames[j]]){
|
||||
ishashObj[tagnames[j]] = tagids[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log(ishashObj);
|
||||
|
||||
// for(let i=0;i<itemtagscombinationRes.length;i++){
|
||||
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
async function getProductDetails(id){
|
||||
|
||||
|
||||
|
||||
// let res = await getStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/productattributelist/productid/${id}`);
|
||||
|
||||
let resData = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/productattributelist/productid/${id}`,true);
|
||||
|
||||
if(resData.isError){
|
||||
alert(resData.errorMsg.message);
|
||||
return;
|
||||
}
|
||||
|
||||
let res = resData.response;
|
||||
|
||||
res = JSON.parse(res.result);
|
||||
// console.log(res);
|
||||
|
||||
if(!res) return;
|
||||
|
||||
|
||||
|
||||
|
||||
let html = '';
|
||||
|
||||
for(let i=0;i<res.length;i++){
|
||||
const currItem = res[i];
|
||||
// parenttagid means under what label
|
||||
// tag id means it know unquie id
|
||||
const {parentattribute,parenttagid,tagid,attribute,productid} = currItem;
|
||||
|
||||
if(labels[parentattribute]){
|
||||
labels[parentattribute].items.push({
|
||||
attribute,
|
||||
tagid:tagid
|
||||
});
|
||||
}else{
|
||||
labels[parentattribute] = {
|
||||
id:parenttagid,
|
||||
items:[{
|
||||
attribute,
|
||||
tagid:tagid
|
||||
}]
|
||||
};
|
||||
html += getParentHTML(parentattribute,productid,parenttagid,i==0);
|
||||
}
|
||||
|
||||
}
|
||||
$('#spec-container-details').html(html);
|
||||
|
||||
|
||||
// console.log(labels,'labels');
|
||||
|
||||
let childIds = [];
|
||||
|
||||
for(let item in labels){
|
||||
let {id,items} = labels[item];
|
||||
// $(`[data-tagid=${id}]`)
|
||||
let html = '';
|
||||
|
||||
for(let i=0;i<items.length;i++){
|
||||
const {attribute,tagid} = items[i]
|
||||
childIds.push(tagid);
|
||||
group[attribute] = item;
|
||||
html += getChildHTML(tagid,attribute,i==0);
|
||||
}
|
||||
$(`[data-tagid="${id}"]`).html(html);
|
||||
}
|
||||
|
||||
itemtagscombinationRes = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/itemtagscombination/productid/${id}`,true);
|
||||
|
||||
itemtagscombinationRes = JSON.parse(itemtagscombinationRes.response.result);
|
||||
console.log(itemtagscombinationRes);
|
||||
|
||||
let valuesSelected = [];
|
||||
|
||||
$('.borderselector').each(function (i,el){
|
||||
|
||||
let val = $(el).html();
|
||||
valuesSelected.push(val.trim());
|
||||
});
|
||||
debugger;
|
||||
let searchParams = window.location.search.split("&");
|
||||
let skuId = window.location.hash.split('=')[1];
|
||||
// skuId = skuId.split('=')[1]
|
||||
let isGo = true;
|
||||
for(let i=0;i<itemtagscombinationRes.length;i++){
|
||||
const currItem = itemtagscombinationRes[i];
|
||||
|
||||
const {tagnames,sku,itemid} = currItem;
|
||||
|
||||
isThereInLabel[tagnames] = itemtagscombinationRes[i];
|
||||
|
||||
|
||||
let isTrue = true;
|
||||
if(isGo){
|
||||
// for(let i=0;i<valuesSelected.length;i++){
|
||||
// if(!tagnames.includes(valuesSelected[i])){
|
||||
// isTrue = false
|
||||
// }
|
||||
// }
|
||||
if(skuId != itemid){
|
||||
isTrue = false
|
||||
}
|
||||
|
||||
if(isTrue){
|
||||
debugger;
|
||||
console.log(itemtagscombinationRes[i],'itemtagscombinationRes[i]');
|
||||
currentComb = itemtagscombinationRes[i];
|
||||
$('.productname').html(itemtagscombinationRes[i].itemname);
|
||||
location.hash = itemtagscombinationRes[i].itemname.trim();
|
||||
$('#skudetailitem').val(itemtagscombinationRes[i].sku)
|
||||
$('.price').html(itemtagscombinationRes[i].pricelist)
|
||||
appendSpecs(itemtagscombinationRes[i].itemid)
|
||||
isGo = false;
|
||||
let {tagnames,tagids,pricelist} = itemtagscombinationRes[i];
|
||||
tagids = tagids.split('|');
|
||||
tagnames = tagnames.split('|');
|
||||
$('.optiontaganwi').removeClass('borderselector');
|
||||
|
||||
for(let i=0;i<tagids.length;i++){
|
||||
|
||||
$(`[data-tagiditem="${tagids[i]}"]`).addClass('borderselector');
|
||||
}
|
||||
// tagiditem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isGo){
|
||||
console.log(itemtagscombinationRes[0]);
|
||||
let {tagnames,tagids,pricelist} = itemtagscombinationRes[0];
|
||||
tagids = tagids.split('|');
|
||||
tagnames = tagnames.split('|');
|
||||
$('.optiontaganwi').removeClass('borderselector');
|
||||
currentComb = itemtagscombinationRes[0];
|
||||
for(let i=0;i<tagids.length;i++){
|
||||
|
||||
$(`[data-type="${tagids[i]}-${tagnames[i]}"]`).addClass('borderselector');
|
||||
}
|
||||
|
||||
$('.price').html(pricelist);
|
||||
//console.log(childIds);
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
//getAllCombination(valuesSelected)
|
||||
|
||||
|
||||
|
||||
// for(let i=0;i<itemtagscombinationRes.length;i++){
|
||||
// const {tagnames} = itemtagscombinationRes[i];
|
||||
|
||||
// }
|
||||
|
||||
$('#spec-container-details').children().slice(1).find('.specsmallcard').removeClass('specsmallcard');
|
||||
addeventlisteners();
|
||||
return;
|
||||
// let resTwo = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/itemtagscombination/productid/${id}`);
|
||||
|
||||
|
||||
//let html = '';
|
||||
let attributesObj = {};
|
||||
for(let i=0;i<res.length;i++){
|
||||
const {parentattribute,tagid,productid} = res[i];
|
||||
// let attributes = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/productattributelist/parenttagid/${tagid}`);
|
||||
// attributesObj[tagid] = JSON.parse(attributes.data.result);
|
||||
// console.log(attributes.data.result,tagid);
|
||||
html += getParentHTML(parentattribute,productid,tagid,i==0);
|
||||
}
|
||||
|
||||
$('#spec-container-details').html(html);
|
||||
|
||||
|
||||
// let attributes = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/productattributelist/parenttagid/${tagid}`);
|
||||
return;
|
||||
for(let attr in attributesObj){
|
||||
const arr = attributesObj[attr];
|
||||
|
||||
let html = '';
|
||||
for(let i=0;i<arr.length;i++){
|
||||
const {attribute,tagid} = arr[i];
|
||||
html += getChildHTML(tagid,attribute,i==0);
|
||||
}
|
||||
|
||||
|
||||
$(`[data-tagid="${attr}"]`).html(html);
|
||||
|
||||
|
||||
}
|
||||
|
||||
let defaultValues = await postStatAPIService(`${SERVERNAME}/apis/v4/bizgaze/integrations/products/sellableitemlist/productid/${id}`);
|
||||
defaultValues = JSON.parse(defaultValues.data.result);
|
||||
let {itemname,price} = defaultValues[0];
|
||||
$('.productname').html(itemname);
|
||||
$('.price').html(price)
|
||||
|
||||
$('#spec-container-details').children().slice(1).find('.specsmallcard').removeClass('specsmallcard');
|
||||
|
||||
|
||||
|
||||
|
||||
// getQuantityById(id)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
startDetails();
|
||||
|
||||
Vendored
+143
@@ -0,0 +1,143 @@
|
||||
function ramProductsInit(){
|
||||
let RAM_ID = '';
|
||||
|
||||
async function init(){
|
||||
const id = await getProductIdService();
|
||||
getRamData(id)
|
||||
}
|
||||
|
||||
function getProductIdService(){
|
||||
return new Promise(async (reslove,reject)=>{
|
||||
let resData =await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getallproducts`,true);
|
||||
if(resData.isError){
|
||||
alert(resData.errorMsg.message);
|
||||
return;
|
||||
}
|
||||
|
||||
let res = resData.response;
|
||||
|
||||
res = JSON.parse(res.result);
|
||||
|
||||
console.log(res);
|
||||
let urlPathName = window.location.pathname;
|
||||
let searchTerm = '';
|
||||
if(urlPathName.includes('ram')){
|
||||
searchTerm = "RAM ORA";
|
||||
}else if(urlPathName.includes('storage')){
|
||||
searchTerm = `SSD ORA`;
|
||||
}
|
||||
let resultItem = null;
|
||||
|
||||
for(let i=0;i<res.length;i++){
|
||||
if(res[i].productname.includes(searchTerm)){
|
||||
resultItem = res[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
res = JSON.parse(res.result);
|
||||
|
||||
console.log(res);
|
||||
let html = '';
|
||||
|
||||
for(let i=0;i<res.length;i++){
|
||||
html += getRamCardHTML(res[i]);
|
||||
}
|
||||
|
||||
$('.product_card_section').html(html);
|
||||
|
||||
$('.ramcard').click(function(e){
|
||||
let sku = $(e.target).data('itemid');
|
||||
let itemid = $(e.target).data('itemid');
|
||||
debugger;
|
||||
window.location.href = `/productdetails.html?productId=${RAM_ID}#itemid=${itemid}`
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function getRamCardHTML({itemname,pricelist,itemid,sku}){
|
||||
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}`;
|
||||
return `
|
||||
|
||||
<!--desktop--->
|
||||
<div class="col-sm-4 p-3">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-item-body">
|
||||
<h3 cclass="mb-2"> <a href="/productdetails.html?productId=${RAM_ID}#itemid=${itemid}" class="" > ${itemname} </a></h3>
|
||||
<hr>
|
||||
<h6>${gb}</h6> <h6>${ramTech}</h6><h6>${priceAmt}</h6>
|
||||
<div class="py-2 card_product_footer">
|
||||
<button data-sku="${sku}" data-itemid="${itemid}" class="w-100 border-0 ramcard bg-transparent satoshi_font ram_btn" data_name="ORA 8GB DDR4 3200MHz Desktop RAM " data_version="DDR4" data_device="Desktop" data_gb="8GB" data_price="2900">Details </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
return `<div class="col-lg-3 col-md-6 ram_card">
|
||||
<div class="card shadow border-0 p-1 h-100">
|
||||
<a href="#">
|
||||
<img src="../dist/assets/imgs/Navbar/ora_ddr5_laptop.png" class="card-img-top" alt="...">
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<a href="#" class="text-decoration-none text-dark">
|
||||
<h5 class="card-title satoshi_font mb-0">
|
||||
${itemname}
|
||||
</h5>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item border-0 py-0">
|
||||
<span class="satoshi_font">${gb} ${ramTech}</span>
|
||||
</li>
|
||||
<li class="list-group-item border-0 py-0">
|
||||
<span class="satoshi_font">3200 Mhz</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-body d-none">
|
||||
<button class="btn--md btn-primary w-100 card-link">
|
||||
<span class="cost currency-symbol">₹</span><span class="cost product-price satoshi_font">${pricelist}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
<div data-sku="${sku}" data-itemid="${itemid}" class="bg-black ramcard btn font-1-2 px-5 text-white w-100 satoshi_font" data_des="Upgrade your laptop with DDR4 Laptop
|
||||
Memory, oering 3200 MHz speed in 8, 16,
|
||||
and 32 GB capacities. Experience enhanced
|
||||
thermal performance, increased longevity,
|
||||
and superior performance with our
|
||||
innovative graphene sticker technology." data_name="ORA 8GB DDR4 3200MHz Laptop RAM ">Details
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
debugger;
|
||||
ramProductsInit();
|
||||
Vendored
+81
@@ -0,0 +1,81 @@
|
||||
function ramProductsInit(){
|
||||
const RAM_ID = 106633230000024;
|
||||
function init(){
|
||||
getRamData(RAM_ID)
|
||||
}
|
||||
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;
|
||||
|
||||
res = JSON.parse(res.result);
|
||||
|
||||
console.log(res);
|
||||
let html = '';
|
||||
|
||||
for(let i=0;i<res.length;i++){
|
||||
html += getRamCardHTML(res[i]);
|
||||
}
|
||||
|
||||
$('.ramsContainer').html(html);
|
||||
|
||||
$('.ramcard').click(function(e){
|
||||
let sku = $(e.target).data('sku');
|
||||
let itemid = $(e.target).data('itemid');
|
||||
|
||||
window.location.href = `/productdetails.html?productId=${RAM_ID}?sku=${sku}`
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function getRamCardHTML({itemname,pricelist,itemid,sku}){
|
||||
let tags = itemname.split('-');
|
||||
let ramTech = tags[tags.length-2];
|
||||
let gb = tags[tags.length-1];
|
||||
return `<div class="col-lg-3 col-md-6 ram_card">
|
||||
<div class="card shadow border-0 p-1 h-100">
|
||||
<a href="#">
|
||||
<img src="../dist/assets/imgs/Navbar/ora_ddr5_laptop.png" class="card-img-top" alt="...">
|
||||
</a>
|
||||
<div class="card-body">
|
||||
<a href="#" class="text-decoration-none text-dark">
|
||||
<h5 class="card-title satoshi_font mb-0">
|
||||
${itemname}
|
||||
</h5>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="list-group list-group-flush">
|
||||
<li class="list-group-item border-0 py-0">
|
||||
<span class="satoshi_font">${gb} ${ramTech}</span>
|
||||
</li>
|
||||
<li class="list-group-item border-0 py-0">
|
||||
<span class="satoshi_font">3200 Mhz</span>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="card-body d-none">
|
||||
<button class="btn--md btn-primary w-100 card-link">
|
||||
<span class="cost currency-symbol">₹</span><span class="cost product-price satoshi_font">${pricelist}</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
<div data-sku="${sku}" data-itemid="${itemid}" class="bg-black ramcard btn font-1-2 px-5 text-white w-100 satoshi_font" data_des="Upgrade your laptop with DDR4 Laptop
|
||||
Memory, oering 3200 MHz speed in 8, 16,
|
||||
and 32 GB capacities. Experience enhanced
|
||||
thermal performance, increased longevity,
|
||||
and superior performance with our
|
||||
innovative graphene sticker technology." data_name="ORA 8GB DDR4 3200MHz Laptop RAM ">Details
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`
|
||||
}
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
ramProductsInit();
|
||||
Vendored
+208
@@ -0,0 +1,208 @@
|
||||
const CART_DATA = 'CART_DATA';
|
||||
|
||||
let cartLength = 0;
|
||||
const CART_ADD = 'CART_ADD';
|
||||
function getCartData(){
|
||||
const data = localStorage.getItem(CART_DATA);
|
||||
if(data) return JSON.parse(data);
|
||||
return null;
|
||||
}
|
||||
|
||||
function removeCartData(){
|
||||
localStorage.removeItem(CART_DATA);
|
||||
}
|
||||
|
||||
function setCartData(data){
|
||||
localStorage.setItem(CART_DATA,JSON.stringify(data));
|
||||
}
|
||||
|
||||
function setLengthCart(){
|
||||
const data = getCartData();
|
||||
if(!data) return;
|
||||
|
||||
|
||||
let length = 0;
|
||||
|
||||
for(let item in data){
|
||||
let curr = data[item];
|
||||
length += parseInt(curr.quantity);
|
||||
}
|
||||
|
||||
if(length>0){
|
||||
$('.cartnumcount').removeClass('d-none').html(length);
|
||||
}else{
|
||||
$('.cartnumcount').addClass('d-none').html(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function getQuantityById(id){
|
||||
const data = getCartData();
|
||||
if(!data) return;
|
||||
|
||||
for(let item in data){
|
||||
if(id == item){
|
||||
$('#quantity').val(products[item].quantity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateCartQuantity(id,val){
|
||||
const data = getCartData();
|
||||
if(!data) return;
|
||||
|
||||
|
||||
data[id].quantity = val;
|
||||
|
||||
|
||||
setCartData(data);
|
||||
updateSummaryPriceAdd();
|
||||
|
||||
}
|
||||
|
||||
function removeCartItem(id){
|
||||
debugger;
|
||||
let data = getCartData();
|
||||
if(!data) return;
|
||||
|
||||
let newdata = {};
|
||||
|
||||
for(let item in data){
|
||||
if(item != id){
|
||||
newdata[item] = data[item];
|
||||
}
|
||||
}
|
||||
|
||||
setCartData(newdata);
|
||||
updateSummaryPriceAdd();
|
||||
|
||||
return Object.keys(newdata).length;
|
||||
}
|
||||
|
||||
function updateSummaryPriceAdd(){
|
||||
let data = getCartData();
|
||||
let totalSummaryPrice = $('.totalSummaryPrice');
|
||||
let totalPrice = $('.totalPrice');
|
||||
let currecy = $('.currecy');
|
||||
let noofitems = $('.noofitems');
|
||||
if(!data) return;
|
||||
let len = 0;
|
||||
let totalAmt = 0;
|
||||
for(let item in data) {
|
||||
let {price,quantity} = data[item];
|
||||
totalAmt += parseInt(price*quantity);
|
||||
len += parseInt(quantity);
|
||||
}
|
||||
const [currencySymbol,amount] = getCurrencySymbol(totalAmt);
|
||||
noofitems.html(len);
|
||||
|
||||
totalSummaryPrice.html(amount);
|
||||
totalPrice.html(amount);
|
||||
currecy.html(currencySymbol);
|
||||
|
||||
|
||||
}
|
||||
|
||||
function initAddToCart(){
|
||||
|
||||
addEventListeners();
|
||||
|
||||
function addToCartFun(){
|
||||
const data = getCartData();
|
||||
|
||||
let id = window.location.search.split('=')[1];
|
||||
if(!data){
|
||||
|
||||
let cartObj = {};
|
||||
debugger;
|
||||
|
||||
cartObj[$('#skudetailitem').val()] = {
|
||||
name:$('.productname').html(),
|
||||
price:$('.price').html(),
|
||||
quantity:$('#quantity').val(),
|
||||
img:$('.productDetailsMain img').attr('src'),
|
||||
sku:$('#skudetailitem').val()
|
||||
}
|
||||
|
||||
|
||||
addtoCart(cartObj);
|
||||
//$('.cartnumcount').removeClass('d-none').html(1);
|
||||
setLengthCart();
|
||||
|
||||
}else{
|
||||
//if(!data[id]) data['length']++;
|
||||
let name = $('.productname').html();
|
||||
let price = $('.price').html();
|
||||
let quantity = $('#quantity').val();
|
||||
let img = $('.productDetailsMain img').attr('src');
|
||||
let sku = $('#skudetailitem').val();
|
||||
|
||||
|
||||
|
||||
if(data[$('#skudetailitem').val()]){
|
||||
data[$('#skudetailitem').val()] = {
|
||||
name:name,
|
||||
price:price,
|
||||
quantity: parseInt(data[sku].quantity)+parseInt(quantity),
|
||||
img:img,
|
||||
sku:sku
|
||||
}
|
||||
addtoCart(data);
|
||||
}else{
|
||||
data[$('#skudetailitem').val()] = {
|
||||
name:name,
|
||||
price:price,
|
||||
quantity:parseInt(quantity),
|
||||
img:img,
|
||||
sku:sku
|
||||
}
|
||||
addtoCart(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
setLengthCart();
|
||||
|
||||
}
|
||||
|
||||
function addEventListeners(){
|
||||
$('#addtocart').html('Add to cart')
|
||||
$('#addtocart').off().click((e)=>{
|
||||
debugger
|
||||
$('#addtocart').off().click(function (el){
|
||||
window.location.href = '/shopping-cart.html';
|
||||
|
||||
});
|
||||
|
||||
addToCartFun();
|
||||
debugger;
|
||||
toasterHelper('success',"Item added to cart");
|
||||
|
||||
$('#addtocart').html('Go to cart');
|
||||
});
|
||||
|
||||
$('.buynow').off('click').click(async (e)=>{
|
||||
addToCartFun();
|
||||
const res = await COOKIE_HELPER.validateToken();
|
||||
if(!res.response){
|
||||
localStorage.setItem(CART_ADD,true);
|
||||
window.location.href = '/login.html';
|
||||
|
||||
$('.checkoutbtn').find('span').removeClass('d-none');
|
||||
$('.checkoutbtn').find('div').addClass('d-none');
|
||||
return;
|
||||
}
|
||||
window.location.href = '/selectdelivery.html';
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function addtoCart(data){
|
||||
const currData = getCartData();
|
||||
let newData = {...currData,...data};
|
||||
setCartData(newData);
|
||||
}
|
||||
}
|
||||
|
||||
initAddToCart();
|
||||
+665
@@ -0,0 +1,665 @@
|
||||
function initSelectDevlivery() {
|
||||
let editMode = false;
|
||||
let countryId = null;
|
||||
let currencyId = null;
|
||||
let billingInfo = null;
|
||||
let userName = null;
|
||||
|
||||
let orderBtnAction = {
|
||||
removeOrdernowBtn() {
|
||||
$('.ordernowbtn').parent().addClass('d-none');
|
||||
},
|
||||
|
||||
addOrdernowBtn() {
|
||||
$('.ordernowbtn').parent().removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
let addresslistAction = {
|
||||
removeAddressContainer(){
|
||||
$('.addresslist').addClass('d-none');
|
||||
},
|
||||
addAddressContainer(){
|
||||
$('.addresslist').removeClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
let changeAddressBtnAction = {
|
||||
removeChangeAddressBtn() {
|
||||
$('.changeAddressBtn').addClass('d-none');
|
||||
},
|
||||
addChangeAddressBtn() {
|
||||
$('.changeAddressBtn').removeClass('d-none');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let changesaveCancelBtnAction = {
|
||||
removeChangeCancelBtn() {
|
||||
$('.saveanddeliverCanel').addClass('d-none');
|
||||
},
|
||||
addChangeCancelBtn() {
|
||||
$('.saveanddeliverCanel').removeClass('d-none');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
let saveFormLoading = {
|
||||
addSpinner(){
|
||||
$('.saveanddeliver').find('.spinner-border').removeClass('d-none');
|
||||
$('.saveanddeliver').find('span').addClass('d-none');
|
||||
},
|
||||
|
||||
removeSpinner(){
|
||||
$('.saveanddeliver').find('.spinner-border').addClass('d-none');
|
||||
$('.saveanddeliver').find('span').removeClass('d-none');
|
||||
},
|
||||
}
|
||||
let paymentgatewaypageAction = {
|
||||
addPaymentgatewaypage(){
|
||||
$('.paymentgatewaypage').removeClass('d-none');
|
||||
},
|
||||
|
||||
removePaymentgatewaypage(){
|
||||
$('.paymentgatewaypage').addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
let paymentContainerAction = {
|
||||
paymentContainerAdd(){
|
||||
$('.orderslist').parent().removeClass('d-none');
|
||||
},
|
||||
|
||||
paymentContainerRemove(){
|
||||
$('.orderslist').parent().addClass('d-none');
|
||||
}
|
||||
}
|
||||
|
||||
const {phonenumber_errorhandler,addressdes_errorhandler,zipcode_errorhandler,state_errorhandler} = factoryErrorControl();
|
||||
|
||||
function init() {
|
||||
getAddressRes();
|
||||
loadEvents();
|
||||
updateSummaryPriceAdd();
|
||||
// changeAddressBtnAction.removeChangeAddressBtn();
|
||||
|
||||
}
|
||||
|
||||
function removeAllFormError(){
|
||||
phonenumber_errorhandler.removeError();
|
||||
addressdes_errorhandler.removeError();
|
||||
zipcode_errorhandler.removeError();
|
||||
state_errorhandler.removeError();
|
||||
|
||||
$('.errMsgFormEdit').addClass('d-none');
|
||||
$('.errMsgFormEdit').html('');
|
||||
|
||||
}
|
||||
|
||||
async function getAddressRes() {
|
||||
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
|
||||
console.log(cookieRes);
|
||||
const { errorMsg, isError, response } = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getbillinginfo/contactid/${cookieRes.userId}`);
|
||||
|
||||
let res = JSON.parse(response.result);
|
||||
console.log(res, 'befores');
|
||||
res = res[res.length - 1];
|
||||
|
||||
//createBillingForm();
|
||||
|
||||
const {cityid, lobid,organizationname,addressline,cityname,phonenumber,zipcode,name } =res;
|
||||
billingInfo = res;
|
||||
debugger;
|
||||
console.log(res);
|
||||
if (cityid != 0) {
|
||||
$('.addnewAddressContainer').addClass('d-none');
|
||||
$('.detailsAddressBg').removeClass('detailsAddressBg');
|
||||
$('.ordersummaryheader').addClass('detailsAddressBg');
|
||||
$('.displayadress').removeClass('d-none')
|
||||
// $('.addresslist').removeClass('d-none');
|
||||
loadShippingProducts();
|
||||
userName = organizationname;
|
||||
|
||||
setAddressHeader({name:organizationname,phonenumber,addressline,cityname,zipcode});
|
||||
debugger;
|
||||
|
||||
editMode = true;
|
||||
|
||||
|
||||
// adding values
|
||||
|
||||
$('#phonenumber').val(phonenumber);
|
||||
$('#addressdes').val(addressline);
|
||||
$('#zipcode').val(zipcode);
|
||||
debugger;
|
||||
$('.userNamelogin').html(`${userName}`);
|
||||
changeAddressBtnAction.addChangeAddressBtn()
|
||||
getCountryStateCurrency();
|
||||
}else{
|
||||
$('.userNamelogin').html(`${organizationname}`);
|
||||
loadShippingProducts();
|
||||
paymentContainerAction.paymentContainerRemove();
|
||||
getCountryStateCurrency();
|
||||
orderBtnAction.removeOrdernowBtn();
|
||||
$('.detailsAddressBg').removeClass('detailsAddressBg');
|
||||
$('.selectAddress').addClass('detailsAddressBg');
|
||||
}
|
||||
}
|
||||
|
||||
function setAddressHeader({name,phonenumber,addressline,cityname,zipcode}){
|
||||
$('.innerDisplayAddress').html(`${name}-${phonenumber}, ${addressline}, ${cityname} - `);
|
||||
$('.zipcodeAddress').html(`${zipcode}`);
|
||||
|
||||
}
|
||||
|
||||
function checkForm(){
|
||||
|
||||
let number = $('#phonenumber').val();
|
||||
let zipcode = $('#zipcode').val();
|
||||
let state = $('#state').val();
|
||||
let address = $('#addressdes').val();
|
||||
|
||||
let isTrue = false;
|
||||
if(!number || number.length!=10){
|
||||
isTrue = true;
|
||||
phonenumber_errorhandler.addError();
|
||||
}
|
||||
|
||||
if(zipcode.length<6 || zipcode.length>6){
|
||||
isTrue = true;
|
||||
zipcode_errorhandler.addError();
|
||||
}
|
||||
|
||||
if(!state){
|
||||
isTrue = true;
|
||||
state_errorhandler.addError();
|
||||
}
|
||||
|
||||
if(!address){
|
||||
isTrue = true;
|
||||
addressdes_errorhandler.addError();
|
||||
}
|
||||
|
||||
return isTrue;
|
||||
|
||||
|
||||
}
|
||||
|
||||
async function createBillingForm(){
|
||||
debugger;
|
||||
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
|
||||
let { userId, name } = cookieRes;
|
||||
const ctyId = await getCountryId();
|
||||
|
||||
let stateId = parseInt($('#state').val());
|
||||
let payload = {
|
||||
"cityid": stateId,
|
||||
"CityName":$(`[data-id="${stateId}"`).html(),
|
||||
"addressline1": $('#addressdes').val(),
|
||||
|
||||
"OrganizationType": 2,
|
||||
"organizationname": name,
|
||||
//"OrganizationId":,
|
||||
"ContactName": name,
|
||||
"ContactId": userId,
|
||||
"countryname": 'india',
|
||||
"countryid": ctyId,
|
||||
"statename":$(`[data-id="${stateId}"`).html(),
|
||||
"phonenumber": $('#phonenumber').val(),
|
||||
|
||||
"OrganizationId": userId,
|
||||
"currencyid": 2,
|
||||
"taxno": '0',
|
||||
"BillingInfoExists": false,
|
||||
"lobid": 0,
|
||||
"lobname": "IT Products",
|
||||
"gstindetailid": 0,
|
||||
zipcode:$('#zipcode').val()
|
||||
}
|
||||
const res = await API_SERVICES_ACTIONS.postAPIService('apis/v4/bizgaze/crm/address/savebillinginfo', payload);
|
||||
// http://localhost:3088/apis/v4/bizgaze/crm/address/savebillinginfo
|
||||
|
||||
|
||||
setAddressHeader({name,phonenumber:$('#phonenumber').val(),addressline: $('#addressdes').val(),cityname:$(`[data-id="${stateId}"`).html(),zipcode:$('#zipcode').val()});
|
||||
|
||||
return new Promise((reslove,reject) => {
|
||||
reslove(res);
|
||||
})
|
||||
console.log(res);
|
||||
}
|
||||
|
||||
async function saveForm() {
|
||||
|
||||
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
|
||||
let { userId, name } = cookieRes;
|
||||
const { errorMsg, isError, response } = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getbillinginfo/contactid/${cookieRes.userId}`);
|
||||
|
||||
let resAnwi = JSON.parse(response.result);
|
||||
console.log(resAnwi, 'befores');
|
||||
resAnwi = resAnwi[resAnwi.length - 1];
|
||||
|
||||
let stateId = parseInt($('#state').val());
|
||||
let payload = {
|
||||
...resAnwi,
|
||||
phonenumber:$('#phonenumber').val(),
|
||||
addressline1:$('#addressdes').val(),
|
||||
zipcode:$('#zipcode').val(),
|
||||
cityid:stateId,
|
||||
CityName:$(`[data-id="${stateId}"`).html(),
|
||||
|
||||
}
|
||||
|
||||
console.log(payload,"ertyuioghjkl");
|
||||
|
||||
|
||||
|
||||
//
|
||||
const res = await API_SERVICES_ACTIONS.postAPIService('apis/v4/bizgaze/crm/address/savebillinginfo', payload);
|
||||
|
||||
return new Promise((reslove,reject) => {
|
||||
reslove(res);
|
||||
})
|
||||
}
|
||||
|
||||
async function loadEvents() {
|
||||
$('.addnewAddressContainer').off('click').click(function (e) {
|
||||
$('.addnewAddressContainer').addClass('d-none');
|
||||
$('.addresslist').removeClass('d-none');
|
||||
changeAddressBtnAction.removeChangeAddressBtn();
|
||||
changesaveCancelBtnAction.addChangeCancelBtn();
|
||||
|
||||
});
|
||||
|
||||
$('.saveanddeliverCanel').off('click').click(function (){
|
||||
if(!editMode){
|
||||
$('.addnewAddressContainer').removeClass('d-none');
|
||||
$('.addresslist').addClass('d-none');
|
||||
changeAddressBtnAction.removeChangeAddressBtn();
|
||||
changesaveCancelBtnAction.removeChangeCancelBtn();
|
||||
}else{
|
||||
loadShippingProducts();
|
||||
addresslistAction.removeAddressContainer()
|
||||
changeAddressBtnAction.addChangeAddressBtn();
|
||||
paymentContainerAction.paymentContainerAdd();
|
||||
$('.displayadress').removeClass('d-none');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$('.saveanddeliver').off('click').click(async function (e) {
|
||||
|
||||
saveFormLoading.addSpinner()
|
||||
let isErrorForm = checkForm();
|
||||
|
||||
if(isErrorForm){
|
||||
saveFormLoading.removeSpinner();
|
||||
return;
|
||||
}
|
||||
let res;
|
||||
if(editMode){
|
||||
res = await saveForm();
|
||||
}else{
|
||||
res = createBillingForm();
|
||||
}
|
||||
saveFormLoading.removeSpinner();
|
||||
|
||||
|
||||
const {isError,errorMsg,response} = res;
|
||||
console.log(errorMsg);
|
||||
if(isError){
|
||||
|
||||
$('.errMsgFormEdit').removeClass('d-none');
|
||||
$('.errMsgFormEdit').html(`${errorMsg.message}`);
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
debugger;
|
||||
editMode = true;
|
||||
let {name} = COOKIE_HELPER.getCookie();
|
||||
// phonenumber:$('#phonenumber').val(),
|
||||
// addressline1:$('#addressdes').val(),
|
||||
// zipcode:$('#zipcode').val(),
|
||||
// cityid:stateId,
|
||||
// CityName:$(`[data-id="${stateId}"`).html(),
|
||||
let stateId = parseInt($('#state').val());
|
||||
setAddressHeader({name,addressline:$('#addressdes').val(),cityname:$(`[data-id="${stateId}"`).html(),phonenumber:$('#phonenumber').val(),zipcode:$('#zipcode').val()});
|
||||
|
||||
|
||||
$('.errMsgFormEdit').html('');
|
||||
loadShippingProducts();
|
||||
addresslistAction.removeAddressContainer()
|
||||
changeAddressBtnAction.addChangeAddressBtn();
|
||||
paymentContainerAction.paymentContainerAdd();
|
||||
$('.displayadress').removeClass('d-none');
|
||||
|
||||
|
||||
});
|
||||
$('.changeAddressBtn').off('click').click(function (e){
|
||||
console.log(e.target);
|
||||
removeOrderSummary();
|
||||
changeAddressBtnAction.removeChangeAddressBtn();
|
||||
$('.displayadress').addClass('d-none')
|
||||
})
|
||||
|
||||
$('.ordernowbtn').off().click(async function (e){
|
||||
let cookieRes = COOKIE_HELPER_ACTIONS.getCookie();
|
||||
let { userId, name } = cookieRes;
|
||||
|
||||
paymentgatewaypageAction.addPaymentgatewaypage();
|
||||
let payload = {
|
||||
"OrganizationName": name,
|
||||
"BranchId": 106632280000001,
|
||||
"OrderItems": [
|
||||
{
|
||||
"UnitPrice": 20,
|
||||
"Quantity": 1,
|
||||
"SKU": "11",
|
||||
"DiscountValue": 0,
|
||||
"DiscountPercent": 0
|
||||
}
|
||||
]
|
||||
}
|
||||
$('.paymentgatewaypage').removeClass('d-none');
|
||||
const data = getCartData();
|
||||
|
||||
let orderItems = [];
|
||||
for(let i in data){
|
||||
const {price,quantity,sku} = data[i];
|
||||
let payload = {
|
||||
"UnitPrice": price,
|
||||
"Quantity": quantity,
|
||||
"SKU": sku,
|
||||
"DiscountValue": 0,
|
||||
"DiscountPercent": 0
|
||||
}
|
||||
orderItems.push(payload)
|
||||
}
|
||||
|
||||
payload['OrderItems'] = orderItems;
|
||||
|
||||
debugger;
|
||||
try {
|
||||
const res = await API_SERVICES_ACTIONS.postAPIService(`apis/v4/bizgaze/integrations/salesorder/save`,payload);
|
||||
console.log(res.response.result);;
|
||||
|
||||
if(!res.response.result){
|
||||
paymentgatewaypageAction.removePaymentgatewaypage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// `http://localhost:3088/apis/v4/bizgaze/transact/orders/getpaymentgatewaytransaction/refid/106633780000069`
|
||||
|
||||
let response = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/transact/orders/getpaymentgatewaytransaction/refid/${res.response.result}`);
|
||||
let {PaymentLink} = JSON.parse(response.response.result);
|
||||
window.location.href = PaymentLink;
|
||||
} catch (error) {
|
||||
paymentgatewaypageAction.removePaymentgatewaypage();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function getItemProductHTML(item) {
|
||||
const { img, name, price, quantity, sku, id } = item;
|
||||
|
||||
return ` <div class="align-items-center item-product-add d-flex justify-content-between" data-id="${id}" data-sku="${sku}">
|
||||
<div style="max-width: 100px;" class="">
|
||||
<img class="w-100" src="${img}" alt="">
|
||||
</div>
|
||||
<div>
|
||||
<div>
|
||||
<div style="font-size:12px">${name}</div>
|
||||
</div>
|
||||
<div>
|
||||
<span style="font-size:12px" class="font-weight-600">${getCurrencySymbol(price)}</span> <span>x <span class="qtyitem" style="font-size:12px">${quantity}</span></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
return ` <div class="item-product-add" data-id="${id}" data-sku="${sku}">
|
||||
<div class="row py-2">
|
||||
<div class="col-sm-2">
|
||||
<div class="w-100 d-flex justify-content-around">
|
||||
<div class="d-flex flex-column align-items-baseline">
|
||||
<div class="px-4 py-2 selectaddressimgshow">
|
||||
<img class="w-100" src="${img}" alt="" class="w-100">
|
||||
</div>
|
||||
<div class="addresscontrol w-100 d-flex justify-content-center gap-1">
|
||||
<div class="rounded-contain btnminus">
|
||||
-
|
||||
</div>
|
||||
<div class="w-100p">
|
||||
<input class="qtyshowinput" disabled value="${quantity}" type="number">
|
||||
</div>
|
||||
<div class="rounded-contain btnplus">
|
||||
+
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-10">
|
||||
<div class="row h-100">
|
||||
<div class="col-sm-8">
|
||||
<div class="h-100 d-flex flex-column justify-content-between">
|
||||
<div> ${name}</div>
|
||||
<div>
|
||||
<span>$</span> ${price} <span class="d-none">56% Off 2 offers applied</span>
|
||||
</div>
|
||||
<div class="d-flex gap-3">
|
||||
<span class="text-uppercase d-none">Save for later</span>
|
||||
<span class="text-uppercase cursor-pointer removecartItem">Remove</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
async function getCountryId(){
|
||||
const countryRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcountry');;
|
||||
|
||||
if (countryRes.isError) {
|
||||
alert("something went wrong");
|
||||
console.log(countryRes);
|
||||
return;
|
||||
}
|
||||
|
||||
let ctyId = 0
|
||||
let countryData = JSON.parse(countryRes.response.result);
|
||||
|
||||
console.log(countryData);
|
||||
|
||||
for (let i = 0; i < countryData.length; i++) {
|
||||
if (countryData[i].countryname.toLowerCase() === 'india') {
|
||||
countryId = countryData[i].countryid;
|
||||
ctyId = countryId
|
||||
countrynameData = countryData[i].countryname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ctyId;
|
||||
|
||||
}
|
||||
|
||||
async function getCountryStateCurrency() {
|
||||
const countryRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcountry');;
|
||||
|
||||
if (countryRes.isError) {
|
||||
alert("something went wrong");
|
||||
console.log(countryRes);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let countryData = JSON.parse(countryRes.response.result);
|
||||
|
||||
console.log(countryData);
|
||||
|
||||
for (let i = 0; i < countryData.length; i++) {
|
||||
if (countryData[i].countryname.toLowerCase() === 'india') {
|
||||
countryID = countryData[i].countryid;
|
||||
countrynameData = countryData[i].countryname;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
const stateRes = await API_SERVICES_ACTIONS.getAPIService(`apis/v4/bizgaze/integrations/products/getcities/countryid/${countryID}`);
|
||||
|
||||
if (stateRes.isError) {
|
||||
alert("something went wrong");
|
||||
console.log(stateRes);
|
||||
return;
|
||||
}
|
||||
|
||||
let stateData = JSON.parse(stateRes.response.result);
|
||||
|
||||
console.log(stateData, 'state');
|
||||
|
||||
|
||||
$('#state').html('');
|
||||
console.log("start")
|
||||
let html = '';
|
||||
statesList = stateData;
|
||||
for (let i = 0; i < stateData.length; i++) {
|
||||
html += `<option value="${stateData[i].cityid}" data-id="${stateData[i].cityid}">${stateData[i].cityname}</option>`
|
||||
|
||||
}
|
||||
|
||||
$('#state').append(html);
|
||||
|
||||
$("#state").select2({
|
||||
placeholder: "Select a City",
|
||||
allowClear: true
|
||||
});
|
||||
|
||||
const currencyRes = await API_SERVICES_ACTIONS.getAPIService('apis/v4/bizgaze/integrations/products/getcurrencies');
|
||||
|
||||
if(currencyRes.isError){
|
||||
alert("something went wrong");
|
||||
console.log(currencyRes);
|
||||
return;
|
||||
}
|
||||
|
||||
let currencyData = JSON.parse(currencyRes.response.result);
|
||||
|
||||
console.log(currencyData,'currencyDatacurrencyDatacurrencyData');
|
||||
|
||||
for(let i=0;i<currencyData.length;i++){
|
||||
const curr = currencyData[i];
|
||||
if(curr.currencyname.toLowerCase().includes('india')){
|
||||
currencyid = curr.currencyid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function loadShippingProducts(){
|
||||
$('.detailsAddressBg').removeClass('detailsAddressBg');
|
||||
$('.ordersummaryheader ').addClass('detailsAddressBg')
|
||||
debugger;
|
||||
const products = getCartData();
|
||||
console.log(products);
|
||||
if (Object.keys(products||{}).length) orderBtnAction.addOrdernowBtn();
|
||||
|
||||
let productsHTML = '';
|
||||
for (let item in products) {
|
||||
const currItem = products[item];
|
||||
productsHTML += getItemProductHTML({ ...currItem, id: item })
|
||||
}
|
||||
$('.orderlistcart').html(productsHTML);
|
||||
// $('.orderslist').html(productsHTML);
|
||||
$('.orderslist').html(` <label for="online">
|
||||
Online
|
||||
<input checked data-op="online" name="payment" type="radio" class="paymentbtn " id="online">
|
||||
</label>
|
||||
<label for="cod">
|
||||
Cash on develiop
|
||||
<input data-op="cod" name="payment" type="radio" class="paymentbtn " id="cod">
|
||||
</label>`);
|
||||
|
||||
$('.paymentbtn').off().click(function (e){
|
||||
const data = $(e.target).data('op');
|
||||
if(data == 'online'){
|
||||
orderBtnAction.addOrdernowBtn();
|
||||
}else{
|
||||
orderBtnAction.removeOrdernowBtn();
|
||||
}
|
||||
})
|
||||
$('.btnminus').each(function (i, el) {
|
||||
$(el).off().click(function (elm) {
|
||||
let id = $(elm.target).parents('.item-product-add').data('id');
|
||||
let val = parseInt($(elm.target).parents('.item-product-add').find('.qtyshowinput').val());
|
||||
if (val <= 1) return;
|
||||
val--;
|
||||
updateCartQuantity(id, val)
|
||||
$(elm.target).parents('.item-product-add').find('.qtyshowinput').val(val)
|
||||
});
|
||||
})
|
||||
$('.btnplus').each(function (i, el) {
|
||||
$(el).off().click(function (elm) {
|
||||
let id = $(elm.target).parents('.item-product-add').data('id');
|
||||
let val = parseInt($(elm.target).parents('.item-product-add').find('.qtyshowinput').val());
|
||||
if (val >= 11) return;
|
||||
val++;
|
||||
updateCartQuantity(id, val)
|
||||
$(elm.target).parents('.item-product-add').find('.qtyshowinput').val(val);
|
||||
});
|
||||
})
|
||||
$('.removecartItem').each(function (i, el) {
|
||||
$(el).click(function (elm) {
|
||||
let id = $(elm.target).parents('.item-product-add').data('id');
|
||||
|
||||
let len = removeCartItem(id);
|
||||
$(`.item-product-add[data-id="${id}"]`).remove();
|
||||
if (!len) {
|
||||
orderBtnAction.removeOrdernowBtn();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function removeOrderSummary(){
|
||||
$('.detailsAddressBg').removeClass('detailsAddressBg');
|
||||
$('.selectAddress').addClass('detailsAddressBg');
|
||||
$('.orderslist').html('');
|
||||
orderBtnAction.removeOrdernowBtn();
|
||||
|
||||
// $('.detailsAddressBtn').addClass('d-none');
|
||||
addresslistAction.addAddressContainer();
|
||||
$('.saveanddeliver').removeClass('d-none');
|
||||
$('.saveanddeliverCanel').removeClass('d-none')
|
||||
}
|
||||
|
||||
function factoryErrorControl(){
|
||||
let inputsArr = ['phonenumber','addressdes','zipcode','state'];
|
||||
|
||||
let controls = {};
|
||||
for(let i=0;i<inputsArr.length;i++){
|
||||
const id =inputsArr[i];
|
||||
|
||||
controls[`${id}_errorhandler`] = {
|
||||
addError(){
|
||||
debugger;
|
||||
$(`#${id}`).parents('.col-sm-6').find('.invalid-feedback').addClass('d-block');
|
||||
},
|
||||
removeError(){
|
||||
$(`#${id}`).parents('.col-sm-6').find('.invalid-feedback').addClass('d-block');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return controls;
|
||||
}
|
||||
|
||||
init();
|
||||
|
||||
}
|
||||
|
||||
checkValidAuth(initSelectDevlivery);
|
||||
Vendored
+228
@@ -0,0 +1,228 @@
|
||||
shoppingCartInit();
|
||||
|
||||
debugger;
|
||||
function shoppingCartInit() {
|
||||
|
||||
shoppingCartAppend();
|
||||
|
||||
function shoppingCartAppend() {
|
||||
let data = getCartData();
|
||||
|
||||
if (!data) {
|
||||
$('.emptyShow').removeClass('d-none');
|
||||
$('.checkoutbtn').addClass('d-none');
|
||||
return;
|
||||
};
|
||||
|
||||
let html = '';
|
||||
let products = data;
|
||||
|
||||
|
||||
|
||||
// for(let i=0;i<products.length;i++){
|
||||
// const {img,name,price,quantity,total} = products[i];
|
||||
// debugger;
|
||||
// html += shoppingCartDesktopHTML(products[i]);
|
||||
// }
|
||||
if(Object.keys(data).length === 0) {
|
||||
$('.checkoutbtn').addClass('d-none');
|
||||
$('.emptyShow').removeClass('d-none');
|
||||
}
|
||||
setLengthCart();
|
||||
for (let product in products) {
|
||||
|
||||
html += shoppingCartDesktopHTML({ ...products[product], total: products[product].quantity * products[product].price, id: product });
|
||||
}
|
||||
|
||||
$('.appendItems').html(html);
|
||||
|
||||
|
||||
addEventListenerCart();
|
||||
|
||||
}
|
||||
|
||||
// event listeners
|
||||
function addEventListenerCart() {
|
||||
|
||||
$('.quantitySelect').each(function (i, element) {
|
||||
if (!$(element).hasClass('d-none')) {
|
||||
$(element).off().change(function (e) {
|
||||
let num = e.target.value;
|
||||
if (num == 5) {
|
||||
$(e.target).parents('.mainselectcontainer').find('.inputcartaddmore').removeClass('d-none');
|
||||
$(e.target).addClass('d-none');
|
||||
$(e.target).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) {
|
||||
const val = $(item.target).parent().find('input').val()
|
||||
let id = $(item.target).parents('.mainselectcontainer').data('id');
|
||||
updateCartQuantity(id, val);
|
||||
// $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none');
|
||||
// $(e.target).removeClass('d-none');
|
||||
setLengthCart();
|
||||
shoppingCartAppend();
|
||||
|
||||
})
|
||||
} else {
|
||||
let id = $(e.target).parents('.mainselectcontainer').data('id');
|
||||
updateCartQuantity(id, num);
|
||||
setLengthCart();
|
||||
shoppingCartAppend();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
$(element).parents('.mainselectcontainer').find('.inputcartaddmore button').off().click(function (item) {
|
||||
const val = $(item.target).parent().find('input').val()
|
||||
let id = $(item.target).parents('.mainselectcontainer').data('id');
|
||||
updateCartQuantity(id, val);
|
||||
// $(item.target).parents('.mainselectcontainer').find('.inputcartaddmore').addClass('d-none');
|
||||
// $(e.target).removeClass('d-none');
|
||||
setLengthCart();
|
||||
shoppingCartAppend();
|
||||
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
$('.btndeletecart').each(function (i, element) {
|
||||
$(element).click(function (e) {
|
||||
const cardId = $(e.target).data('cartid');
|
||||
let data = getCartData();
|
||||
console.log(data, 'cardId', cardId);
|
||||
if (!data) return;
|
||||
debugger;
|
||||
const products = data;
|
||||
const productsFilter = {};
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
$('.checkoutbtn').click(async function (e){
|
||||
$('.checkoutbtn').find('span').addClass('d-none');
|
||||
$('.checkoutbtn').find('div').removeClass('d-none');
|
||||
const res = await COOKIE_HELPER.validateToken();
|
||||
if(!res.response){
|
||||
localStorage.setItem(CART_ADD,true);
|
||||
window.location.href = '/login.html';
|
||||
|
||||
$('.checkoutbtn').find('span').removeClass('d-none');
|
||||
$('.checkoutbtn').find('div').addClass('d-none');
|
||||
return;
|
||||
}
|
||||
window.location.href = '/selectdelivery.html';
|
||||
$('.checkoutbtn').find('span').removeClass('d-none');
|
||||
$('.checkoutbtn').find('div').addClass('d-none');
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function getQuantityHTML(value, id) {
|
||||
return `<div data-id="${id}" class="mainselectcontainer w-100">
|
||||
<div class="w-100">
|
||||
<label>Qty</label>
|
||||
<select class="quantitySelect form-select ${value >= 5 ? 'd-none' : ''}" value="${value}">
|
||||
<option ${value == 1 ? 'selected="selected"' : null} value="1">
|
||||
1
|
||||
</option>
|
||||
<option ${value == 2 ? 'selected="selected"' : null} value="2">
|
||||
2
|
||||
</option>
|
||||
<option ${value == 3 ? 'selected="selected"' : null} value="3">
|
||||
3
|
||||
</option>
|
||||
<option ${value == 4 ? 'selected="selected"' : null} value="4">
|
||||
4
|
||||
</option>
|
||||
<option ${value == 5 ? 'selected="selected"' : null} value="5">
|
||||
5+
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class=" inputcartaddmore d-flex gap-2 ${value >= 5 ? '' : 'd-none'}">
|
||||
<input min="1" class="form-control" style="max-width:100px" value="${value <= 5 ? '5' : value}" type="number" />
|
||||
<button class="btn border-none bg-info">Add</button>
|
||||
</div>
|
||||
|
||||
</div>`
|
||||
}
|
||||
|
||||
function shoppingCartDesktopHTML({ id, img, name, price, description, quantity, total }) {
|
||||
const [currencySymbol,amt] = getCurrencySymbol(price);
|
||||
return `
|
||||
<div class="row bg-white mt-3 rounded py-3 d-flex ">
|
||||
<div class="col-md-2 text-center"><img src="${img}" alt="${name}" class="img-fluid"></div>
|
||||
<div class="col-md-4 d-flex justify-content-center align-items-center">
|
||||
|
||||
<a class="text-decoration-none text-dark cursor-pointer" href="/productdetails.html?productId=${id}">${name}</a>
|
||||
<small>${description||''}</small>
|
||||
<span class="badge d-none text-bg-warning">8 Offers ></span>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex justify-content-center align-items-center">
|
||||
<p class="text-right"><span>${currencySymbol}</span> ${amt}</p>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex justify-content-center align-items-center">
|
||||
|
||||
${getQuantityHTML(quantity, id)}
|
||||
</div>
|
||||
<div class="col-md-2 d-flex justify-content-center align-items-center">
|
||||
<div class="d-flex justify-content-between w-100">
|
||||
<p class="fw-bold"><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" data-cartid="${id}">x</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="warrenty-sec px-3 sec-space-4 d-none">
|
||||
<div class="row align-items-center border
|
||||
py-2 mx-4">
|
||||
<div class="col-md-8">
|
||||
<p class="mb-0"> <img src="./dist/assets/imgs/Home/Anwi-cart-logo.png" alt="shopping-cart-item-img"> Anwi Extended Warranty 2 Year: Protect your Laptop for another 2 years Learn more </p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<p class="text-end mb-0"> ₹3,200 (2 year)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-center border
|
||||
py-2 mx-4 mt-3">
|
||||
<div class="col-md-8">
|
||||
<p class="mb-0"> <img src="./dist/assets/imgs/Home/Anwi-cart-logo-2.png" alt="shopping-cart-item-img"> Anwi Extended Warranty 2 Year: Protect your Laptop for another 2 years Learn more </p>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<p class="text-end mb-0"> ₹2,900 (2 year)
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class=" bg-white mt-3 rounded py-3 d-block d-sm-none ">
|
||||
<div class="row">
|
||||
<div class=""></div>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
Vendored
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
|
||||
const uid = function(){
|
||||
return Date.now().toString(36) + Math.random().toString(36).substr(2);
|
||||
}
|
||||
|
||||
function getCurrencySymbol(value=0) {
|
||||
let type = 'INR'
|
||||
if (type) {
|
||||
const ans = new Intl.NumberFormat('en-US', { style: 'currency', currency: type }).format(value);;
|
||||
const res = ans.split(/(\D+)/);
|
||||
const currencySymbol = res[1];
|
||||
const amount = res.slice(2,res.length).join('')
|
||||
|
||||
|
||||
return [currencySymbol,amount]
|
||||
} else {
|
||||
console.log("errrrrrrrrrrrrrrrrrrrrrrrrr",type);
|
||||
return ['',0];
|
||||
}
|
||||
}
|
||||
|
||||
function toasterHelper(type,message){
|
||||
// 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"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user