1
0
mirror of synced 2024-11-23 22:06:11 +03:00
bitrix-module/intaro.retailcrm/install/export/bitrix/js/intaro/sms.js
Сергей Чазов 34e8105583
Loyalty (#241)
* Loyalty program
* fix dot bug for shops-exoprt option
* delete credantials request from services
* add CurlException for credentials catch
* add catching CurlException
* edit error msgs
* add supportind double bonuses
* add any step for bonus-input field in sale.order.ajax template
* recalculate bonuses
* fix bonus rounded
* strtoupper for params in icml
* change delivery service code
2022-03-02 15:40:53 +03:00

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));
}
});
}