This commit is contained in:
whitechiina 2026-09-07 10:45:55 +08:00
parent 48c1ed6bdc
commit d97a58ed53
11 changed files with 280 additions and 47 deletions

View File

@ -384,12 +384,37 @@ function normalizeWalletSource(data) {
const hasExplicitWalletFields =
Object.prototype.hasOwnProperty.call(source, "address") ||
Object.prototype.hasOwnProperty.call(source, "more_address") ||
Object.prototype.hasOwnProperty.call(source, "moreAddress");
Object.prototype.hasOwnProperty.call(source, "moreAddress") ||
Object.prototype.hasOwnProperty.call(source, "more_address_info") ||
Object.prototype.hasOwnProperty.call(source, "moreAddressInfo");
if (hasExplicitWalletFields) {
const walletSource = [];
const defaultAddress = String(source.address || "").trim();
const moreAddress = pickFirstValue(source, ["more_address", "moreAddress"]);
const moreAddressInfo = pickFirstValue(source, [
"more_address_info",
"moreAddressInfo",
]);
const hasMoreAddressInfo =
(Array.isArray(moreAddressInfo) && moreAddressInfo.length > 0) ||
(moreAddressInfo && typeof moreAddressInfo === "object");
const moreAddress = hasMoreAddressInfo
? moreAddressInfo
: pickFirstValue(source, ["more_address", "moreAddress"]);
const moreAddressNames = normalizeWalletSource(
pickFirstValue(source, [
"more_address_name",
"moreAddressName",
"more_address_names",
"moreAddressNames",
"more_name",
"moreName",
"more_names",
"moreNames",
"wallet_names",
"walletNames",
]),
);
if (defaultAddress) {
walletSource.push({
@ -401,6 +426,16 @@ function normalizeWalletSource(data) {
}
normalizeWalletSource(moreAddress).forEach(function (item, index) {
const indexedName = moreAddressNames[index];
const fallbackName =
indexedName && typeof indexedName === "object"
? pickFirstValue(indexedName, [
"name",
"wallet_name",
"walletName",
"value",
])
: indexedName;
const address = String(
item && typeof item === "object"
? pickFirstValue(item, [
@ -420,7 +455,7 @@ function normalizeWalletSource(data) {
name:
item && typeof item === "object"
? pickFirstValue(item, ["name", "wallet_name", "walletName"])
: "",
: fallbackName || "",
});
}
});
@ -3297,6 +3332,9 @@ export async function saveAssetWallet(payload, requestOptions) {
if (!address) {
throw createError("请输入钱包地址");
}
if (type === 1 && !name) {
throw createError("请输入钱包名称");
}
if (type === 0 && addressList.length > 1) {
throw createError("默认钱包只能填写一个地址");
}

View File

@ -207,7 +207,7 @@
v-model="moreWalletName"
class="wallet-edit-dialog__input"
type="text"
placeholder="请输入钱包名称(选填)"
placeholder="请输入钱包名称"
placeholder-style="color:rgba(165,175,208,0.82);font-size:28rpx;"
:maxlength="30"
/>
@ -225,7 +225,7 @@
/>
</view>
<text class="wallet-edit-dialog__desc">
*钱包地址确认后,无法修改,请仔细核对钱包地址
*每次只能添加一个钱包地址;请仔细核对地址
</text>
</view>
</asset-confirm-popup>
@ -639,6 +639,14 @@ export default {
return;
}
if (!this.trimmedMoreWalletName) {
uni.showToast({
title: "请输入钱包名称",
icon: "none",
});
return;
}
if (addresses.length > this.remainingMoreAddressCount) {
uni.showToast({
title:
@ -1004,7 +1012,7 @@ export default {
.wallet-edit-dialog__label {
display: block;
margin-top: 4rpx;
font-size: 26rpx;
font-size: 30rpx;
line-height: 1.6;
color: rgba(220, 228, 250, 0.92);
}
@ -1065,7 +1073,7 @@ export default {
.wallet-edit-dialog__desc {
display: block;
margin-top: 26rpx;
font-size: 22rpx;
font-size: 26rpx;
line-height: 1.8;
color: #F77E57;
}

View File

@ -70,24 +70,21 @@
<view v-if="selectedWallet" class="wallet-box">
<view class="wallet-box__head">
<view v-if="selectedWallet.isDefault" class="wallet-box__name-wrap">
<text class="wallet-box__name">默认钱包</text>
<view class="wallet-box__name-wrap">
<text
v-if="selectedWallet.isDefault || selectedWallet.name"
class="wallet-box__name"
>{{ selectedWallet.isDefault ? "默认钱包" : selectedWallet.name }}</text>
</view>
<view class="wallet-box__actions">
<picker
<view
v-if="detail.wallets.length > 1"
class="wallet-box__picker"
mode="selector"
:range="walletOptions"
range-key="label"
:value="selectedWalletIndex"
@change="selectWallet"
class="wallet-box__select-action"
@click.stop="openWalletPicker"
>
<view class="wallet-box__select-action">
<text>选择钱包</text>
<view class="wallet-box__arrow"></view>
</view>
</picker>
<text>选择钱包</text>
<view class="wallet-box__arrow"></view>
</view>
<view class="wallet-box__action" @click="copyWallet">复制</view>
</view>
</view>
@ -160,6 +157,57 @@
</text>
</view>
</asset-confirm-popup>
<view
v-if="walletPickerVisible"
class="wallet-picker-mask"
@click="closeWalletPicker"
>
<view class="wallet-picker-panel" @click.stop>
<view class="wallet-picker-panel__head">
<text class="wallet-picker-panel__title">选择钱包</text>
<view class="wallet-picker-panel__close" @click="closeWalletPicker">
<image
class="wallet-picker-panel__close-image"
src="https://imgs.agrimedia.cn/bm-bmt/bmt-close.png"
mode="aspectFit"
></image>
</view>
</view>
<scroll-view
class="wallet-picker-list"
scroll-y
:style="{ height: walletPickerListHeight }"
>
<view
v-for="(wallet, index) in detail.wallets"
:key="wallet.id || wallet.address || index"
class="wallet-picker-item"
:class="{
'wallet-picker-item--selected': index === selectedWalletIndex,
}"
@click="selectWallet(index)"
>
<view class="wallet-picker-item__head">
<text class="wallet-picker-item__name">
{{ wallet.isDefault ? "默认钱包" : wallet.name || wallet.address }}
</text>
<view
v-if="index === selectedWalletIndex"
class="wallet-picker-item__check"
>
<text>✓</text>
</view>
</view>
<text
v-if="wallet.isDefault || wallet.name"
class="wallet-picker-item__address asset-number-font"
>{{ wallet.address }}</text>
</view>
</scroll-view>
</view>
</view>
</view>
</template>
@ -192,6 +240,7 @@ export default {
},
confirmVisible: false,
walletVisible: false,
walletPickerVisible: false,
selectedWalletIndex: 0,
submitting: false,
};
@ -207,6 +256,14 @@ export default {
this.hasShown = true;
},
onBackPress() {
if (this.walletPickerVisible) {
this.walletPickerVisible = false;
return true;
}
return false;
},
computed: {
amountValue() {
return Number(this.form.amount || 0);
@ -271,17 +328,11 @@ export default {
: [];
return wallets[this.selectedWalletIndex] || wallets[0] || null;
},
walletOptions() {
walletPickerListHeight() {
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,
};
});
return Math.min(Math.max(wallets.length * 170, 300), 680) + "rpx";
},
},
methods: {
@ -428,6 +479,7 @@ export default {
this.selectedWalletIndex =
matchedIndex >= 0 ? matchedIndex : defaultIndex >= 0 ? defaultIndex : 0;
this.walletVisible = false;
this.walletPickerVisible = false;
} catch (error) {
console.log(error)
uni.showToast({
@ -449,9 +501,28 @@ export default {
}
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;
openWalletPicker() {
if (!this.detail.wallets || this.detail.wallets.length <= 1) {
return;
}
this.walletPickerVisible = true;
},
closeWalletPicker() {
this.walletPickerVisible = false;
},
selectWallet(index) {
const nextIndex = Number(index);
if (
!Number.isFinite(nextIndex) ||
nextIndex < 0 ||
nextIndex >= this.detail.wallets.length
) {
return;
}
this.selectedWalletIndex = nextIndex;
this.walletPickerVisible = false;
this.walletVisible = false;
},
copyWallet() {
@ -823,16 +894,14 @@ export default {
min-width: 0;
}
.wallet-box__picker {
display: flex;
align-items: center;
flex-shrink: 0;
height: 44rpx;
margin-right: 24rpx;
}
.wallet-box__name {
font-size: 26rpx;
display: block;
max-width: 240rpx;
overflow: hidden;
font-size: 28rpx;
line-height: 44rpx;
white-space: nowrap;
text-overflow: ellipsis;
color: rgba(232, 239, 255, 0.88);
}
@ -849,12 +918,17 @@ export default {
display: flex;
align-items: center;
height: 44rpx;
font-size: 26rpx;
padding: 0 4rpx;
font-size: 29rpx;
line-height: 44rpx;
font-weight: 400;
color: #20b6f5;
}
.wallet-box__select-action {
margin-right: 24rpx;
}
.wallet-box__arrow {
width: 10rpx;
height: 10rpx;
@ -866,6 +940,119 @@ export default {
flex-shrink: 0;
}
.wallet-picker-mask {
position: fixed;
inset: 0;
z-index: 90;
display: flex;
align-items: flex-end;
background: rgba(5, 10, 22, 0.72);
}
.wallet-picker-panel {
width: 100%;
max-height: 78vh;
padding: 30rpx 24rpx calc(68rpx + env(safe-area-inset-bottom));
border-radius: 28rpx 28rpx 0 0;
border: 1px solid rgba(142, 157, 206, 0.14);
background: #2a2f4d;
box-shadow: 0 -20rpx 70rpx rgba(0, 0, 0, 0.28);
box-sizing: border-box;
overflow: hidden;
}
.wallet-picker-panel__head {
position: relative;
display: flex;
align-items: center;
justify-content: center;
min-height: 52rpx;
}
.wallet-picker-panel__title {
font-size: 34rpx;
font-weight: 700;
color: #ffffff;
}
.wallet-picker-panel__close {
position: absolute;
right: 0;
top: 50%;
display: flex;
align-items: center;
justify-content: center;
width: 52rpx;
height: 52rpx;
transform: translateY(-50%);
}
.wallet-picker-panel__close-image {
width: 32rpx;
height: 32rpx;
}
.wallet-picker-list {
margin-top: 22rpx;
}
.wallet-picker-item {
padding: 24rpx 22rpx;
border: 1px solid rgba(157, 173, 221, 0.16);
border-radius: 12rpx;
background: rgba(53, 62, 94, 0.72);
box-sizing: border-box;
}
.wallet-picker-item + .wallet-picker-item {
margin-top: 16rpx;
}
.wallet-picker-item--selected {
border-color: rgba(32, 182, 245, 0.9);
background: rgba(32, 182, 245, 0.14);
}
.wallet-picker-item__head {
display: flex;
align-items: center;
justify-content: space-between;
}
.wallet-picker-item__name {
flex: 1;
min-width: 0;
padding-right: 20rpx;
font-size: 34rpx;
font-weight: 700;
line-height: 1.5;
color: #ffffff;
word-break: break-all;
}
.wallet-picker-item__check {
display: flex;
align-items: center;
justify-content: center;
width: 40rpx;
height: 40rpx;
border-radius: 50%;
background: #20b6f5;
font-size: 24rpx;
font-weight: 700;
color: #ffffff;
flex-shrink: 0;
}
.wallet-picker-item__address {
display: block;
margin-top: 12rpx;
font-size: 26rpx;
line-height: 1.6;
color: rgba(224, 231, 250, 0.86);
word-break: break-all;
}
.wallet-box__address {
margin-top: 18rpx;
font-size: 26rpx;

View File

@ -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)'))
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>
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.19c00be4.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