updata
This commit is contained in:
parent
34fa2cb21b
commit
48c1ed6bdc
378
api/assets.js
378
api/assets.js
|
|
@ -305,26 +305,289 @@ function buildTransferTips(feePercent, bmtrFeePercent) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildWalletList(address) {
|
function resolveWalletModifyCount(source) {
|
||||||
const normalizedAddress = String(address || "").trim();
|
const target = source && typeof source === "object" ? source : {};
|
||||||
|
let rawCount = pickFirstValue(target, [
|
||||||
|
"edit_times",
|
||||||
|
"editTimes",
|
||||||
|
"remaining_modify_count",
|
||||||
|
"remainingModifyCount",
|
||||||
|
"modify_num",
|
||||||
|
"modifyNum",
|
||||||
|
"modify_count",
|
||||||
|
"modifyCount",
|
||||||
|
"change_num",
|
||||||
|
"changeNum",
|
||||||
|
"change_count",
|
||||||
|
"changeCount",
|
||||||
|
"edit_num",
|
||||||
|
"editNum",
|
||||||
|
"edit_count",
|
||||||
|
"editCount",
|
||||||
|
"update_num",
|
||||||
|
"updateNum",
|
||||||
|
"update_count",
|
||||||
|
"updateCount",
|
||||||
|
"surplus_num",
|
||||||
|
"surplusNum",
|
||||||
|
"remain_num",
|
||||||
|
"remainNum",
|
||||||
|
"remaining_times",
|
||||||
|
"remainingTimes",
|
||||||
|
"modify_times",
|
||||||
|
"modifyTimes",
|
||||||
|
"change_times",
|
||||||
|
"changeTimes",
|
||||||
|
"address_modify_num",
|
||||||
|
"addressModifyNum",
|
||||||
|
"address_change_num",
|
||||||
|
"addressChangeNum",
|
||||||
|
"wallet_modify_num",
|
||||||
|
"walletModifyNum",
|
||||||
|
"remaining_count",
|
||||||
|
"remainingCount",
|
||||||
|
]);
|
||||||
|
|
||||||
if (!normalizedAddress) {
|
if (rawCount === "") {
|
||||||
|
const countKey = Object.keys(target).find(function (key) {
|
||||||
|
const normalizedKey = String(key || "").toLowerCase();
|
||||||
|
return (
|
||||||
|
/(modify|change|edit|update|alter|replace).*(num|number|count|times|limit|remain|surplus)/.test(
|
||||||
|
normalizedKey,
|
||||||
|
) ||
|
||||||
|
/(remain|surplus).*(modify|change|edit|update|alter|replace)/.test(
|
||||||
|
normalizedKey,
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
rawCount = countKey ? target[countKey] : "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rawCount === "") {
|
||||||
|
const canModify = pickFirstValue(target, ["can_modify", "canModify"]);
|
||||||
|
if (canModify === "") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return canModify === true || Number(canModify) > 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const count = Number(rawCount);
|
||||||
|
return Number.isFinite(count) ? Math.max(0, Math.floor(count)) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeWalletSource(data) {
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
const source = data && typeof data === "object" ? data : {};
|
||||||
|
const hasExplicitWalletFields =
|
||||||
|
Object.prototype.hasOwnProperty.call(source, "address") ||
|
||||||
|
Object.prototype.hasOwnProperty.call(source, "more_address") ||
|
||||||
|
Object.prototype.hasOwnProperty.call(source, "moreAddress");
|
||||||
|
|
||||||
|
if (hasExplicitWalletFields) {
|
||||||
|
const walletSource = [];
|
||||||
|
const defaultAddress = String(source.address || "").trim();
|
||||||
|
const moreAddress = pickFirstValue(source, ["more_address", "moreAddress"]);
|
||||||
|
|
||||||
|
if (defaultAddress) {
|
||||||
|
walletSource.push({
|
||||||
|
address: defaultAddress,
|
||||||
|
is_default: 1,
|
||||||
|
type: 0,
|
||||||
|
name: "默认钱包",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
normalizeWalletSource(moreAddress).forEach(function (item, index) {
|
||||||
|
const address = String(
|
||||||
|
item && typeof item === "object"
|
||||||
|
? pickFirstValue(item, [
|
||||||
|
"address",
|
||||||
|
"wallet_address",
|
||||||
|
"walletAddress",
|
||||||
|
"value",
|
||||||
|
])
|
||||||
|
: item || "",
|
||||||
|
).trim();
|
||||||
|
|
||||||
|
if (address && address !== defaultAddress) {
|
||||||
|
walletSource.push({
|
||||||
|
address: address,
|
||||||
|
is_default: 0,
|
||||||
|
type: 1,
|
||||||
|
name:
|
||||||
|
item && typeof item === "object"
|
||||||
|
? pickFirstValue(item, ["name", "wallet_name", "walletName"])
|
||||||
|
: "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return walletSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
let walletSource = pickFirstValue(source, [
|
||||||
|
"wallets",
|
||||||
|
"wallet_list",
|
||||||
|
"walletList",
|
||||||
|
"address_list",
|
||||||
|
"addressList",
|
||||||
|
"addresses",
|
||||||
|
"list",
|
||||||
|
"address",
|
||||||
|
]);
|
||||||
|
|
||||||
|
if (!walletSource && typeof data === "string") {
|
||||||
|
walletSource = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Array.isArray(walletSource)) {
|
||||||
|
return walletSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (walletSource && typeof walletSource === "object") {
|
||||||
|
return [walletSource];
|
||||||
|
}
|
||||||
|
|
||||||
|
const text = String(walletSource || "").trim();
|
||||||
|
if (!text) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
if (text.charAt(0) === "[") {
|
||||||
{
|
try {
|
||||||
id: "default-wallet",
|
const parsed = JSON.parse(text);
|
||||||
name: serviceConfig.WALLET_NAME,
|
if (Array.isArray(parsed)) {
|
||||||
address: normalizedAddress,
|
return parsed;
|
||||||
isDefault: true,
|
}
|
||||||
},
|
} catch (error) {
|
||||||
];
|
// Continue with delimiter parsing for legacy responses.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return text.split(/[\n,;]+/).filter(function (item) {
|
||||||
|
return String(item || "").trim();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildWalletPayload(address) {
|
function buildWalletList(data) {
|
||||||
|
const source = data && typeof data === "object" ? data : {};
|
||||||
|
const sharedModifyCount = resolveWalletModifyCount(source);
|
||||||
|
const wallets = normalizeWalletSource(data)
|
||||||
|
.map(function (item, index) {
|
||||||
|
const wallet = item && typeof item === "object" ? item : {};
|
||||||
|
const address = String(
|
||||||
|
typeof item === "string"
|
||||||
|
? item
|
||||||
|
: pickFirstValue(wallet, [
|
||||||
|
"address",
|
||||||
|
"wallet_address",
|
||||||
|
"walletAddress",
|
||||||
|
"value",
|
||||||
|
]),
|
||||||
|
).trim();
|
||||||
|
|
||||||
|
if (!address) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const walletModifyCount = resolveWalletModifyCount(wallet);
|
||||||
|
const remainingModifyCount =
|
||||||
|
walletModifyCount === null ? sharedModifyCount : walletModifyCount;
|
||||||
|
|
||||||
|
const requestId = pickFirstValue(wallet, ["id", "wallet_id", "walletId"]);
|
||||||
|
const defaultValue = pickFirstValue(wallet, [
|
||||||
|
"is_default",
|
||||||
|
"isDefault",
|
||||||
|
"default",
|
||||||
|
]);
|
||||||
|
const isDefault =
|
||||||
|
defaultValue === true ||
|
||||||
|
defaultValue === 1 ||
|
||||||
|
String(defaultValue).toLowerCase() === "true" ||
|
||||||
|
String(defaultValue) === "1";
|
||||||
|
const walletType = Number(pickFirstValue(wallet, ["type"]));
|
||||||
|
const walletName = pickFirstValue(wallet, [
|
||||||
|
"name",
|
||||||
|
"wallet_name",
|
||||||
|
"walletName",
|
||||||
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
wallets: buildWalletList(address),
|
id: String(requestId || "wallet-" + index),
|
||||||
|
requestId: requestId === "" ? "" : String(requestId),
|
||||||
|
name: String(walletName || (isDefault ? serviceConfig.WALLET_NAME : "")),
|
||||||
|
address: address,
|
||||||
|
isDefault: isDefault,
|
||||||
|
type: walletType === 1 ? 1 : 0,
|
||||||
|
editTimes: remainingModifyCount,
|
||||||
|
remainingModifyCount: remainingModifyCount,
|
||||||
|
canModify:
|
||||||
|
remainingModifyCount !== null && remainingModifyCount === 0,
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
|
.filter(function (wallet, index, list) {
|
||||||
|
return list.findIndex(function (item) {
|
||||||
|
return item.address === wallet.address;
|
||||||
|
}) === index;
|
||||||
|
});
|
||||||
|
|
||||||
|
const hasExplicitDefaultField =
|
||||||
|
Object.prototype.hasOwnProperty.call(source, "address") &&
|
||||||
|
(Object.prototype.hasOwnProperty.call(source, "more_address") ||
|
||||||
|
Object.prototype.hasOwnProperty.call(source, "moreAddress"));
|
||||||
|
if (
|
||||||
|
wallets.length &&
|
||||||
|
!hasExplicitDefaultField &&
|
||||||
|
!wallets.some(function (wallet) {
|
||||||
|
return wallet.isDefault;
|
||||||
|
})
|
||||||
|
) {
|
||||||
|
wallets[0].isDefault = true;
|
||||||
|
if (!wallets[0].name) {
|
||||||
|
wallets[0].name = serviceConfig.WALLET_NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wallets;
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildWalletPayload(data) {
|
||||||
|
const wallets = buildWalletList(data);
|
||||||
|
const editTimes = resolveWalletModifyCount(data);
|
||||||
|
const source = data && typeof data === "object" ? data : {};
|
||||||
|
const rawMoreAddressNum = pickFirstValue(source, [
|
||||||
|
"more_address_num",
|
||||||
|
"moreAddressNum",
|
||||||
|
]);
|
||||||
|
const moreWallets = wallets.filter(function (wallet) {
|
||||||
|
return !wallet.isDefault;
|
||||||
|
});
|
||||||
|
const parsedMoreAddressNum = Number(rawMoreAddressNum);
|
||||||
|
const moreAddressNum =
|
||||||
|
rawMoreAddressNum !== "" && Number.isFinite(parsedMoreAddressNum)
|
||||||
|
? Math.max(0, Math.floor(parsedMoreAddressNum))
|
||||||
|
: moreWallets.length;
|
||||||
|
|
||||||
|
return {
|
||||||
|
wallets: wallets,
|
||||||
|
defaultWallet:
|
||||||
|
wallets.find(function (wallet) {
|
||||||
|
return wallet.isDefault;
|
||||||
|
}) || null,
|
||||||
|
moreWallets: moreWallets,
|
||||||
|
moreAddressNum: moreAddressNum,
|
||||||
|
editTimes: editTimes,
|
||||||
|
remainingModifyCount: editTimes,
|
||||||
|
canModify:
|
||||||
|
editTimes !== null
|
||||||
|
? editTimes === 0
|
||||||
|
: wallets.some(function (wallet) {
|
||||||
|
return wallet.canModify;
|
||||||
|
}),
|
||||||
instructions: [
|
instructions: [
|
||||||
"点击交易所 App 底部“资产”进入钱包页",
|
"点击交易所 App 底部“资产”进入钱包页",
|
||||||
"搜索或输入大写字母 BMT",
|
"搜索或输入大写字母 BMT",
|
||||||
|
|
@ -1767,15 +2030,16 @@ async function fetchExtractBankData(requestOptions) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function fetchBmtPowerRateData(requestOptions) {
|
async function fetchBmtRedeemConfigData(requestOptions) {
|
||||||
return fetchPayload(
|
return fetchPayload(
|
||||||
createRequestOptions(
|
createRequestOptions(
|
||||||
{
|
{
|
||||||
url: serviceConfig.ENDPOINTS.bmtRedeemPowerRate,
|
url: serviceConfig.ENDPOINTS.bmtRedeemConfig,
|
||||||
|
method: "POST",
|
||||||
},
|
},
|
||||||
requestOptions,
|
requestOptions,
|
||||||
),
|
),
|
||||||
"兑换比例加载失败",
|
"兑换配置加载失败",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1919,6 +2183,7 @@ async function fetchWalletAddressData(requestOptions) {
|
||||||
createRequestOptions(
|
createRequestOptions(
|
||||||
{
|
{
|
||||||
url: serviceConfig.ENDPOINTS.walletDetail,
|
url: serviceConfig.ENDPOINTS.walletDetail,
|
||||||
|
method: "GET",
|
||||||
},
|
},
|
||||||
requestOptions,
|
requestOptions,
|
||||||
),
|
),
|
||||||
|
|
@ -2607,28 +2872,36 @@ export async function submitAssetBmtFlashExchange(payload, requestOptions) {
|
||||||
export async function fetchBmtExchangeDetail(requestOptions) {
|
export async function fetchBmtExchangeDetail(requestOptions) {
|
||||||
const result = await Promise.all([
|
const result = await Promise.all([
|
||||||
fetchHomeBalanceData(requestOptions),
|
fetchHomeBalanceData(requestOptions),
|
||||||
fetchBmtPowerRateData(requestOptions),
|
fetchBmtRedeemConfigData(requestOptions),
|
||||||
|
fetchUserData(requestOptions),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const ticker = getHomeTickerCache();
|
const ticker = getHomeTickerCache();
|
||||||
const balances = normalizeBalances(result[0]);
|
const balances = normalizeBalances(result[0]);
|
||||||
const powerRate = resolveRedeemPowerRate(result[1]);
|
const exchangeConfig = {
|
||||||
|
point: toNumber(result[1] && result[1].point),
|
||||||
|
cPower: toNumber(result[1] && result[1].c_power),
|
||||||
|
bmtr: toNumber(result[1] && result[1].bmtr),
|
||||||
|
redeemNum: toNumber(result[1] && result[1].redeem_num),
|
||||||
|
};
|
||||||
|
const bmtr = pickFirstValue(result[2], ["bmtr"]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
ticker: ticker,
|
ticker: ticker,
|
||||||
powerRate: powerRate,
|
exchangeConfig: exchangeConfig,
|
||||||
balances: {
|
balances: {
|
||||||
points: balances.points,
|
points: balances.points,
|
||||||
power: balances.power,
|
power: balances.power,
|
||||||
bmt: balances.bmt,
|
bmt: balances.bmt,
|
||||||
|
bmtr: toNumber(bmtr),
|
||||||
voucher: balances.voucher,
|
voucher: balances.voucher,
|
||||||
coupon: balances.coupon,
|
coupon: balances.coupon,
|
||||||
},
|
},
|
||||||
tips: [
|
tips: [
|
||||||
"预估 BMT数= 输入可用积分数÷BMT 实时价格。",
|
`预估BMT数=输入可用积分数 ÷ ${exchangeConfig.point} × ${exchangeConfig.redeemNum}BMT个数。`,
|
||||||
`兑换会同步消耗算力, 1 点可用积分,需同步消耗${powerRate}点算力。`,
|
`兑换会同步消耗算力、BMTR、${exchangeConfig.point}点可用积分,需同步消耗${exchangeConfig.cPower}点算力和${exchangeConfig.bmtr}个BMTR`,
|
||||||
"仅支持 100 的正整数倍, 不足 100的可用积分无法发起兑换。",
|
`仅支持100的正整数倍,不足100的可用积分无法发起兑换`,
|
||||||
"凌晨00:00至02:00为积分维护时段,期间暂停兑换服务,请避开该时间段操作。",
|
`凌晨00:00至02:00为积分维护时段,期间暂停兑换服务,请避开该时间段操作。`,
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
@ -2668,8 +2941,12 @@ export async function fetchWithdrawDetail(requestOptions) {
|
||||||
]);
|
]);
|
||||||
const ticker = normalizeTicker(result[0]);
|
const ticker = normalizeTicker(result[0]);
|
||||||
const balances = normalizeBalances(result[1]);
|
const balances = normalizeBalances(result[1]);
|
||||||
const walletPayload = buildWalletPayload(result[2] && result[2].address);
|
const walletPayload = buildWalletPayload(result[2]);
|
||||||
const withdrawRate = resolvePercentRate(result[3]);
|
const withdrawRate = resolvePercentRate(result[3]);
|
||||||
|
const defaultWallet =
|
||||||
|
walletPayload.wallets.find(function (wallet) {
|
||||||
|
return wallet.isDefault;
|
||||||
|
}) || walletPayload.wallets[0] || null;
|
||||||
|
|
||||||
setHomeTickerCache(ticker);
|
setHomeTickerCache(ticker);
|
||||||
|
|
||||||
|
|
@ -2683,7 +2960,7 @@ export async function fetchWithdrawDetail(requestOptions) {
|
||||||
brokerage_price: toFixedNumber(balances.balance, 2),
|
brokerage_price: toFixedNumber(balances.balance, 2),
|
||||||
},
|
},
|
||||||
wallets: walletPayload.wallets,
|
wallets: walletPayload.wallets,
|
||||||
defaultWallet: walletPayload.wallets[0] || null,
|
defaultWallet: defaultWallet,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -2997,26 +3274,47 @@ export async function fetchVoucherCenterPage(
|
||||||
|
|
||||||
export async function fetchWalletDetail(requestOptions) {
|
export async function fetchWalletDetail(requestOptions) {
|
||||||
const data = await fetchWalletAddressData(requestOptions);
|
const data = await fetchWalletAddressData(requestOptions);
|
||||||
return buildWalletPayload(data && data.address);
|
return buildWalletPayload(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function saveAssetWallet(payload, requestOptions) {
|
export async function saveAssetWallet(payload, requestOptions) {
|
||||||
const address = String(
|
const rawAddress = String(
|
||||||
payload && payload.address ? payload.address : "",
|
payload && payload.address ? payload.address : "",
|
||||||
).trim();
|
).trim();
|
||||||
|
const name = String(payload && payload.name ? payload.name : "").trim();
|
||||||
|
const type = Number(payload && payload.type) === 1 ? 1 : 0;
|
||||||
|
const addressList = rawAddress
|
||||||
|
.split(/[\n,;]+/)
|
||||||
|
.map(function (address) {
|
||||||
|
return String(address || "").trim();
|
||||||
|
})
|
||||||
|
.filter(Boolean)
|
||||||
|
.filter(function (address, index, list) {
|
||||||
|
return list.indexOf(address) === index;
|
||||||
|
});
|
||||||
|
const address = type === 1 ? addressList.join(",") : addressList[0] || "";
|
||||||
|
|
||||||
if (!address) {
|
if (!address) {
|
||||||
throw createError("请输入钱包地址");
|
throw createError("请输入钱包地址");
|
||||||
}
|
}
|
||||||
|
if (type === 0 && addressList.length > 1) {
|
||||||
|
throw createError("默认钱包只能填写一个地址");
|
||||||
|
}
|
||||||
|
|
||||||
|
const requestData = {
|
||||||
|
address: address,
|
||||||
|
type: type,
|
||||||
|
};
|
||||||
|
if (name) {
|
||||||
|
requestData.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
await fetchPayload(
|
await fetchPayload(
|
||||||
createRequestOptions(
|
createRequestOptions(
|
||||||
{
|
{
|
||||||
url: serviceConfig.ENDPOINTS.walletSave,
|
url: serviceConfig.ENDPOINTS.walletSave,
|
||||||
method: "POST",
|
method: "POST",
|
||||||
data: {
|
data: requestData,
|
||||||
address: address,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
requestOptions,
|
requestOptions,
|
||||||
),
|
),
|
||||||
|
|
@ -3028,26 +3326,6 @@ export async function saveAssetWallet(payload, requestOptions) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function deleteAssetWallet(id, requestOptions) {
|
|
||||||
await fetchPayload(
|
|
||||||
createRequestOptions(
|
|
||||||
{
|
|
||||||
url: serviceConfig.ENDPOINTS.walletSave,
|
|
||||||
method: "POST",
|
|
||||||
data: {
|
|
||||||
address: "",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
requestOptions,
|
|
||||||
),
|
|
||||||
"删除失败",
|
|
||||||
);
|
|
||||||
|
|
||||||
return {
|
|
||||||
success: true,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function padTimeUnit(value) {
|
function padTimeUnit(value) {
|
||||||
return value < 10 ? "0" + value : String(value);
|
return value < 10 ? "0" + value : String(value);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -75,9 +75,14 @@ export default {
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.wallet-dialog__message {
|
.wallet-dialog__message {
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 24rpx;
|
padding: 16rpx 18rpx;
|
||||||
|
border-left: 6rpx solid #ff5f6d;
|
||||||
|
border-radius: 6rpx;
|
||||||
|
background: rgba(255, 82, 96, 0.12);
|
||||||
|
font-size: 28rpx;
|
||||||
|
font-weight: 700;
|
||||||
line-height: 1.6;
|
line-height: 1.6;
|
||||||
color: #edf2ff;
|
color: #ff6976;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wallet-dialog__address {
|
.wallet-dialog__address {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ const serviceConfig = {
|
||||||
bmtFlashExchangeSubmit: "/api/hn/redeem/justRedeem",
|
bmtFlashExchangeSubmit: "/api/hn/redeem/justRedeem",
|
||||||
bmtrExchangePercent: "/api/hn/redeem/getBmtrPercent",
|
bmtrExchangePercent: "/api/hn/redeem/getBmtrPercent",
|
||||||
powerExchangeMuit: "/api/hn/redeem/getMuit",
|
powerExchangeMuit: "/api/hn/redeem/getMuit",
|
||||||
bmtRedeemPowerRate: "/api/hn/redeem/getRedeemPowerRate",
|
bmtRedeemConfig: "/api/hn/redeem/getConfigSet",
|
||||||
bmtExchangeSubmit: "/api/hn/redeem/redeem_bmt",
|
bmtExchangeSubmit: "/api/hn/redeem/redeem_bmt",
|
||||||
getUser: "/api/mxj/api/get_user",
|
getUser: "/api/mxj/api/get_user",
|
||||||
transferFee: "/api/hn/transfer/getProp",
|
transferFee: "/api/hn/transfer/getProp",
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,18 @@
|
||||||
<text class="info-row__value asset-number-font">{{ displayCoupon }}</text>
|
<text class="info-row__value asset-number-font">{{ displayCoupon }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
<view class="info-row">
|
||||||
|
<view class="info-row__left">
|
||||||
|
<image
|
||||||
|
class="info-row__icon"
|
||||||
|
:src="pageIcon('bmtr')"
|
||||||
|
mode="aspectFit"
|
||||||
|
></image>
|
||||||
|
<text class="info-row__label">BMTR数量</text>
|
||||||
|
</view>
|
||||||
|
<text class="info-row__value asset-number-font">{{ displayBmtr }}</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
<view class="info-row info-row--last">
|
<view class="info-row info-row--last">
|
||||||
<view class="info-row__left">
|
<view class="info-row__left">
|
||||||
<image
|
<image
|
||||||
|
|
@ -105,6 +117,16 @@
|
||||||
powerCost
|
powerCost
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="preview-card__row">
|
||||||
|
<view class="preview-card__left">
|
||||||
|
<text class="preview-card__label preview-card__label--light"
|
||||||
|
>消耗BMTR</text
|
||||||
|
>
|
||||||
|
</view>
|
||||||
|
<text class="preview-card__value preview-card__value--light asset-number-font">{{
|
||||||
|
bmtrCost
|
||||||
|
}}</text>
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="tips-block">
|
<view class="tips-block">
|
||||||
|
|
@ -153,6 +175,10 @@
|
||||||
<text class="meta-pair__label">消耗算力:</text>
|
<text class="meta-pair__label">消耗算力:</text>
|
||||||
<text class="meta-pair__value asset-number-font">{{ powerCost }}</text>
|
<text class="meta-pair__value asset-number-font">{{ powerCost }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="popup-line">
|
||||||
|
<text class="meta-pair__label">消耗BMTR:</text>
|
||||||
|
<text class="meta-pair__value asset-number-font">{{ bmtrCost }}</text>
|
||||||
|
</view>
|
||||||
</asset-confirm-popup>
|
</asset-confirm-popup>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
@ -177,6 +203,7 @@ export default {
|
||||||
detail: {
|
detail: {
|
||||||
ticker: {},
|
ticker: {},
|
||||||
balances: {},
|
balances: {},
|
||||||
|
exchangeConfig: {},
|
||||||
tips: [],
|
tips: [],
|
||||||
},
|
},
|
||||||
hasShown: false,
|
hasShown: false,
|
||||||
|
|
@ -202,8 +229,17 @@ export default {
|
||||||
pointsValue() {
|
pointsValue() {
|
||||||
return Number(this.form.points || 0);
|
return Number(this.form.points || 0);
|
||||||
},
|
},
|
||||||
powerRateNumber() {
|
configPointNumber() {
|
||||||
return Number(this.detail.powerRate || 0);
|
return Number(this.detail.exchangeConfig.point || 0);
|
||||||
|
},
|
||||||
|
configPowerNumber() {
|
||||||
|
return Number(this.detail.exchangeConfig.cPower || 0);
|
||||||
|
},
|
||||||
|
configBmtrNumber() {
|
||||||
|
return Number(this.detail.exchangeConfig.bmtr || 0);
|
||||||
|
},
|
||||||
|
redeemNumNumber() {
|
||||||
|
return Number(this.detail.exchangeConfig.redeemNum || 0);
|
||||||
},
|
},
|
||||||
estimateBmt() {
|
estimateBmt() {
|
||||||
if (!this.pointsValue) {
|
if (!this.pointsValue) {
|
||||||
|
|
@ -217,22 +253,36 @@ export default {
|
||||||
return this.formatAmount(this.pointsValue / price, 2);
|
return this.formatAmount(this.pointsValue / price, 2);
|
||||||
},
|
},
|
||||||
powerCost() {
|
powerCost() {
|
||||||
if (!this.pointsValue || !this.powerRateNumber) {
|
if (!this.pointsValue || !this.configPointNumber) {
|
||||||
return "0.00";
|
return "0.00";
|
||||||
}
|
}
|
||||||
|
|
||||||
return (this.pointsValue * this.powerRateNumber).toFixed(2);
|
return (
|
||||||
|
(this.pointsValue / this.configPointNumber) * this.configPowerNumber
|
||||||
|
).toFixed(2);
|
||||||
|
},
|
||||||
|
bmtrCostNumber() {
|
||||||
|
if (!this.pointsValue || !this.configPointNumber) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
(this.pointsValue / this.configPointNumber) * this.configBmtrNumber
|
||||||
|
);
|
||||||
|
},
|
||||||
|
bmtrCost() {
|
||||||
|
return this.formatAmount(this.bmtrCostNumber, 4);
|
||||||
},
|
},
|
||||||
allEstimateBmt() {
|
allEstimateBmt() {
|
||||||
const points = Number(this.detail.balances.points || 0);
|
const points = Number(this.detail.balances.points || 0);
|
||||||
const compute = Number(this.detail.balances.power || 0);
|
|
||||||
const price = this.priceNumber;
|
const price = this.priceNumber;
|
||||||
|
|
||||||
if (!price) {
|
if (!price) {
|
||||||
return "0";
|
return "0.00";
|
||||||
}
|
}
|
||||||
const estimatedBmt = Math.min(points, compute * 10) / price;
|
|
||||||
return this.formatAmount(Math.max(0, estimatedBmt), 2);
|
const truncatedBmt = Math.floor((points / price) * 100) / 100;
|
||||||
|
return this.formatAmount(truncatedBmt, 2);
|
||||||
},
|
},
|
||||||
priceNumber() {
|
priceNumber() {
|
||||||
return Number(
|
return Number(
|
||||||
|
|
@ -248,6 +298,9 @@ export default {
|
||||||
displayCoupon() {
|
displayCoupon() {
|
||||||
return this.detail.balances.points;
|
return this.detail.balances.points;
|
||||||
},
|
},
|
||||||
|
displayBmtr() {
|
||||||
|
return this.formatAmount(this.detail.balances.bmtr, 4);
|
||||||
|
},
|
||||||
displayPrice() {
|
displayPrice() {
|
||||||
return this.priceNumber ? this.priceNumber : "0.00";
|
return this.priceNumber ? this.priceNumber : "0.00";
|
||||||
},
|
},
|
||||||
|
|
@ -257,10 +310,11 @@ export default {
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"1.BMT=积分-BMT实时价格;",
|
"BMT=积分-BMT实时价格;",
|
||||||
"2.只能兑换100的整数倍,小于100积分不可兑换;",
|
`消耗算力=输入可用积分数÷${this.configPointNumber}×${this.configPowerNumber};`,
|
||||||
"3.凌晨0点-凌晨1点积分系统维护不可兑换;",
|
`消耗BMTR=输入可用积分数÷${this.configPointNumber}×${this.configBmtrNumber};`,
|
||||||
"4.可用积分不足,可以将释放中的积分转换成可用积分0。",
|
`只能兑换${this.redeemNumNumber}的整数倍,小于${this.redeemNumNumber}积分不可兑换;`,
|
||||||
|
"凌晨0点-凌晨1点积分系统维护不可兑换;",
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -274,6 +328,7 @@ export default {
|
||||||
voucher: "https://imgs.agrimedia.cn/bm-bmt/quan-icon-g%20%281%29.png",
|
voucher: "https://imgs.agrimedia.cn/bm-bmt/quan-icon-g%20%281%29.png",
|
||||||
points: "https://imgs.agrimedia.cn/bm-bmt/j.png",
|
points: "https://imgs.agrimedia.cn/bm-bmt/j.png",
|
||||||
coupon: "https://imgs.agrimedia.cn/bm-bmt/xiaofei-icon-o.png",
|
coupon: "https://imgs.agrimedia.cn/bm-bmt/xiaofei-icon-o.png",
|
||||||
|
bmtr: "https://imgs.agrimedia.cn/webimg/202607171808386371853.svg",
|
||||||
};
|
};
|
||||||
return iconMap[type] || "";
|
return iconMap[type] || "";
|
||||||
},
|
},
|
||||||
|
|
@ -331,17 +386,25 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pointsValue < 100) {
|
if (!this.configPointNumber) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "小于100积分不可兑换",
|
title: "兑换配置加载失败,请稍后重试",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.pointsValue % 100 !== 0) {
|
if (this.redeemNumNumber && this.pointsValue < this.redeemNumNumber) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "只能兑换100的整数倍",
|
title: `小于${this.redeemNumNumber}积分不可兑换`,
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.redeemNumNumber && this.pointsValue % this.redeemNumNumber !== 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: `只能兑换${this.redeemNumNumber}的整数倍`,
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
|
|
@ -363,6 +426,14 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.bmtrCostNumber > Number(this.detail.balances.bmtr || 0)) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "BMTR数量不足",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.submitting = true;
|
this.submitting = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -635,6 +706,10 @@ export default {
|
||||||
color: rgba(26, 210, 150, 1);
|
color: rgba(26, 210, 150, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.preview-card__label--light {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
.preview-card__value {
|
.preview-card__value {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
font-weight: 800;
|
font-weight: 800;
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
<wallet-action-popup
|
<wallet-action-popup
|
||||||
:visible="confirmVisible"
|
:visible="confirmVisible"
|
||||||
:title="form.id ? '修改钱包' : '新增钱包'"
|
:title="form.id ? '修改钱包' : '新增钱包'"
|
||||||
:message="form.id ? '确认修改钱包新地址' : '确认保存钱包地址'"
|
message="钱包地址确认后,无法修改,请仔细核对钱包地址"
|
||||||
:address="trimmedAddress"
|
:address="trimmedAddress"
|
||||||
description="请仔细核对钱包地址,以免造成财产损失"
|
description="请仔细核对钱包地址,以免造成财产损失"
|
||||||
confirm-text="确认"
|
confirm-text="确认"
|
||||||
|
|
@ -168,6 +168,7 @@ export default {
|
||||||
id: this.form.id,
|
id: this.form.id,
|
||||||
name: this.form.name,
|
name: this.form.name,
|
||||||
address: this.trimmedAddress,
|
address: this.trimmedAddress,
|
||||||
|
type: 0,
|
||||||
}, {
|
}, {
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
loadingText: "保存中",
|
loadingText: "保存中",
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,9 @@
|
||||||
>复制地址</text
|
>复制地址</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
<view class="wallet-edit-dialog__desc" style="font-size: 26rpx">
|
||||||
|
钱包地址确认后,无法多次修改,请仔细核对钱包地址!
|
||||||
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-else class="wallet-panel__new">
|
<view v-else class="wallet-panel__new">
|
||||||
|
|
@ -43,20 +46,76 @@
|
||||||
<text class="wallet-panel__helper">
|
<text class="wallet-panel__helper">
|
||||||
钱包地址请在【海南农综】APP中获取
|
钱包地址请在【海南农综】APP中获取
|
||||||
</text>
|
</text>
|
||||||
|
<view class="wallet-edit-dialog__desc" style="font-size: 26rpx">
|
||||||
|
钱包地址确认后,无法多次修改,请仔细核对钱包地址!
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="showMoreWalletSection" class="wallet-panel wallet-panel--more">
|
||||||
|
<view class="wallet-panel__head">
|
||||||
|
<view class="wallet-panel__title">
|
||||||
|
<view class="wallet-panel__title-icon">
|
||||||
|
<view class="wallet-panel__title-tab"></view>
|
||||||
|
<view class="wallet-panel__title-body"></view>
|
||||||
|
</view>
|
||||||
|
<text class="wallet-panel__title-text">其他钱包地址</text>
|
||||||
|
</view>
|
||||||
|
<text class="wallet-panel__subtitle">{{ moreAddressNum }} 个</text>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view v-if="moreWallets.length" class="wallet-more-list">
|
||||||
|
<view
|
||||||
|
v-for="(wallet, index) in moreWallets"
|
||||||
|
:key="wallet.id"
|
||||||
|
class="wallet-more-item"
|
||||||
|
>
|
||||||
|
<view class="wallet-more-item__head">
|
||||||
|
<text class="wallet-more-item__name">
|
||||||
|
{{ wallet.name || "钱包地址 " + (index + 1) }}
|
||||||
|
</text>
|
||||||
|
<text class="wallet-panel__copy" @click="copy(wallet.address)">
|
||||||
|
复制地址
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
<text class="wallet-more-item__address asset-number-font">{{
|
||||||
|
wallet.address
|
||||||
|
}}</text>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<text v-else class="wallet-more-empty">暂未添加其他钱包地址</text>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view
|
||||||
|
v-if="canAddMoreWallet"
|
||||||
|
class="wallet-more-action wallet-more-action--standalone"
|
||||||
|
@click="openMoreAddressDialog"
|
||||||
|
>
|
||||||
|
添加钱包地址
|
||||||
|
</view>
|
||||||
|
|
||||||
<view
|
<view
|
||||||
class="wallet-actions"
|
class="wallet-actions"
|
||||||
:class="{ 'wallet-actions--compact': !currentWallet }"
|
:class="{
|
||||||
|
'wallet-actions--compact': !currentWallet,
|
||||||
|
'wallet-actions--single': currentWallet && !canModifyWallet,
|
||||||
|
}"
|
||||||
>
|
>
|
||||||
<view
|
<view
|
||||||
|
v-if="!currentWallet || canModifyWallet"
|
||||||
class="wallet-button wallet-button--primary"
|
class="wallet-button wallet-button--primary"
|
||||||
@touchend.stop.prevent="handlePrimaryAction"
|
@touchend.stop.prevent="handlePrimaryAction"
|
||||||
@tap.stop="handlePrimaryAction"
|
@tap.stop="handlePrimaryAction"
|
||||||
@click.stop="handlePrimaryAction"
|
@click.stop="handlePrimaryAction"
|
||||||
>
|
>
|
||||||
{{ currentWallet ? "修改钱包地址" : savingAddress ? "保存中..." : "保存" }}
|
{{
|
||||||
|
currentWallet
|
||||||
|
? "修改默认地址"
|
||||||
|
: savingAddress
|
||||||
|
? "保存中..."
|
||||||
|
: "保存"
|
||||||
|
}}
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="wallet-button wallet-button--secondary"
|
class="wallet-button wallet-button--secondary"
|
||||||
|
|
@ -77,24 +136,28 @@
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<text
|
|
||||||
v-if="currentWallet"
|
|
||||||
class="wallet-delete"
|
|
||||||
@click="openDeleteDialog"
|
|
||||||
>
|
|
||||||
删除地址
|
|
||||||
</text>
|
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<wallet-action-popup
|
<wallet-action-popup
|
||||||
:visible="deleteDialogVisible"
|
:visible="createConfirmVisible"
|
||||||
title="删除钱包"
|
title="新增钱包"
|
||||||
message="确认删除钱包地址"
|
message="钱包地址确认后,无法修改,请仔细核对钱包地址"
|
||||||
:address="currentWallet ? currentWallet.address : ''"
|
:address="trimmedDraftAddress"
|
||||||
confirm-text="确认"
|
confirm-text="确认添加"
|
||||||
cancel-text="取消"
|
cancel-text="返回检查"
|
||||||
@cancel="deleteDialogVisible = false"
|
@cancel="createConfirmVisible = false"
|
||||||
@confirm="remove"
|
@confirm="saveCurrentAddress"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<wallet-action-popup
|
||||||
|
:visible="editConfirmVisible"
|
||||||
|
title="修改钱包"
|
||||||
|
message="钱包地址确认后,无法修改,请仔细核对钱包地址"
|
||||||
|
:address="pendingEditAddress"
|
||||||
|
confirm-text="确认修改"
|
||||||
|
cancel-text="返回检查"
|
||||||
|
@cancel="cancelEditConfirm"
|
||||||
|
@confirm="saveEditedAddress"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<asset-confirm-popup
|
<asset-confirm-popup
|
||||||
|
|
@ -121,12 +184,64 @@
|
||||||
粘贴
|
粘贴
|
||||||
</text> -->
|
</text> -->
|
||||||
</view>
|
</view>
|
||||||
<text class="wallet-edit-dialog__desc asset-number-font">
|
<text class="wallet-edit-dialog__desc asset-number-font" style="font-size: 28rpx">
|
||||||
*请仔细核对钱包地址,以免造成财产损失
|
*请仔细核对钱包地址,以免造成财产损失
|
||||||
</text>
|
</text>
|
||||||
</view>
|
</view>
|
||||||
</asset-confirm-popup>
|
</asset-confirm-popup>
|
||||||
|
|
||||||
|
<asset-confirm-popup
|
||||||
|
class="wallet-edit-popup"
|
||||||
|
:visible="moreAddressDialogVisible"
|
||||||
|
title="添加钱包地址"
|
||||||
|
confirm-text="下一步"
|
||||||
|
cancel-text="取消"
|
||||||
|
:close-on-mask="false"
|
||||||
|
@cancel="closeMoreAddressDialog"
|
||||||
|
@confirm="confirmMoreAddresses"
|
||||||
|
>
|
||||||
|
<view class="wallet-edit-dialog">
|
||||||
|
<text class="wallet-edit-dialog__label">钱包名称</text>
|
||||||
|
<view class="wallet-edit-dialog__box wallet-edit-dialog__box--input">
|
||||||
|
<input
|
||||||
|
v-model="moreWalletName"
|
||||||
|
class="wallet-edit-dialog__input"
|
||||||
|
type="text"
|
||||||
|
placeholder="请输入钱包名称(选填)"
|
||||||
|
placeholder-style="color:rgba(165,175,208,0.82);font-size:28rpx;"
|
||||||
|
:maxlength="30"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text class="wallet-edit-dialog__label wallet-edit-dialog__label--address">
|
||||||
|
钱包地址
|
||||||
|
</text>
|
||||||
|
<view class="wallet-edit-dialog__box wallet-edit-dialog__box--textarea">
|
||||||
|
<textarea
|
||||||
|
v-model="moreAddressInput"
|
||||||
|
class="wallet-edit-dialog__textarea asset-number-font"
|
||||||
|
placeholder="请输入钱包地址"
|
||||||
|
placeholder-style="color:rgba(165,175,208,0.82);font-size:28rpx;"
|
||||||
|
:maxlength="-1"
|
||||||
|
/>
|
||||||
|
</view>
|
||||||
|
<text class="wallet-edit-dialog__desc">
|
||||||
|
*钱包地址确认后,无法修改,请仔细核对钱包地址
|
||||||
|
</text>
|
||||||
|
</view>
|
||||||
|
</asset-confirm-popup>
|
||||||
|
|
||||||
|
<wallet-action-popup
|
||||||
|
:visible="moreAddressConfirmVisible"
|
||||||
|
title="确认添加钱包"
|
||||||
|
message="钱包地址确认后,无法修改,请仔细核对钱包地址"
|
||||||
|
:address="pendingMoreAddress"
|
||||||
|
:description="moreAddressConfirmDescription"
|
||||||
|
confirm-text="确认添加"
|
||||||
|
cancel-text="返回检查"
|
||||||
|
@cancel="cancelMoreAddressConfirm"
|
||||||
|
@confirm="saveMoreAddresses"
|
||||||
|
/>
|
||||||
|
|
||||||
<view v-if="successTipVisible" class="wallet-success-tip">
|
<view v-if="successTipVisible" class="wallet-success-tip">
|
||||||
<image
|
<image
|
||||||
class="wallet-success-tip__icon"
|
class="wallet-success-tip__icon"
|
||||||
|
|
@ -144,7 +259,6 @@ import AssetConfirmPopup from "../../components/asset-confirm-popup.vue";
|
||||||
import WalletActionPopup from "../../components/wallet-action-popup.vue";
|
import WalletActionPopup from "../../components/wallet-action-popup.vue";
|
||||||
import {
|
import {
|
||||||
fetchWalletDetail,
|
fetchWalletDetail,
|
||||||
deleteAssetWallet,
|
|
||||||
saveAssetWallet,
|
saveAssetWallet,
|
||||||
} from "../../api/assets";
|
} from "../../api/assets";
|
||||||
|
|
||||||
|
|
@ -161,8 +275,19 @@ export default {
|
||||||
savingAddress: false,
|
savingAddress: false,
|
||||||
editDialogVisible: false,
|
editDialogVisible: false,
|
||||||
editAddress: "",
|
editAddress: "",
|
||||||
|
pendingEditAddress: "",
|
||||||
|
moreAddressInput: "",
|
||||||
|
moreWalletName: "",
|
||||||
|
pendingMoreAddress: "",
|
||||||
|
pendingMoreWalletName: "",
|
||||||
editingAddress: false,
|
editingAddress: false,
|
||||||
deleteDialogVisible: false,
|
savingMoreAddress: false,
|
||||||
|
createConfirmVisible: false,
|
||||||
|
editConfirmVisible: false,
|
||||||
|
moreAddressDialogVisible: false,
|
||||||
|
moreAddressConfirmVisible: false,
|
||||||
|
walletCanModify: false,
|
||||||
|
moreAddressNum: 0,
|
||||||
successTipVisible: false,
|
successTipVisible: false,
|
||||||
successTipText: "",
|
successTipText: "",
|
||||||
successTipTimer: null,
|
successTipTimer: null,
|
||||||
|
|
@ -176,9 +301,6 @@ export default {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
onLoad() {
|
|
||||||
this.loadPage();
|
|
||||||
},
|
|
||||||
onShow() {
|
onShow() {
|
||||||
this.loadPage();
|
this.loadPage();
|
||||||
},
|
},
|
||||||
|
|
@ -193,7 +315,21 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.wallets[0] || null;
|
return null;
|
||||||
|
},
|
||||||
|
moreWallets() {
|
||||||
|
return this.wallets.filter(function (wallet) {
|
||||||
|
return !wallet.isDefault;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showMoreWalletSection() {
|
||||||
|
return Boolean(this.currentWallet) && this.moreAddressNum > 0;
|
||||||
|
},
|
||||||
|
remainingMoreAddressCount() {
|
||||||
|
return Math.max(0, this.moreAddressNum - this.moreWallets.length);
|
||||||
|
},
|
||||||
|
canAddMoreWallet() {
|
||||||
|
return Boolean(this.currentWallet) && this.remainingMoreAddressCount > 0;
|
||||||
},
|
},
|
||||||
trimmedDraftAddress() {
|
trimmedDraftAddress() {
|
||||||
return String(this.draftAddress || "").trim();
|
return String(this.draftAddress || "").trim();
|
||||||
|
|
@ -201,12 +337,33 @@ export default {
|
||||||
trimmedEditAddress() {
|
trimmedEditAddress() {
|
||||||
return String(this.editAddress || "").trim();
|
return String(this.editAddress || "").trim();
|
||||||
},
|
},
|
||||||
|
trimmedMoreWalletName() {
|
||||||
|
return String(this.moreWalletName || "").trim();
|
||||||
|
},
|
||||||
|
moreAddressConfirmDescription() {
|
||||||
|
if (this.pendingMoreWalletName) {
|
||||||
|
return "钱包名称:" + this.pendingMoreWalletName;
|
||||||
|
}
|
||||||
|
return "多个钱包地址将使用英文逗号分隔后提交";
|
||||||
|
},
|
||||||
|
canModifyWallet() {
|
||||||
|
if (!this.currentWallet) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.walletCanModify;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async loadPage() {
|
async loadPage() {
|
||||||
try {
|
try {
|
||||||
const result = await fetchWalletDetail();
|
const result = await fetchWalletDetail();
|
||||||
this.wallets = result.wallets || [];
|
this.wallets = result.wallets || [];
|
||||||
|
this.walletCanModify = Boolean(result.canModify);
|
||||||
|
const moreAddressNum = Number(result.moreAddressNum || 0);
|
||||||
|
this.moreAddressNum = Number.isFinite(moreAddressNum)
|
||||||
|
? Math.max(0, Math.floor(moreAddressNum))
|
||||||
|
: 0;
|
||||||
if (this.currentWallet) {
|
if (this.currentWallet) {
|
||||||
this.draftAddress = this.currentWallet.address || "";
|
this.draftAddress = this.currentWallet.address || "";
|
||||||
}
|
}
|
||||||
|
|
@ -271,11 +428,25 @@ export default {
|
||||||
this.primaryActionAt = now;
|
this.primaryActionAt = now;
|
||||||
|
|
||||||
if (this.currentWallet) {
|
if (this.currentWallet) {
|
||||||
|
if (!this.canModifyWallet) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.openEditDialog();
|
this.openEditDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.saveCurrentAddress();
|
this.openCreateConfirm();
|
||||||
|
},
|
||||||
|
openCreateConfirm() {
|
||||||
|
if (!this.trimmedDraftAddress) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "请先粘贴钱包地址",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.createConfirmVisible = true;
|
||||||
},
|
},
|
||||||
openEditDialog() {
|
openEditDialog() {
|
||||||
if (!this.currentWallet) {
|
if (!this.currentWallet) {
|
||||||
|
|
@ -292,7 +463,11 @@ export default {
|
||||||
closeEditDialog() {
|
closeEditDialog() {
|
||||||
this.editDialogVisible = false;
|
this.editDialogVisible = false;
|
||||||
this.editAddress = "";
|
this.editAddress = "";
|
||||||
this.editingAddress = false;
|
},
|
||||||
|
cancelEditConfirm() {
|
||||||
|
this.editConfirmVisible = false;
|
||||||
|
this.editAddress = this.pendingEditAddress;
|
||||||
|
this.editDialogVisible = true;
|
||||||
},
|
},
|
||||||
pasteEditAddress() {
|
pasteEditAddress() {
|
||||||
uni.getClipboardData({
|
uni.getClipboardData({
|
||||||
|
|
@ -332,8 +507,8 @@ export default {
|
||||||
this.successTipTimer = null;
|
this.successTipTimer = null;
|
||||||
}, 1400);
|
}, 1400);
|
||||||
},
|
},
|
||||||
async confirmEditAddress() {
|
confirmEditAddress() {
|
||||||
if (!this.currentWallet || this.editingAddress) {
|
if (!this.currentWallet || !this.canModifyWallet || this.editingAddress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -345,14 +520,27 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.pendingEditAddress = this.trimmedEditAddress;
|
||||||
|
this.editDialogVisible = false;
|
||||||
|
this.editConfirmVisible = true;
|
||||||
|
},
|
||||||
|
async saveEditedAddress() {
|
||||||
|
if (
|
||||||
|
!this.currentWallet ||
|
||||||
|
!this.canModifyWallet ||
|
||||||
|
!this.pendingEditAddress ||
|
||||||
|
this.editingAddress
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.editingAddress = true;
|
this.editingAddress = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await saveAssetWallet(
|
await saveAssetWallet(
|
||||||
{
|
{
|
||||||
id: this.currentWallet.id,
|
address: this.pendingEditAddress,
|
||||||
name: this.currentWallet.name,
|
type: 0,
|
||||||
address: this.trimmedEditAddress,
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
|
|
@ -360,7 +548,9 @@ export default {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
this.closeEditDialog();
|
this.editConfirmVisible = false;
|
||||||
|
this.editAddress = "";
|
||||||
|
this.pendingEditAddress = "";
|
||||||
this.showSuccessTip("修改成功!");
|
this.showSuccessTip("修改成功!");
|
||||||
|
|
||||||
this.loadPage();
|
this.loadPage();
|
||||||
|
|
@ -392,6 +582,7 @@ export default {
|
||||||
await saveAssetWallet(
|
await saveAssetWallet(
|
||||||
{
|
{
|
||||||
address: this.trimmedDraftAddress,
|
address: this.trimmedDraftAddress,
|
||||||
|
type: 0,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
|
|
@ -399,6 +590,7 @@ export default {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.createConfirmVisible = false;
|
||||||
this.showSuccessTip("保存成功!");
|
this.showSuccessTip("保存成功!");
|
||||||
|
|
||||||
this.loadPage();
|
this.loadPage();
|
||||||
|
|
@ -411,29 +603,130 @@ export default {
|
||||||
this.savingAddress = false;
|
this.savingAddress = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
openDeleteDialog() {
|
normalizeMoreAddresses(value) {
|
||||||
if (!this.currentWallet) {
|
return String(value || "")
|
||||||
return;
|
.split(/[\n,;]+/)
|
||||||
}
|
.map(function (address) {
|
||||||
|
return String(address || "").trim();
|
||||||
this.deleteDialogVisible = true;
|
})
|
||||||
|
.filter(Boolean)
|
||||||
|
.filter(function (address, index, list) {
|
||||||
|
return list.indexOf(address) === index;
|
||||||
|
});
|
||||||
},
|
},
|
||||||
async remove() {
|
openMoreAddressDialog() {
|
||||||
if (!this.currentWallet) {
|
if (!this.canAddMoreWallet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
this.moreAddressInput = "";
|
||||||
await deleteAssetWallet(this.currentWallet.id);
|
this.moreWalletName = "";
|
||||||
this.deleteDialogVisible = false;
|
this.moreAddressDialogVisible = true;
|
||||||
this.draftAddress = '';
|
},
|
||||||
this.showSuccessTip("删除成功!");
|
closeMoreAddressDialog() {
|
||||||
this.loadPage();
|
this.moreAddressDialogVisible = false;
|
||||||
} catch (error) {
|
this.moreAddressInput = "";
|
||||||
|
this.moreWalletName = "";
|
||||||
|
},
|
||||||
|
confirmMoreAddresses() {
|
||||||
|
const addresses = this.normalizeMoreAddresses(this.moreAddressInput);
|
||||||
|
|
||||||
|
if (!addresses.length) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: error.message || "删除失败",
|
title: "请输入至少一个钱包地址",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
});
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addresses.length > this.remainingMoreAddressCount) {
|
||||||
|
uni.showToast({
|
||||||
|
title:
|
||||||
|
"最多还可添加" +
|
||||||
|
this.remainingMoreAddressCount +
|
||||||
|
"个钱包地址",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.trimmedMoreWalletName && addresses.length > 1) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "设置钱包名称时一次只能添加一个地址",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (addresses.indexOf(this.currentWallet.address) >= 0) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "其他地址不能与默认地址相同",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const existingAddresses = this.moreWallets.map(function (wallet) {
|
||||||
|
return wallet.address;
|
||||||
|
});
|
||||||
|
if (addresses.some(function (address) {
|
||||||
|
return existingAddresses.indexOf(address) >= 0;
|
||||||
|
})) {
|
||||||
|
uni.showToast({
|
||||||
|
title: "输入的钱包地址已存在",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.pendingMoreAddress = addresses.join(",");
|
||||||
|
this.pendingMoreWalletName = this.trimmedMoreWalletName;
|
||||||
|
this.moreAddressDialogVisible = false;
|
||||||
|
this.moreAddressConfirmVisible = true;
|
||||||
|
},
|
||||||
|
cancelMoreAddressConfirm() {
|
||||||
|
this.moreAddressConfirmVisible = false;
|
||||||
|
this.moreAddressInput = this.pendingMoreAddress.replace(/,/g, "\n");
|
||||||
|
this.moreWalletName = this.pendingMoreWalletName;
|
||||||
|
this.moreAddressDialogVisible = true;
|
||||||
|
},
|
||||||
|
async saveMoreAddresses() {
|
||||||
|
if (
|
||||||
|
!this.canAddMoreWallet ||
|
||||||
|
!this.pendingMoreAddress ||
|
||||||
|
this.savingMoreAddress
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.savingMoreAddress = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
await saveAssetWallet(
|
||||||
|
{
|
||||||
|
address: this.pendingMoreAddress,
|
||||||
|
name: this.pendingMoreWalletName,
|
||||||
|
type: 1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
showLoading: true,
|
||||||
|
loadingText: "保存中",
|
||||||
|
},
|
||||||
|
);
|
||||||
|
this.moreAddressConfirmVisible = false;
|
||||||
|
this.moreAddressInput = "";
|
||||||
|
this.moreWalletName = "";
|
||||||
|
this.pendingMoreAddress = "";
|
||||||
|
this.pendingMoreWalletName = "";
|
||||||
|
this.showSuccessTip("添加成功!");
|
||||||
|
await this.loadPage();
|
||||||
|
} catch (error) {
|
||||||
|
uni.showToast({
|
||||||
|
title: error.message || "保存失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
} finally {
|
||||||
|
this.savingMoreAddress = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -463,6 +756,10 @@ export default {
|
||||||
box-shadow: 0 12rpx 24rpx rgba(8, 13, 30, 0.12);
|
box-shadow: 0 12rpx 24rpx rgba(8, 13, 30, 0.12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-panel--more {
|
||||||
|
margin-top: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.wallet-panel__head {
|
.wallet-panel__head {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -553,6 +850,70 @@ export default {
|
||||||
color: #1fb7f9;
|
color: #1fb7f9;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-more-list {
|
||||||
|
margin-top: 18rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-item {
|
||||||
|
padding: 22rpx 24rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
background: rgba(53, 62, 94, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-item + .wallet-more-item {
|
||||||
|
margin-top: 14rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-item__head {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-item__name {
|
||||||
|
font-size: 24rpx;
|
||||||
|
color: rgba(196, 205, 231, 0.88);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-item__address {
|
||||||
|
display: block;
|
||||||
|
margin-top: 14rpx;
|
||||||
|
font-size: 25rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
word-break: break-all;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-empty {
|
||||||
|
display: block;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
padding: 28rpx 20rpx;
|
||||||
|
border-radius: 8rpx;
|
||||||
|
text-align: center;
|
||||||
|
font-size: 25rpx;
|
||||||
|
color: rgba(174, 183, 211, 0.82);
|
||||||
|
background: rgba(53, 62, 94, 0.58);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-action {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
height: 76rpx;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
border: 1px solid rgba(31, 183, 249, 0.56);
|
||||||
|
border-radius: 8rpx;
|
||||||
|
font-size: 27rpx;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1fb7f9;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-more-action--standalone {
|
||||||
|
flex-shrink: 0;
|
||||||
|
margin-top: 18rpx;
|
||||||
|
background: rgba(36, 41, 68, 0.72);
|
||||||
|
}
|
||||||
|
|
||||||
.wallet-input {
|
.wallet-input {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -596,6 +957,11 @@ export default {
|
||||||
margin-top: 48rpx;
|
margin-top: 48rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-actions--single .wallet-button {
|
||||||
|
max-width: 420rpx;
|
||||||
|
margin: 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
.get-walleck {
|
.get-walleck {
|
||||||
background: #20263e;
|
background: #20263e;
|
||||||
margin-top: 48rpx;
|
margin-top: 48rpx;
|
||||||
|
|
@ -635,6 +1001,18 @@ export default {
|
||||||
color: #edf2ff;
|
color: #edf2ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-edit-dialog__label {
|
||||||
|
display: block;
|
||||||
|
margin-top: 4rpx;
|
||||||
|
font-size: 26rpx;
|
||||||
|
line-height: 1.6;
|
||||||
|
color: rgba(220, 228, 250, 0.92);
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-edit-dialog__label--address {
|
||||||
|
margin-top: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.wallet-edit-dialog__box {
|
.wallet-edit-dialog__box {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -645,6 +1023,15 @@ export default {
|
||||||
background: rgba(70, 80, 122, 0.78);
|
background: rgba(70, 80, 122, 0.78);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-edit-dialog__box--input {
|
||||||
|
min-height: 92rpx;
|
||||||
|
margin-top: 12rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-edit-dialog__box--input .wallet-edit-dialog__input {
|
||||||
|
min-height: 92rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.wallet-edit-dialog__input {
|
.wallet-edit-dialog__input {
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
|
|
@ -654,6 +1041,20 @@ export default {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-edit-dialog__box--textarea {
|
||||||
|
align-items: stretch;
|
||||||
|
min-height: 220rpx;
|
||||||
|
padding: 18rpx 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-edit-dialog__textarea {
|
||||||
|
width: 100%;
|
||||||
|
min-height: 184rpx;
|
||||||
|
font-size: 28rpx;
|
||||||
|
line-height: 1.7;
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
|
|
||||||
.wallet-edit-dialog__paste {
|
.wallet-edit-dialog__paste {
|
||||||
margin-left: 18rpx;
|
margin-left: 18rpx;
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
|
|
@ -720,15 +1121,6 @@ export default {
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
.wallet-delete {
|
|
||||||
margin-top: auto;
|
|
||||||
padding: 140rpx 0 10rpx;
|
|
||||||
text-align: center;
|
|
||||||
font-size: 28rpx;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #1fb7f9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wallet-success-tip {
|
.wallet-success-tip {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: calc(env(safe-area-inset-top) + 132rpx);
|
top: calc(env(safe-area-inset-top) + 132rpx);
|
||||||
|
|
|
||||||
|
|
@ -64,23 +64,34 @@
|
||||||
<text class="section-head__title">钱包地址</text>
|
<text class="section-head__title">钱包地址</text>
|
||||||
</view>
|
</view>
|
||||||
<text class="wallet-card__link" @click="openWallet"
|
<text class="wallet-card__link" @click="openWallet"
|
||||||
>修改钱包地址</text
|
>钱包管理</text
|
||||||
>
|
>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-if="detail.defaultWallet" class="wallet-box">
|
<view v-if="selectedWallet" class="wallet-box">
|
||||||
<view class="wallet-box__head">
|
<view class="wallet-box__head">
|
||||||
<text class="wallet-box__name">{{
|
<view v-if="selectedWallet.isDefault" class="wallet-box__name-wrap">
|
||||||
detail.defaultWallet.name
|
<text class="wallet-box__name">默认钱包</text>
|
||||||
}}</text>
|
</view>
|
||||||
<view class="wallet-box__actions">
|
<view class="wallet-box__actions">
|
||||||
<text class="wallet-box__action" @click="toggleWalletVisible">{{
|
<picker
|
||||||
walletVisible ? "隐藏" : "显示"
|
v-if="detail.wallets.length > 1"
|
||||||
}}</text>
|
class="wallet-box__picker"
|
||||||
<text class="wallet-box__action" @click="copyWallet">复制</text>
|
mode="selector"
|
||||||
|
:range="walletOptions"
|
||||||
|
range-key="label"
|
||||||
|
:value="selectedWalletIndex"
|
||||||
|
@change="selectWallet"
|
||||||
|
>
|
||||||
|
<view class="wallet-box__select-action">
|
||||||
|
<text>选择钱包</text>
|
||||||
|
<view class="wallet-box__arrow"></view>
|
||||||
|
</view>
|
||||||
|
</picker>
|
||||||
|
<view class="wallet-box__action" @click="copyWallet">复制</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<text class="wallet-box__address asset-number-font">{{ walletDisplayAddress }}</text>
|
<view class="wallet-box__address asset-number-font">{{ walletDisplayAddress }}</view>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view v-else class="wallet-box wallet-box--empty" @click="openWallet">
|
<view v-else class="wallet-box wallet-box--empty" @click="openWallet">
|
||||||
|
|
@ -112,7 +123,7 @@
|
||||||
<view class="withdraw-popup">
|
<view class="withdraw-popup">
|
||||||
<view class="withdraw-popup__address-card">
|
<view class="withdraw-popup__address-card">
|
||||||
<text class="withdraw-popup__address asset-number-font">{{
|
<text class="withdraw-popup__address asset-number-font">{{
|
||||||
detail.defaultWallet ? detail.defaultWallet.address : "未设置"
|
selectedWallet ? selectedWallet.address : "未设置"
|
||||||
}}</text>
|
}}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
|
|
@ -173,6 +184,7 @@ export default {
|
||||||
coupon: 0,
|
coupon: 0,
|
||||||
},
|
},
|
||||||
defaultWallet: null,
|
defaultWallet: null,
|
||||||
|
wallets: [],
|
||||||
},
|
},
|
||||||
hasShown: false,
|
hasShown: false,
|
||||||
form: {
|
form: {
|
||||||
|
|
@ -180,6 +192,7 @@ export default {
|
||||||
},
|
},
|
||||||
confirmVisible: false,
|
confirmVisible: false,
|
||||||
walletVisible: false,
|
walletVisible: false,
|
||||||
|
selectedWalletIndex: 0,
|
||||||
submitting: false,
|
submitting: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
@ -241,17 +254,35 @@ export default {
|
||||||
return this.stripTrailingZero(this.withdrawRateNumber) + "%";
|
return this.stripTrailingZero(this.withdrawRateNumber) + "%";
|
||||||
},
|
},
|
||||||
walletDisplayAddress() {
|
walletDisplayAddress() {
|
||||||
if (!this.detail.defaultWallet || !this.detail.defaultWallet.address) {
|
if (!this.selectedWallet || !this.selectedWallet.address) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const address = this.detail.defaultWallet.address;
|
const address = this.selectedWallet.address;
|
||||||
if (this.walletVisible || address.length <= 16) {
|
if (this.walletVisible || address.length <= 16) {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
return address.slice(0, 8) + "..." + address.slice(-8);
|
return address.slice(0, 8) + "..." + address.slice(-8);
|
||||||
},
|
},
|
||||||
|
selectedWallet() {
|
||||||
|
const wallets = Array.isArray(this.detail.wallets)
|
||||||
|
? this.detail.wallets
|
||||||
|
: [];
|
||||||
|
return wallets[this.selectedWalletIndex] || wallets[0] || null;
|
||||||
|
},
|
||||||
|
walletOptions() {
|
||||||
|
const wallets = Array.isArray(this.detail.wallets)
|
||||||
|
? this.detail.wallets
|
||||||
|
: [];
|
||||||
|
return wallets.map((wallet, index) => {
|
||||||
|
const address = this.maskWalletAddress(wallet.address);
|
||||||
|
return {
|
||||||
|
label: wallet.isDefault ? `默认钱包 ${address}` : address,
|
||||||
|
value: index,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
pageIcon(type) {
|
pageIcon(type) {
|
||||||
|
|
@ -377,6 +408,9 @@ export default {
|
||||||
},
|
},
|
||||||
async loadPage(showLoading) {
|
async loadPage(showLoading) {
|
||||||
try {
|
try {
|
||||||
|
const selectedAddress = this.selectedWallet
|
||||||
|
? this.selectedWallet.address
|
||||||
|
: "";
|
||||||
this.detail = await fetchWithdrawDetail(
|
this.detail = await fetchWithdrawDetail(
|
||||||
showLoading
|
showLoading
|
||||||
? {
|
? {
|
||||||
|
|
@ -385,6 +419,14 @@ export default {
|
||||||
}
|
}
|
||||||
: null,
|
: null,
|
||||||
);
|
);
|
||||||
|
const matchedIndex = this.detail.wallets.findIndex(
|
||||||
|
(wallet) => wallet.address === selectedAddress,
|
||||||
|
);
|
||||||
|
const defaultIndex = this.detail.wallets.findIndex(
|
||||||
|
(wallet) => wallet.isDefault,
|
||||||
|
);
|
||||||
|
this.selectedWalletIndex =
|
||||||
|
matchedIndex >= 0 ? matchedIndex : defaultIndex >= 0 ? defaultIndex : 0;
|
||||||
this.walletVisible = false;
|
this.walletVisible = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error)
|
console.log(error)
|
||||||
|
|
@ -400,13 +442,25 @@ export default {
|
||||||
toggleWalletVisible() {
|
toggleWalletVisible() {
|
||||||
this.walletVisible = !this.walletVisible;
|
this.walletVisible = !this.walletVisible;
|
||||||
},
|
},
|
||||||
|
maskWalletAddress(address) {
|
||||||
|
const value = String(address || "");
|
||||||
|
if (value.length <= 16) {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
return value.slice(0, 8) + "..." + value.slice(-8);
|
||||||
|
},
|
||||||
|
selectWallet(event) {
|
||||||
|
const index = Number(event && event.detail ? event.detail.value : 0);
|
||||||
|
this.selectedWalletIndex = Number.isFinite(index) ? index : 0;
|
||||||
|
this.walletVisible = false;
|
||||||
|
},
|
||||||
copyWallet() {
|
copyWallet() {
|
||||||
if (!this.detail.defaultWallet || !this.detail.defaultWallet.address) {
|
if (!this.selectedWallet || !this.selectedWallet.address) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uni.setClipboardData({
|
uni.setClipboardData({
|
||||||
data: this.detail.defaultWallet.address,
|
data: this.selectedWallet.address,
|
||||||
showToast: false,
|
showToast: false,
|
||||||
success: () => {
|
success: () => {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
|
|
@ -429,7 +483,7 @@ export default {
|
||||||
|
|
||||||
this.form.amount = amountCheck.normalized;
|
this.form.amount = amountCheck.normalized;
|
||||||
|
|
||||||
if (!this.detail.defaultWallet) {
|
if (!this.selectedWallet) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请先添加钱包地址",
|
title: "请先添加钱包地址",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
|
|
@ -464,7 +518,7 @@ export default {
|
||||||
|
|
||||||
this.form.amount = amountCheck.normalized;
|
this.form.amount = amountCheck.normalized;
|
||||||
|
|
||||||
if (!this.detail.defaultWallet) {
|
if (!this.selectedWallet) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "请先添加钱包地址",
|
title: "请先添加钱包地址",
|
||||||
icon: "none",
|
icon: "none",
|
||||||
|
|
@ -477,7 +531,7 @@ export default {
|
||||||
try {
|
try {
|
||||||
await submitAssetWithdraw({
|
await submitAssetWithdraw({
|
||||||
amount: this.amountValue,
|
amount: this.amountValue,
|
||||||
address: this.detail.defaultWallet.address,
|
address: this.selectedWallet.address,
|
||||||
}, {
|
}, {
|
||||||
showLoading: true,
|
showLoading: true,
|
||||||
loadingText: "提交中",
|
loadingText: "提交中",
|
||||||
|
|
@ -762,6 +816,21 @@ export default {
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-box__name-wrap {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex: 1;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.wallet-box__picker {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
flex-shrink: 0;
|
||||||
|
height: 44rpx;
|
||||||
|
margin-right: 24rpx;
|
||||||
|
}
|
||||||
|
|
||||||
.wallet-box__name {
|
.wallet-box__name {
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
color: rgba(232, 239, 255, 0.88);
|
color: rgba(232, 239, 255, 0.88);
|
||||||
|
|
@ -770,15 +839,33 @@ export default {
|
||||||
.wallet-box__actions {
|
.wallet-box__actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-left: auto;
|
||||||
|
flex-shrink: 0;
|
||||||
|
min-height: 44rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-box__select-action,
|
||||||
.wallet-box__action {
|
.wallet-box__action {
|
||||||
margin-left: 24rpx;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
height: 44rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
|
line-height: 44rpx;
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
color: #20b6f5;
|
color: #20b6f5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.wallet-box__arrow {
|
||||||
|
width: 10rpx;
|
||||||
|
height: 10rpx;
|
||||||
|
margin-left: 10rpx;
|
||||||
|
margin-top: -5rpx;
|
||||||
|
border-right: 2rpx solid #20b6f5;
|
||||||
|
border-bottom: 2rpx solid #20b6f5;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.wallet-box__address {
|
.wallet-box__address {
|
||||||
margin-top: 18rpx;
|
margin-top: 18rpx;
|
||||||
font-size: 26rpx;
|
font-size: 26rpx;
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>白马交易所</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
<!DOCTYPE html><html lang=zh-CN><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><title>白马交易所</title><script>var coverSupport = 'CSS' in window && typeof CSS.supports === 'function' && (CSS.supports('top: env(a)') || CSS.supports('top: constant(a)'))
|
||||||
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/bmt/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/bmt/static/js/chunk-vendors.a58c62f3.js></script><script src=/bmt/static/js/index.8b3c4206.js></script></body></html>
|
document.write('<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0' + (coverSupport ? ', viewport-fit=cover' : '') + '" />')</script><link rel=stylesheet href=/bmt/static/index.883130ca.css></head><body><noscript><strong>Please enable JavaScript to continue.</strong></noscript><div id=app></div><script src=/bmt/static/js/chunk-vendors.a58c62f3.js></script><script src=/bmt/static/js/index.dd7af24c.js></script></body></html>
|
||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue