fix: 修复货币下拉列表无法展开问题,支持CNY/USD/HKD三种货币选择,选择股票时自动填充对应货币

This commit is contained in:
claw_bot 2026-03-09 10:40:45 +00:00
parent c10b951f4a
commit 0b76ea601d

View File

@ -200,10 +200,12 @@
<view class="form-item"> <view class="form-item">
<text class="form-label">货币</text> <text class="form-label">货币</text>
<picker @change="onCurrencyChange" :value="currencyIndex" :range="currencyList" range-key="name">
<view class="form-select"> <view class="form-select">
<text>{{ transactionForm.currency }}</text> <text>{{ transactionForm.currency }}</text>
<uni-icons type="bottom" size="14" color="#9CA3AF"></uni-icons> <uni-icons type="bottom" size="14" color="#9CA3AF"></uni-icons>
</view> </view>
</picker>
</view> </view>
<view class="form-item"> <view class="form-item">
@ -264,13 +266,26 @@ const transactionForm = ref({
remark: '' remark: ''
}); });
//
const currencyList = ref([
{ name: '人民币 CNY', code: 'CNY' },
{ name: '美元 USD', code: 'USD' },
{ name: '港币 HKD', code: 'HKD' }
]);
const currencyIndex = ref(0);
const onCurrencyChange = (e) => {
currencyIndex.value = e.detail.value;
transactionForm.value.currency = currencyList.value[currencyIndex.value].code;
};
// //
const searchResults = ref([]); const searchResults = ref([]);
const searchTimer = ref(null); const searchTimer = ref(null);
const searchStock = async (keyword) => { const searchStock = async (keyword) => {
// //
if (searchTimer.value) clearTimeout(searchTimer.value); if (searchTimer.value) clearTimeout(searchTimer.value);
if (!keyword || keyword.length < 2) { if (!keyword || keyword.length < 1) {
searchResults.value = []; searchResults.value = [];
return; return;
} }
@ -289,7 +304,19 @@ const searchStock = async (keyword) => {
}; };
const selectStock = (result) => { const selectStock = (result) => {
transactionForm.value.stockCode = result.Ticker; transactionForm.value.stockCode = result.ticker || result.Ticker;
//
if (result.priceCurrency) {
const currencyMap = {
'CNY': 0,
'USD': 1,
'HKD': 2
};
if (currencyMap[result.priceCurrency] !== undefined) {
currencyIndex.value = currencyMap[result.priceCurrency];
transactionForm.value.currency = result.priceCurrency;
}
}
searchResults.value = []; searchResults.value = [];
}; };