feat: restructure OKX options UI with header funds, settings card, and dual-column layout
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
const root = document.getElementById("options-settings-root");
|
||||
if (!root) return;
|
||||
|
||||
async function apiJson(url, opts) {
|
||||
const r = await fetch(url, Object.assign({ credentials: "same-origin" }, opts || {}));
|
||||
return r.json();
|
||||
}
|
||||
|
||||
function setMsg(id, text, isErr) {
|
||||
const el = document.getElementById(id);
|
||||
if (!el) return;
|
||||
el.textContent = text || "";
|
||||
el.classList.toggle("opt-error", !!isErr);
|
||||
}
|
||||
|
||||
document.getElementById("opt-set-swap-btn").addEventListener("click", async function () {
|
||||
const amount = parseFloat(document.getElementById("opt-set-swap-amount").value);
|
||||
if (!amount || amount <= 0) {
|
||||
setMsg("opt-set-swap-msg", "请输入有效数量", true);
|
||||
return;
|
||||
}
|
||||
const d = await apiJson("/api/options/spot/swap", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
direction: document.getElementById("opt-set-swap-dir").value,
|
||||
amount: amount,
|
||||
}),
|
||||
});
|
||||
setMsg("opt-set-swap-msg", d.ok ? "兑换单已提交" : (d.msg || "失败"), !d.ok);
|
||||
});
|
||||
|
||||
document.getElementById("opt-set-int-btn").addEventListener("click", async function () {
|
||||
const amount = parseFloat(document.getElementById("opt-set-int-amount").value);
|
||||
if (!amount || amount <= 0) {
|
||||
setMsg("opt-set-int-msg", "请输入有效数量", true);
|
||||
return;
|
||||
}
|
||||
const d = await apiJson("/api/options/transfer", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
ccy: document.getElementById("opt-set-int-ccy").value,
|
||||
from: document.getElementById("opt-set-int-from").value,
|
||||
to: document.getElementById("opt-set-int-to").value,
|
||||
amount: amount,
|
||||
}),
|
||||
});
|
||||
setMsg("opt-set-int-msg", d.ok ? "划转成功" : (d.msg || "失败"), !d.ok);
|
||||
});
|
||||
|
||||
document.getElementById("opt-set-cross-btn").addEventListener("click", async function () {
|
||||
const amount = parseFloat(document.getElementById("opt-set-cross-amount").value);
|
||||
if (!amount || amount <= 0) {
|
||||
setMsg("opt-set-cross-msg", "请输入有效数量", true);
|
||||
return;
|
||||
}
|
||||
const d = await apiJson("/api/options/cross-transfer", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
ccy: document.getElementById("opt-set-cross-ccy").value,
|
||||
amount: amount,
|
||||
account: document.getElementById("opt-set-cross-acct").value,
|
||||
direction: document.getElementById("opt-set-cross-dir").value,
|
||||
}),
|
||||
});
|
||||
setMsg("opt-set-cross-msg", d.ok ? "划转成功" : (d.msg || "失败"), !d.ok);
|
||||
});
|
||||
})();
|
||||
Reference in New Issue
Block a user