Skip to content

Commit

Permalink
feat :support auto payment query timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehco1996 committed Dec 19, 2023
1 parent 16e891e commit 77b599f
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions templates/web/charge_center.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h2 class="subtitle">
<div id="id-qrcode-canvas"></div>
<hr>
<p>
<strong>付费完成之后请点击确认</strong>
<strong>付费完成之后请点击确认</strong>
</p>
<p id="id-msg-line"></p>
<div class="control">
Expand Down Expand Up @@ -152,6 +152,8 @@ <h2 class="subtitle">
var codeBox = $("#id-qrcode-box")
var msgline = $("#id-msg-line")
var url = "{% url 'api:order' %}"
var queryTimer;

var payrequest = function () {
paynum = payinput.val()
if (paynum >= 1 && paynum % 1 == 0) {
Expand All @@ -168,6 +170,7 @@ <h2 class="subtitle">
codeBox.attr('class', '')
qrcode_url = results.qrcode_url
$("#id-qrcode-canvas").qrcode(qrcode_url)
var queryTimer = setInterval(payquery, 1000);
}
})
} else {
Expand All @@ -176,15 +179,21 @@ <h2 class="subtitle">
}
requestButton.click(payrequest)

// 支付查询部分
queryButton = $("#id-button-query")
var payquery = function () {
msgline.html('后台飞速查询结果中 请稍候....')

function payquery() {
msgline.html('后台飞速查询结果中,请稍候...');
$.getJSON(url, function (results) {
info = results.info
swal(info.title, info.subtitle, info.status)
})
info = results.info;
swal(info.title, info.subtitle, info.status);
if (info.status == "success") {
// 停止定时器
clearInterval(queryTimer);
}
});
}

// 支付查询部分
queryButton = $("#id-button-query")
queryButton.click(payquery)
</script>

Expand Down

0 comments on commit 77b599f

Please sign in to comment.