* New module structure (refactoring) * Simple serializer and deserializer with models, new architecture * Move logic to strategies * Partial api client facade implementation (full implementation is not necessary for now) * Loyalty feature installer * Sms verification order (#167) * Make updater self-sufficient * Fix for order submit & fix for incorrect component rendering in the constructor * Fix for loyalty personal area error handling * Fix for cart component identity * Fix for softlock when customer cannot be registered in loyalty Co-authored-by: Сергей Чазов <45812598+Chazovs@users.noreply.github.com> Co-authored-by: Sergey Chazov <oitv18@gmail.com>
60 lines
1.7 KiB
JavaScript
60 lines
1.7 KiB
JavaScript
function getTimeRemaining(endtime) {
|
|
return Date.parse(endtime) - Date.parse(new Date());
|
|
}
|
|
|
|
function initializeClock(id, endtime) {
|
|
$('#countdownDiv').show();
|
|
$('#deadlineMessage').hide();
|
|
|
|
const timeInterval = setInterval(updateClock, 1000);
|
|
const clock = document.getElementById(id);
|
|
|
|
function updateClock() {
|
|
const time = getTimeRemaining(endtime);
|
|
|
|
if (time <= 0) {
|
|
$('#countdownDiv').hide();
|
|
$('#deadlineMessage').show();
|
|
clearInterval(timeInterval);
|
|
return true;
|
|
}
|
|
|
|
clock.innerText = String(time).slice(0, -3);
|
|
}
|
|
|
|
updateClock();
|
|
}
|
|
|
|
function resendRegisterSms(idInLoyalty) {
|
|
BX.ajax.runAction('intaro:retailcrm.api.loyalty.register.resendRegisterSms',
|
|
{
|
|
data: {
|
|
sessid: BX.bitrix_sessid(),
|
|
idInLoyalty: idInLoyalty
|
|
}
|
|
}
|
|
).then(function(response) {
|
|
$('#lpRegMsg').text(response.data.msg);
|
|
$('#checkIdField').val(response.data.form.fields.checkId.value);
|
|
initializeClock("countdown", response.data.resendAvailable);
|
|
});
|
|
}
|
|
|
|
function resendOrderSms(orderId) {
|
|
BX.ajax.runAction('intaro:retailcrm.api.loyalty.order.resendOrderSms',
|
|
{
|
|
data: {
|
|
sessid: BX.bitrix_sessid(),
|
|
orderId: orderId
|
|
}
|
|
}
|
|
).then(function(response) {
|
|
if (response.data.msg !== undefined) {
|
|
$('#msg').text(response.data.msg);
|
|
} else if (response.data.resendAvailable !== undefined) {
|
|
$('#checkIdVerify').val(response.data.checkId);
|
|
initializeClock("countdown", new Date(response.data.resendAvailable.date));
|
|
}
|
|
});
|
|
}
|