Skip to content

Commit

Permalink
fix: pay
Browse files Browse the repository at this point in the history
  • Loading branch information
whes1015 committed Oct 14, 2023
1 parent 717ca2b commit ce797ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 13 additions & 1 deletion src/scripts/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
8 changes: 4 additions & 4 deletions src/user.pug
Original file line number Diff line number Diff line change
Expand Up @@ -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") 加值硬幣數量
Expand All @@ -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") 加值硬幣數量
Expand All @@ -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;") 加值硬幣數量
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ce797ed

Please sign in to comment.