From ce797edcf4d4706ca1795616eb00e09bffef50ef Mon Sep 17 00:00:00 2001 From: whes1015 Date: Sun, 15 Oct 2023 03:22:23 +0800 Subject: [PATCH] fix: pay --- src/scripts/user.js | 14 +++++++++++++- src/user.pug | 8 ++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/scripts/user.js b/src/scripts/user.js index aa67ee8..1508ea5 100644 --- a/src/scripts/user.js +++ b/src/scripts/user.js @@ -55,16 +55,28 @@ let service_info = []; let user = {}; let CTX; +const pay_1 = document.getElementById("pay-1"); +const pay_2 = document.getElementById("pay-2"); +const pay_3 = document.getElementById("pay-3"); +pay_1.addEventListener("click", () => Pay("1")); +pay_2.addEventListener("click", () => Pay("2")); +pay_3.addEventListener("click", () => Pay("3")); function Pay(type) { - document.getElementById("pay-page").style.display = "none"; + pay_1.style.display = "none"; + pay_2.style.display = "none"; + pay_3.style.display = "none"; fetch(`https://exptech.com.tw/api/v1/et/pay?type=${type}&token=${params.token}`) .then(async res => { + document.getElementById("pay-button").textContent = `NTD ${(type == 1) ? "100" : (type == 2) ? "500" : "1000"} 前往付款`; const data = await res.json(); document.getElementById("TradeInfo").value = data.TradeInfo; document.getElementById("TradeSha").value = data.TradeSha; document.getElementById("Pay").style.display = ""; }) .catch(err => { + pay_1.style.display = ""; + pay_2.style.display = ""; + pay_3.style.display = ""; console.error(err); const res = err.request.response; alert(res); diff --git a/src/user.pug b/src/user.pug index 11a1022..a4c5766 100644 --- a/src/user.pug +++ b/src/user.pug @@ -369,7 +369,7 @@ html(lang="zh-Hant") #charge.view .box-items( - onclick="Pay('1')" + id="pay-1" style="background-color: dimgrey; cursor: pointer;" ) div(style="font-size: 24px; font-weight: 900") 加值硬幣數量 @@ -391,7 +391,7 @@ html(lang="zh-Hant") div(style="font-size: 22px; padding-right: 8px") NTD 100 .box-items( - onclick="Pay('2')" + id="pay-2" style="background-color: darkslategrey; cursor: pointer;" ) div(style="font-size: 24px; font-weight: 900") 加值硬幣數量 @@ -412,7 +412,7 @@ html(lang="zh-Hant") div(style="font-size: 22px; padding-right: 8px") NTD 500 .box-items( - onclick="Pay('3')" + id="pay-3" style="background-color: darkslateblue; cursor: pointer;" ) div(style="font-size: 24px; font-weight: 900;") 加值硬幣數量 @@ -440,7 +440,7 @@ html(lang="zh-Hant") input#TradeInfo(type="text", name="TradeInfo", hidden) input#TradeSha(type="text", name="TradeSha", hidden) input(type="text", name="Version", value="2.0", hidden) - button.Pay(type="submit") 前往付款 + button.Pay(type="submit",id="pay-button") 前往付款 #about.view .container