Gustavo Luigi 2022-09-01 20:07:45 +02:00
parent 75fb350e2e
commit 07338e08f5
1 changed files with 11 additions and 11 deletions

View File

@ -96,8 +96,8 @@
</table> </table>
</div> </div>
<div class="col-12"> <div class="col-12">
<a href="" id="cart-link" style="color: var(--bs-link-color);"></a> <a href="" class="cart-link text-primary"></a>
<button id="btn-share">Share</button> <button class="btn-share">Share</button>
</div> </div>
</div> </div>
</div> </div>
@ -170,8 +170,8 @@
if(typeof updateProducts === "function") $('#list-products').html(''); if(typeof updateProducts === "function") $('#list-products').html('');
totalPrice = 0; totalPrice = 0;
if(objProducts.length > 0) { if(objProducts.length > 0) {
$('#cart-link').show(); $('.cart-link').show();
$("#btn-share").show(); $(".btn-share").show();
let ids = objProducts.map(obj => obj.id); let ids = objProducts.map(obj => obj.id);
$.get($('meta[name="get-contents"]').attr('content')+"/"+ids.join(","), function(response, status){ $.get($('meta[name="get-contents"]').attr('content')+"/"+ids.join(","), function(response, status){
response.contents.forEach(function(item){ response.contents.forEach(function(item){
@ -225,8 +225,8 @@
$('#total-checkout-price').parent().parent().parent().hide(); $('#total-checkout-price').parent().parent().parent().hide();
$('#no-products-in-checkout').show(); $('#no-products-in-checkout').show();
} }
$('#cart-link').hide(); $('.cart-link').hide();
$("#btn-share").hide(); $(".btn-share").hide();
} }
$('#total-price').text(formatter.format(totalPrice)); $('#total-price').text(formatter.format(totalPrice));
let productId = $('meta[name="product-id"]').attr('content'); let productId = $('meta[name="product-id"]').attr('content');
@ -302,20 +302,20 @@
let url = null; let url = null;
if(window.location.origin == 'http://localhost') url = window.location.origin+'/areya-energy/public/'+btoa(JSON.stringify(objProducts)); if(window.location.origin == 'http://localhost') url = window.location.origin+'/areya-energy/public/'+btoa(JSON.stringify(objProducts));
else url = window.location.origin+'/'+btoa(JSON.stringify(objProducts)); else url = window.location.origin+'/'+btoa(JSON.stringify(objProducts));
$('#cart-link').attr('href', url); $('.cart-link').attr('href', url);
$('#cart-link').text(url); $('.cart-link').text(url);
const shareData = { const shareData = {
title: "Share cart list", title: "Share cart list",
text: 'share cart list', text: 'share cart list',
url: url, url: url,
}; };
$("#btn-share").click(async function() { $(".btn-share").click(async function() {
if(navigator.share) { try { await navigator.share(shareData); } catch(err) { console.warn(err); } } if(navigator.share) { try { await navigator.share(shareData); } catch(err) { console.warn(err); } }
else { console.warn('Native Web Sharing not supported'); } else { console.warn('Native Web Sharing not supported'); }
}); });
}else{ }else{
$('#cart-link').hide(); $('.cart-link').hide();
$("#btn-share").hide(); $(".btn-share").hide();
} }
}); });
</script> </script>