fix: 1. 降低搜索触发门槛为1位字符,支持单字母股票代码;2. 适配后端返回的小写字段,显示资产类型标签

This commit is contained in:
claw_bot 2026-03-09 10:33:36 +00:00
parent 6dbad69a8d
commit c10b951f4a

View File

@ -66,8 +66,11 @@
:key="idx" :key="idx"
@click="selectStock(result)" @click="selectStock(result)"
> >
<text class="item-ticker">{{ result.Ticker }}</text> <view class="item-left">
<text class="item-exchange">{{ result.Exchange }}</text> <text class="item-ticker">{{ result.ticker }}</text>
<text class="item-type" v-if="result.assetType">{{ result.assetType }}</text>
</view>
<text class="item-exchange">{{ result.exchange }}</text>
</view> </view>
</view> </view>
</view> </view>
@ -134,7 +137,7 @@ const searchStock = async (keyword, stockIndex) => {
// //
activeSearchIndex.value = stockIndex; activeSearchIndex.value = stockIndex;
if (!keyword || keyword.length < 2) { if (!keyword || keyword.length < 1) {
searchResults.value = []; searchResults.value = [];
activeSearchIndex.value = -1; activeSearchIndex.value = -1;
return; return;
@ -160,7 +163,10 @@ const searchStock = async (keyword, stockIndex) => {
const selectStock = (result) => { const selectStock = (result) => {
const stock = form.value.stocks[result.stockIndex]; const stock = form.value.stocks[result.stockIndex];
if (stock) { if (stock) {
stock.name = result.Ticker; stock.name = result.ticker;
//
stock.assetType = result.assetType;
stock.currency = result.priceCurrency;
} }
searchResults.value = []; searchResults.value = [];
activeSearchIndex.value = -1; activeSearchIndex.value = -1;
@ -514,12 +520,27 @@ onShow(async () => {
background-color: #F3F4F6; background-color: #F3F4F6;
} }
.item-left {
display: flex;
flex-direction: row;
align-items: center;
gap: 12rpx;
}
.item-ticker { .item-ticker {
font-size: 26rpx; font-size: 26rpx;
font-weight: 600; font-weight: 600;
color: #1F2937; color: #1F2937;
} }
.item-type {
font-size: 18rpx;
color: #064E3B;
background-color: #D1FAE5;
padding: 2rpx 8rpx;
border-radius: 4rpx;
}
.item-exchange { .item-exchange {
font-size: 22rpx; font-size: 22rpx;
color: #9CA3AF; color: #9CA3AF;