diff --git a/pages/detail/detail.vue b/pages/detail/detail.vue
index c7a8cd6..a784270 100644
--- a/pages/detail/detail.vue
+++ b/pages/detail/detail.vue
@@ -200,10 +200,12 @@
货币
-
- {{ transactionForm.currency }}
-
-
+
+
+ {{ transactionForm.currency }}
+
+
+
@@ -264,13 +266,26 @@ const transactionForm = ref({
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 searchTimer = ref(null);
const searchStock = async (keyword) => {
// 防抖
if (searchTimer.value) clearTimeout(searchTimer.value);
- if (!keyword || keyword.length < 2) {
+ if (!keyword || keyword.length < 1) {
searchResults.value = [];
return;
}
@@ -289,7 +304,19 @@ const searchStock = async (keyword) => {
};
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 = [];
};