fix: nfc not working with jade
This commit is contained in:
@@ -207,29 +207,19 @@ document.addEventListener('DOMContentLoaded', function () {
|
|||||||
const paymentCards = document.querySelectorAll('.payment-card:not(.disabled)');
|
const paymentCards = document.querySelectorAll('.payment-card:not(.disabled)');
|
||||||
const cancelButton = document.querySelector('.btn-cancel');
|
const cancelButton = document.querySelector('.btn-cancel');
|
||||||
|
|
||||||
$('#read_modal').hide();
|
// $('#read_modal').hide();
|
||||||
$('.modal-backdrop.fade').css('display', 'none');
|
// $('.modal-backdrop.fade').css('display', 'none');
|
||||||
|
|
||||||
$('#read_nfc').on('hide.bs.modal', function() {
|
|
||||||
$('#payment_modal').css('display', 'none');
|
|
||||||
$('.modal-backdrop.fade').css('display', 'none');
|
|
||||||
});
|
|
||||||
|
|
||||||
$("#read_nfc").on('click', function() {
|
|
||||||
$('#payment_modal').css('display', 'none');
|
|
||||||
$('.modal-backdrop.fade').css('display', 'none');
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
cancelButton.addEventListener('click', function () {
|
cancelButton.addEventListener('click', function () {
|
||||||
|
alert('cancel click');
|
||||||
console.log("Action: Cancel payment.");
|
console.log("Action: Cancel payment.");
|
||||||
|
|
||||||
paymentCards.forEach(c => c.classList.remove('active'));
|
paymentCards.forEach(c => c.classList.remove('active'));
|
||||||
|
$('.payment-card').css('display', 'none');
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const disabledNfcCard = document.querySelector('.payment-card.disabled');
|
|
||||||
|
|
||||||
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
|
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
|
||||||
initDynamicQrPay();
|
initDynamicQrPay();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -518,7 +518,86 @@
|
|||||||
</div>
|
</div>
|
||||||
<%= render "read_modal" %>
|
<%= render "read_modal" %>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script defer type="text/javascript">
|
||||||
|
|
||||||
|
// nfc scan
|
||||||
|
$("#read_modal").on('shown.bs.modal', function() {
|
||||||
|
$('#payment_modal').css('display', 'none');
|
||||||
|
})
|
||||||
|
|
||||||
|
$("#read_nfc").on('click', function() {
|
||||||
|
$('#payment_modal').hide();
|
||||||
|
|
||||||
|
$('#payment_modal').css('display', 'none');
|
||||||
|
$('.modal-backdrop.fade').css('display', 'none');
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#read_modal").on('shown.bs.modal', function() {
|
||||||
|
$('#payment_modal').css('display', 'none');
|
||||||
|
$('#payment_modal').hide();
|
||||||
|
$("#read_modal").attr('data-for', 'member');
|
||||||
|
|
||||||
|
// alert('show read nfc modal');
|
||||||
|
var sale_id = $('#sale_id').text();
|
||||||
|
|
||||||
|
getCardNo();
|
||||||
|
|
||||||
|
onScan.attachTo(document, {
|
||||||
|
onScan: function (sCode) {
|
||||||
|
setCardNo(sCode);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// qr pay
|
||||||
|
document.querySelector('.payment-card#dynamic_qr').addEventListener('click', function() {
|
||||||
|
initDynamicQrPay();
|
||||||
|
});
|
||||||
|
|
||||||
|
function initDynamicQrPay() {
|
||||||
|
const paymentMethod = 'MMQR';
|
||||||
|
const $serverMode = $('#server_mode');
|
||||||
|
const $createOrderBtn = $('#create_order');
|
||||||
|
const $createPayOrderBtn = $('#create_pay_order');
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: '/foodcourt/qrpay/req_bill?order_id=' + $('#receipt_no').text().trim() + '&customer_id=' + $('input[name="customer_id"]').val(),
|
||||||
|
method: 'GET',
|
||||||
|
success: function(result) {
|
||||||
|
console.log(result);
|
||||||
|
if(! result.status) {
|
||||||
|
alert('Something went wrong');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init`;
|
||||||
|
if ($serverMode.val() !== "cloud" && $("#display_type").val() === "2") {
|
||||||
|
// customer_display_view(null, "reload");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function(xhr) {
|
||||||
|
$('#oqs_loading_wrapper').hide();
|
||||||
|
$createOrderBtn.prop('disabled', false);
|
||||||
|
$createPayOrderBtn.prop('disabled', false);
|
||||||
|
|
||||||
|
const errorMsg = xhr.status ? `Status: ${xhr.status} - ${xhr.statusText}` : "Network error";
|
||||||
|
swal("Error", errorMsg, "error");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const cancelButton = document.querySelector('.btn-cancel');
|
||||||
|
|
||||||
|
cancelButton.addEventListener('click', function () {
|
||||||
|
console.log("Action: Cancel payment.");
|
||||||
|
|
||||||
|
paymentCards.forEach(c => c.classList.remove('active'));
|
||||||
|
$("#payment_modal").css('display', 'none');
|
||||||
|
$("#payment_modal").hide();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
var cashier_type = 'food_court';
|
var cashier_type = 'food_court';
|
||||||
$("#read_modal").on("hidden.bs.modal", function (e) {
|
$("#read_modal").on("hidden.bs.modal", function (e) {
|
||||||
$("#read_modal").css("display", "none");
|
$("#read_modal").css("display", "none");
|
||||||
@@ -535,16 +614,16 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
$('#pay, .req_bill').on('click', function () {
|
$('#pay, .req_bill').on('click', function () {
|
||||||
$("#read_modal").show();
|
// $("#read_modal").show();
|
||||||
$("#read_modal").attr('data-for', 'member');
|
// $("#read_modal").attr('data-for', 'member');
|
||||||
var sale_id = $('#sale_id').text();
|
// var sale_id = $('#sale_id').text();
|
||||||
getCardNo();
|
// getCardNo();
|
||||||
|
|
||||||
onScan.attachTo(document, {
|
// onScan.attachTo(document, {
|
||||||
onScan: function(sCode) {
|
// onScan: function(sCode) {
|
||||||
setCardNo(sCode)
|
// setCardNo(sCode)
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
});
|
});
|
||||||
// $('#pay').on('click', function () {
|
// $('#pay').on('click', function () {
|
||||||
// // var sale_id = $('#sale_id').text();
|
// // var sale_id = $('#sale_id').text();
|
||||||
|
|||||||
@@ -333,16 +333,16 @@ $(document).ready(function() {
|
|||||||
paid_amount: amountToReceive,
|
paid_amount: amountToReceive,
|
||||||
receipt_no: receiptNo
|
receipt_no: receiptNo
|
||||||
}, "pay_success");
|
}, "pay_success");
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
window.location.href = "/";
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: (xhr, status, error) => {
|
error: (xhr, status, error) => {
|
||||||
console.log("Error:", error);
|
console.log("Error:", error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = "/";
|
||||||
|
}, 1500);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkPaymentStatus() {
|
function checkPaymentStatus() {
|
||||||
@@ -434,13 +434,16 @@ $(document).ready(function() {
|
|||||||
success: function(data) {
|
success: function(data) {
|
||||||
if (data.status) {
|
if (data.status) {
|
||||||
customer_display_view(null, "reload");
|
customer_display_view(null, "reload");
|
||||||
window.location.href = "/";
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(xhr, status, error) {
|
error: function(xhr, status, error) {
|
||||||
console.log("Error:", error);
|
console.log("Error:", error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
window.location.href = "/";
|
||||||
|
}, 1500);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user