chore: update h5 subpage interactions
This commit is contained in:
parent
b6c3d8b0b3
commit
3a3788c62b
@ -1,4 +1,4 @@
|
||||
import { applyLang, bindHeader, connectToApp, get, post, safeJsonArray, t, toast } from "../bd-static/shared.js";
|
||||
import { applyLang, bindHeader, connectToApp, createMask, get, navigateTo, post, safeJsonArray, t, toast } from "../bd-static/shared.js";
|
||||
|
||||
let existing = false;
|
||||
let data = { id: "", contactNumber: "", category: "CARD", otherDescription: "", passportFrontUrl: "", passportBackUrl: "meaningless" };
|
||||
@ -11,7 +11,13 @@ document.getElementById("contactNumber").placeholder = t("enter_contact_number")
|
||||
document.getElementById("otherDescription").placeholder = t("enter_other_description");
|
||||
document.getElementById("contactNumber").addEventListener("input", sync);
|
||||
document.getElementById("otherDescription").addEventListener("input", sync);
|
||||
document.getElementById("submitButton").addEventListener("click", submit);
|
||||
document.getElementById("submitButton").addEventListener("click", () => {
|
||||
if (existing) {
|
||||
confirmSubmit();
|
||||
} else {
|
||||
submit();
|
||||
}
|
||||
});
|
||||
connectToApp().then(load);
|
||||
|
||||
async function load() {
|
||||
@ -102,8 +108,45 @@ async function submit() {
|
||||
try {
|
||||
await post(existing ? "/wallet/withdraw-info/update" : "/wallet/withdraw-info/add", data);
|
||||
toast(t("application_submitted"));
|
||||
window.setTimeout(() => window.history.back(), 300);
|
||||
window.setTimeout(returnBack, 300);
|
||||
} catch (error) {
|
||||
toast(error.response?.errorMsg || error.message);
|
||||
}
|
||||
}
|
||||
|
||||
function confirmSubmit() {
|
||||
const sheet = document.createElement("section");
|
||||
sheet.className = "sheet";
|
||||
sheet.style.bottom = "auto";
|
||||
sheet.style.left = "5%";
|
||||
sheet.style.right = "5%";
|
||||
sheet.style.top = "30%";
|
||||
sheet.style.borderRadius = "12px";
|
||||
sheet.innerHTML = `
|
||||
<div class="sheet-title">${t("tips")}</div>
|
||||
<div class="subtle" style="font-size:1.1em;margin-bottom:12px">${t("confirm_modify_kyc")}</div>
|
||||
<div class="row">
|
||||
<button class="soft-btn" type="button" data-cancel>${t("cancel")}</button>
|
||||
<button class="primary-btn" type="button" data-confirm>${t("confirm")}</button>
|
||||
</div>
|
||||
`;
|
||||
const mask = createMask(sheet);
|
||||
sheet.querySelector("[data-cancel]").addEventListener("click", () => mask.remove());
|
||||
sheet.querySelector("[data-confirm]").addEventListener("click", () => {
|
||||
mask.remove();
|
||||
submit();
|
||||
});
|
||||
}
|
||||
|
||||
function returnBack() {
|
||||
const query = new URLSearchParams(window.location.search);
|
||||
const from = query.get("from");
|
||||
if (from) {
|
||||
const activeAction = query.get("activeAction");
|
||||
const target = new URL(from, window.location.origin);
|
||||
if (activeAction) target.searchParams.set("activeAction", activeAction);
|
||||
navigateTo(`${target.pathname}${target.search}`);
|
||||
return;
|
||||
}
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ function historyItem(item, settings) {
|
||||
`<div>${t("num_teams") || t(settings.countLabel)} ${item.agencyNumber || item.bdNumber || 0}</div>`
|
||||
];
|
||||
card.innerHTML = `<div class="status-tag">${statusText(item.statusText)}</div>${details.join("")}`;
|
||||
if (item.billBelong) {
|
||||
if (item.statusText === "Completed") {
|
||||
const more = document.createElement("button");
|
||||
more.className = "more-btn";
|
||||
more.type = "button";
|
||||
|
||||
@ -56,7 +56,7 @@ function readIdentity() {
|
||||
function readPayee() {
|
||||
for (const storage of [sessionStorage, localStorage]) {
|
||||
try {
|
||||
const value = storage.getItem("payee");
|
||||
const value = storage.getItem("transfer.payee") || storage.getItem("payee");
|
||||
if (value) return JSON.parse(value);
|
||||
} catch {}
|
||||
}
|
||||
@ -180,7 +180,9 @@ function renderTransfer() {
|
||||
renderTransfer();
|
||||
}));
|
||||
document.getElementById("payeeButton").addEventListener("click", () => navigateTo("/search-payee?from=/available-income&activeAction=Transfer"));
|
||||
document.getElementById("transferButton").addEventListener("click", submitTransfer);
|
||||
const transferButton = document.getElementById("transferButton");
|
||||
transferButton.disabled = !(state.transferId && state.payee?.id);
|
||||
transferButton.addEventListener("click", submitTransfer);
|
||||
}
|
||||
|
||||
function payeeHtml(payee) {
|
||||
@ -189,7 +191,7 @@ function payeeHtml(payee) {
|
||||
<img class="avatar" src="${payee.avatar || ""}" alt="">
|
||||
<span class="member-main">
|
||||
<span class="member-name">${payee.name || "-"}</span>
|
||||
<span class="member-meta">${t("user_id_prefix")}${payee.account || "-"}</span>
|
||||
<span class="member-meta">${t("user_id_prefix")}${payee.goodID || payee.account || "-"}</span>
|
||||
</span>
|
||||
</span>
|
||||
`;
|
||||
@ -201,7 +203,7 @@ function renderExchange() {
|
||||
<div class="amount-grid">
|
||||
${exchanges.map((item) => `<button class="amount-card ${state.exchangeId === item.id ? "active" : ""}" data-exchange="${item.id}" type="button">$${item.cash}<br><span class="subtle">${item.coins}</span></button>`).join("")}
|
||||
</div>
|
||||
<div style="display:flex;justify-content:center;margin-top:12px"><button class="primary-btn" id="exchangeButton" type="button">${t("exchange")}</button></div>
|
||||
<div style="display:flex;justify-content:center;margin-top:12px"><button class="primary-btn" id="exchangeButton" type="button" ${state.exchangeId ? "" : "disabled"}>${t("exchange")}</button></div>
|
||||
`;
|
||||
panel.querySelectorAll("[data-exchange]").forEach((button) => button.addEventListener("click", () => {
|
||||
const id = Number(button.dataset.exchange);
|
||||
@ -222,11 +224,13 @@ function renderCashOut() {
|
||||
${state.kyc ? kycHtml(state.kyc) : `<button class="menu-link" id="completeKyc" type="button"><span>${t("complete_information")}</span><img class="arrow" src="../bd-static/icons/arrow.svg" alt=""></button>`}
|
||||
</article>
|
||||
<div style="display:flex;justify-content:center;margin-top:12px">
|
||||
<button class="primary-btn" id="cashButton" type="button" ${status === "PASS" ? "" : "disabled"}>${t("cash_out")}</button>
|
||||
<button class="primary-btn" id="cashButton" type="button" style="${status === "PASS" ? "" : "background:#ccc;opacity:.6"}">${t("cash_out")}</button>
|
||||
</div>
|
||||
`;
|
||||
const completeKyc = document.getElementById("completeKyc");
|
||||
if (completeKyc) completeKyc.addEventListener("click", () => navigateTo("/bank-cards?from=/available-income&activeAction=Cash out"));
|
||||
const editKyc = document.getElementById("editKyc");
|
||||
if (editKyc) editKyc.addEventListener("click", () => navigateTo("/bank-cards?from=/available-income&activeAction=Cash out"));
|
||||
document.getElementById("cashButton").addEventListener("click", () => {
|
||||
if (state.kyc && state.kyc.status === "PASS") openCashSheet();
|
||||
else if (!state.kyc) openImproveDialog();
|
||||
@ -243,7 +247,7 @@ function statusLabel(status) {
|
||||
function kycHtml(item) {
|
||||
return `
|
||||
<div style="display:flex;flex-direction:column;gap:8px">
|
||||
<div><b>${t("passport_id_card_title")}:</b></div>
|
||||
<div class="row"><b>${t("passport_id_card_title")}:</b><button type="button" id="editKyc"><img class="arrow" src="../bd-static/icons/arrow.svg" alt=""></button></div>
|
||||
<div style="display:flex;gap:8px;flex-wrap:wrap">${(item.previewUrls || []).map((src) => `<img src="${src}" alt="" style="width:15vw;aspect-ratio:1/1;object-fit:cover;border-radius:10px">`).join("")}</div>
|
||||
<div><b>${t("contact_number")}:</b></div><div class="subtle">${item.contactNumber || ""}</div>
|
||||
<div><b>${t("other_description")}:</b></div><div class="subtle">${item.otherDescription || ""}</div>
|
||||
|
||||
@ -17,7 +17,10 @@ kycMore.addEventListener("click", () => navigateTo("/KYC"));
|
||||
async function init() {
|
||||
try {
|
||||
await connectToApp();
|
||||
await Promise.all([loadCards(), loadKyc()]);
|
||||
const [cardsResult, kycResult] = await Promise.allSettled([loadCards(), loadKyc()]);
|
||||
[cardsResult, kycResult].forEach((result) => {
|
||||
if (result.status === "rejected") toast(result.reason?.response?.errorMsg || result.reason?.message);
|
||||
});
|
||||
} catch (error) {
|
||||
toast(error.response?.errorMsg || error.message);
|
||||
} finally {
|
||||
|
||||
@ -117,7 +117,11 @@ async function sendGift(account, mask) {
|
||||
mask.remove();
|
||||
toast(t("gift_delivery_successful"));
|
||||
state.selected = null;
|
||||
} else {
|
||||
state.locked = true;
|
||||
}
|
||||
} else {
|
||||
state.locked = true;
|
||||
}
|
||||
} catch (error) {
|
||||
toast(error.response?.errorMsg || error.message);
|
||||
|
||||
@ -272,6 +272,17 @@ export function navigateTo(target) {
|
||||
}
|
||||
|
||||
export function closePage() {
|
||||
const params = new URLSearchParams(window.location.search);
|
||||
const from = params.get("from");
|
||||
if (from) {
|
||||
const target = new URL(from, window.location.origin);
|
||||
const activeAction = params.get("activeAction");
|
||||
if (activeAction) target.searchParams.set("activeAction", activeAction);
|
||||
const currentLang = params.get("lang");
|
||||
if (currentLang && !target.searchParams.has("lang")) target.searchParams.set("lang", currentLang);
|
||||
window.location.href = `${target.pathname}${target.search}${target.hash}`;
|
||||
return;
|
||||
}
|
||||
if (window.history.length > 1) {
|
||||
window.history.back();
|
||||
return;
|
||||
|
||||
@ -45,12 +45,6 @@ clearButton.addEventListener("click", () => {
|
||||
|
||||
inviteButton.addEventListener("click", inviteSelected);
|
||||
|
||||
let searchTimer = 0;
|
||||
input.addEventListener("input", () => {
|
||||
window.clearTimeout(searchTimer);
|
||||
if (state.query.trim()) searchTimer = window.setTimeout(search, 500);
|
||||
});
|
||||
|
||||
async function init() {
|
||||
try {
|
||||
await connectToApp();
|
||||
|
||||
@ -11,7 +11,11 @@
|
||||
<section class="content">
|
||||
<div class="row">
|
||||
<div class="input-box" style="flex:1">
|
||||
<input class="field" id="searchInput" type="text" autocomplete="off">
|
||||
<div style="display:flex;align-items:center;gap:8px">
|
||||
<img src="../bd-static/icons/search.svg" alt="" style="width:22px;height:22px;opacity:.8">
|
||||
<input class="field" id="searchInput" type="text" autocomplete="off">
|
||||
<button type="button" id="clearButton" hidden style="color:#9ca3af;font-size:20px;line-height:1">x</button>
|
||||
</div>
|
||||
</div>
|
||||
<button class="primary-btn" id="inviteButton" type="button" disabled data-i18n="invite">Invite</button>
|
||||
</div>
|
||||
|
||||
@ -14,15 +14,24 @@ let selected = null;
|
||||
bindHeader(config.title);
|
||||
applyLang();
|
||||
const input = document.getElementById("searchInput");
|
||||
const clearButton = document.getElementById("clearButton");
|
||||
input.placeholder = t("enter_user_id");
|
||||
input.addEventListener("input", () => {
|
||||
selected = null;
|
||||
clearButton.hidden = !input.value;
|
||||
render();
|
||||
});
|
||||
input.addEventListener("keyup", (event) => {
|
||||
if (event.key === "Enter") search();
|
||||
});
|
||||
document.getElementById("inviteButton").addEventListener("click", invite);
|
||||
clearButton.addEventListener("click", () => {
|
||||
input.value = "";
|
||||
searchResult = [];
|
||||
selected = null;
|
||||
clearButton.hidden = true;
|
||||
render();
|
||||
});
|
||||
connectToApp().then(loadInvited);
|
||||
|
||||
async function loadInvited() {
|
||||
|
||||
@ -7,13 +7,7 @@
|
||||
<link rel="stylesheet" href="../bd-static/shared.css">
|
||||
</head>
|
||||
<body>
|
||||
<main class="page">
|
||||
<section class="content">
|
||||
<article class="card card-pad">
|
||||
<div class="subtle" id="policyHint"></div>
|
||||
</article>
|
||||
</section>
|
||||
</main>
|
||||
<main class="page"></main>
|
||||
<script type="module" src="./policy.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import { applyLang, bindHeader, connectToApp, t } from "../bd-static/shared.js";
|
||||
import { applyLang, bindHeader, connectToApp } from "../bd-static/shared.js";
|
||||
|
||||
const from = new URLSearchParams(window.location.search).get("from") || "BDLead";
|
||||
bindHeader(from === "BD" ? "bd_policy" : "bd_leader_policy");
|
||||
applyLang();
|
||||
document.getElementById("policyHint").textContent = from === "BD" ? t("bd_policy") : t("bd_leader_policy");
|
||||
connectToApp();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user