<style>
body {
&::after {
content: '';
position: absolute;
z-index: 6;
top: 50%;
left: 50%;
margin-left: -24px;
margin-top: -24px;
width: 48px;
height: 48px;
border-radius: 50%;
display: inline-block;
border-top: 3px solid #999;
border-right: 3px solid transparent;
box-sizing: border-box;
animation: rotation 1s linear infinite;
}
&::before {
content: '';
width: 100%;
height: 100%;
top: 0;
left: 0;
position: absolute;
background-color: white;
z-index: 5;
border-radius: 10px;
}
}
</style>
<form id="form" action="{{ Urls.FullBaseUrl }}/web-api/v1/Shopping/Basket/CheckoutRedirect" method="post" style="display:none;">
<input type="hidden" name="BasketID" id="BasketID" value="" />
<input type="hidden" name="CustomerID" id="CustomerID" value="" />
<button type="submit">
enviar
</button>
</form>
<script>
try {
(async function() {
var urlParams = new URLSearchParams(window.location.search);
var
BasketID = Number(urlParams.get('BasketID')),
CustomerID = Number(urlParams.get('CustomerID')),
h = urlParams.get('h');
localStorage.setItem('queryBasketID', BasketID);
localStorage.setItem('queryCustomerID', CustomerID);
document.getElementById('BasketID').value = BasketID;
document.getElementById('CustomerID').value = CustomerID;
var basketsIds = JSON.parse(localStorage.getItem('basketsIds')) || [];
if (basketsIds?.includes(BasketID) === false) {
const response = await fetch('/Logout/SignOut', {
method: 'GET',
credentials: 'include'
});
if (!response.ok) {
throw new Error(`Erro HTTP: ${response.status}`);
}
const data = await response.json().catch(() => null);
console.log('Logout OK', data);
}
basketsIds.push(BasketID);
localStorage.setItem('basketsIds', JSON.stringify(basketsIds));
if (h != null) {
const
d = window.atob(h),
o = JSON.parse(d);
BasketID = o.BasketID;
CustomerID = o.CustomerID;
}
function deleteCookies(domain) {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
var eqPos = cookie.indexOf('=');
var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
var cookieDomain = document.domain;
if (cookieDomain.endsWith(domain)) {
document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
}
}
}
deleteCookies(".{{ Urls.FullBaseUrl | replace: 'https://', '' }}");
document.getElementById('form').submit();
})();
} catch (e) {
console.log(e);
}
</script> |