From 6afd34cb0f8f573ce30dd4749a5a213d7ed810de Mon Sep 17 00:00:00 2001 From: claw_bot Date: Tue, 10 Mar 2026 07:16:10 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=88=9B=E5=BB=BA?= =?UTF-8?q?=E7=BB=84=E5=90=88=E5=B8=81=E7=A7=8D=E9=80=89=E6=8B=A9=EF=BC=8C?= =?UTF-8?q?=E4=BA=A4=E6=98=93=E9=A1=B5=E9=9D=A2=E5=8E=BB=E6=8E=89=E5=B8=81?= =?UTF-8?q?=E7=A7=8D=E9=80=89=E6=8B=A9=E6=A1=86=EF=BC=8C=E6=98=8E=E7=BB=86?= =?UTF-8?q?=E9=A1=B5=E8=B4=A7=E5=B8=81=E7=AC=A6=E5=8F=B7=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/config/config.vue | 27 +++++++++++++++++++++++++-- pages/detail/detail.vue | 34 ++++++++++++++++++++-------------- 2 files changed, 45 insertions(+), 16 deletions(-) diff --git a/pages/config/config.vue b/pages/config/config.vue index 013d7cd..5a20a94 100644 --- a/pages/config/config.vue +++ b/pages/config/config.vue @@ -29,6 +29,17 @@ {{ selectedStrategy.desc }} + + + 组合币种 + + + {{ currencyList[currencyIndex].name }} + + + + 创建后币种不可修改,所有交易只能使用该币种 + @@ -117,6 +128,13 @@ import { api } from '../../utils/api'; const strategies = ref([]); const strategyIndex = ref(-1); +// 币种选择 +const currencyList = ref([ + { name: '人民币 CNY', code: 'CNY' }, + { name: '美元 USD', code: 'USD' }, + { name: '港币 HKD', code: 'HKD' } +]); +const currencyIndex = ref(0); // 默认CNY // 防止重复请求的标志 let isFetching = false; @@ -253,6 +271,10 @@ const onDateChange = (e, index) => { form.value.stocks[index].date = e.detail.value; }; +const onCurrencyChange = (e) => { + currencyIndex.value = e.detail.value; +}; + const submitForm = async () => { if (!form.value.name) return uni.showToast({ title: '请输入组合名称', icon: 'none' }); if (strategyIndex.value === -1) return uni.showToast({ title: '请选择策略', icon: 'none' }); @@ -294,17 +316,18 @@ const submitForm = async () => { } } + const selectedCurrency = currencyList.value[currencyIndex.value].code; const requestData = { name: form.value.name, strategyId: selected.id, - currency: 'USD', + currency: selectedCurrency, stocks: form.value.stocks.map(stock => ({ name: stock.name, code: stock.name, price: parseFloat(stock.price) || 0, amount: parseFloat(stock.amount) || 0, date: stock.date, - currency: 'USD' + currency: selectedCurrency })) }; diff --git a/pages/detail/detail.vue b/pages/detail/detail.vue index 07dda63..c91ccdf 100644 --- a/pages/detail/detail.vue +++ b/pages/detail/detail.vue @@ -16,7 +16,7 @@ - ¥ + {{ getCurrencySymbol(portfolioData.currency) }} {{ (portfolioData.portfolioValue || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} @@ -27,7 +27,7 @@ 日内波动 - {{ (portfolioData.dailyVolatility || 0) >= 0 ? '+' : '' }}¥{{ (portfolioData.dailyVolatility || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} + {{ (portfolioData.dailyVolatility || 0) >= 0 ? '+' : '' }}{{ getCurrencySymbol(portfolioData.currency) }}{{ (portfolioData.dailyVolatility || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} @@ -83,7 +83,7 @@ - ¥{{ (item.totalValue || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} + {{ getCurrencySymbol(portfolioData.currency) }}{{ (item.totalValue || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} 比例 {{ (item.ratio || 0).toFixed(1) }}% @@ -94,7 +94,7 @@ 变动额 - {{ (item.changeAmount || 0) >= 0 ? '+' : '' }}¥{{ (item.changeAmount || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} + {{ (item.changeAmount || 0) >= 0 ? '+' : '' }}{{ getCurrencySymbol(portfolioData.currency) }}{{ (item.changeAmount || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 }) }} @@ -214,15 +214,7 @@ /> - - 货币 - - - {{ transactionForm.currency }} - - - - + 交易时间 @@ -258,6 +250,16 @@ import { ref, onMounted, watch } from 'vue'; import { api } from '../../utils/api'; +// 获取货币符号 +const getCurrencySymbol = (currency) => { + const symbols = { + 'CNY': '¥', + 'USD': '$', + 'HKD': 'HK$' + }; + return symbols[currency] || '¥'; +}; + const portfolioId = ref(''); const portfolioData = ref({ id: '', @@ -297,7 +299,7 @@ const transactionForm = ref({ stockCode: '', amount: '', price: '', - currency: 'CNY', + currency: '', // 默认使用组合币种 transactionDate: getCurrentDate(), remark: '' }); @@ -427,12 +429,16 @@ const goStrategyConfig = () => { const handleBuy = () => { transactionType.value = 'buy'; resetTransactionForm(); + // 默认使用组合币种 + transactionForm.value.currency = portfolioData.value.currency; showTransactionForm.value = true; }; const handleSell = () => { transactionType.value = 'sell'; resetTransactionForm(); + // 默认使用组合币种 + transactionForm.value.currency = portfolioData.value.currency; // 卖出时自动填充持仓列表作为可选 searchResults.value = positions.value.map(pos => ({ ticker: pos.stockCode,