add share cart link

master
Gustavo Luigi 2022-09-01 19:53:06 +02:00
parent a1a38350f3
commit 5f79d45b5b
1 changed files with 18 additions and 0 deletions

View File

@ -95,6 +95,10 @@
</tfoot>
</table>
</div>
<div class="col-12">
<a href="" id="cart-link" style="color: var(--bs-link-color);"></a>
<button id="btn-share">Share</button>
</div>
</div>
</div>
<div class="modal-footer">
@ -290,6 +294,20 @@
objProducts[index].quantity = quantity;
updateProductsInLocalStorage();
});
let url = null;
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));
$('#cart-link').attr('href', url);
$('#cart-link').text(url);
const shareData = {
title: "Share cart list",
text: 'share cart list',
url: url,
};
$("#btn-share").click(async function() {
if(navigator.share) { try { await navigator.share(shareData); } catch(err) { console.warn(err); } }
else { console.warn('Native Web Sharing not supported'); }
});
});
</script>
@yield('scripts')