Move spot sell retry into positions header row per mockup.
Show trading-account coin balance with gradient retry button and icon refresh in the holdings title bar. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2166,7 +2166,7 @@
|
||||
if (ss && ss.ok && !ss.skipped) {
|
||||
okMsg += "\n已自动卖回 USDT";
|
||||
} else if (ss && ss.bridge_status === "pending_sell_spot") {
|
||||
okMsg += "\n卖回 USDT 失败,请点持仓区「重试卖回」";
|
||||
okMsg += "\n卖回 USDT 失败,请点持仓标题栏「重试卖回」";
|
||||
}
|
||||
alert(okMsg);
|
||||
} else {
|
||||
@@ -2210,6 +2210,14 @@
|
||||
setOptionsPosTab(state.posTab);
|
||||
}
|
||||
|
||||
function fmtCoinAvail(v) {
|
||||
const n = Number(v);
|
||||
if (!Number.isFinite(n) || n <= 0) return "0";
|
||||
if (n >= 1) return n.toFixed(6).replace(/\.?0+$/, "");
|
||||
if (n >= 0.000001) return n.toFixed(6).replace(/\.?0+$/, "");
|
||||
return n.toFixed(8).replace(/\.?0+$/, "");
|
||||
}
|
||||
|
||||
function shouldShowSpotSellBanner(d, positions) {
|
||||
if (!isCoinMarginMode()) return false;
|
||||
const ss = d && d.spot_sell;
|
||||
@@ -2219,7 +2227,7 @@
|
||||
if (ss.bridge_status === "pending_sell_spot") return true;
|
||||
const eth = Number(ss.trading_eth || 0);
|
||||
const btc = Number(ss.trading_btc || 0);
|
||||
return eth > 0.00001 || btc > 0.000001;
|
||||
return eth > 1e-12 || btc > 1e-12;
|
||||
}
|
||||
|
||||
function spotSellUnderlying(ss) {
|
||||
@@ -2227,18 +2235,19 @@
|
||||
if (ss.bridge_underlying) return String(ss.bridge_underlying).toUpperCase();
|
||||
const eth = Number(ss.trading_eth || 0);
|
||||
const btc = Number(ss.trading_btc || 0);
|
||||
if (btc > eth && btc > 0.000001) return "BTC";
|
||||
if (eth > 0.00001) return "ETH";
|
||||
if (btc > eth && btc > 1e-12) return "BTC";
|
||||
if (eth > 1e-12) return "ETH";
|
||||
return (ss.default_underly || state.underlying || "ETH").toUpperCase();
|
||||
}
|
||||
|
||||
function paintSpotSellBanner(d, positions) {
|
||||
const banner = document.getElementById("opt-spot-sell-banner");
|
||||
const textEl = document.getElementById("opt-spot-sell-banner-text");
|
||||
if (!banner || !textEl) return;
|
||||
const head = document.getElementById("opt-spot-sell-head");
|
||||
const availEl = document.getElementById("opt-spot-sell-avail-text");
|
||||
const retryBtn = document.getElementById("opt-spot-sell-retry-btn");
|
||||
if (!head || !availEl || !retryBtn) return;
|
||||
const show = shouldShowSpotSellBanner(d, positions);
|
||||
if (!show) {
|
||||
banner.hidden = true;
|
||||
head.hidden = true;
|
||||
state.spotSellUnderlying = null;
|
||||
return;
|
||||
}
|
||||
@@ -2248,15 +2257,9 @@
|
||||
const eth = Number(ss.trading_eth || 0);
|
||||
const btc = Number(ss.trading_btc || 0);
|
||||
const amt = uly === "BTC" ? btc : eth;
|
||||
let msg = "交易账户残留 " + uly;
|
||||
if (amt > 0) msg += " " + fmt(amt, 6);
|
||||
if (ss.bridge_status === "pending_sell_spot") {
|
||||
msg += ",自动卖回 USDT 失败";
|
||||
} else {
|
||||
msg += ",可卖回 USDT";
|
||||
}
|
||||
textEl.textContent = msg;
|
||||
banner.hidden = false;
|
||||
availEl.textContent = "交易户可用 " + fmtCoinAvail(amt) + " " + uly;
|
||||
retryBtn.textContent = "重试卖回 " + uly;
|
||||
head.hidden = false;
|
||||
}
|
||||
|
||||
async function retrySpotSell() {
|
||||
|
||||
Reference in New Issue
Block a user