From 58def6a3d0d6ba3b841ac16f35c151da449ee30c Mon Sep 17 00:00:00 2001 From: spark Date: Thu, 19 Dec 2024 09:00:01 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/data/stock_data_api.go | 2 +- frontend/src/components/stock.vue | 28 +++++++++++++++++++++------- main.go | 2 +- 3 files changed, 23 insertions(+), 9 deletions(-) diff --git a/backend/data/stock_data_api.go b/backend/data/stock_data_api.go index 200fef7..0a0b599 100644 --- a/backend/data/stock_data_api.go +++ b/backend/data/stock_data_api.go @@ -220,7 +220,7 @@ func (receiver StockDataApi) GetStockCodeRealTimeData(StockCode string) (*StockI return &StockInfo{}, nil } stockData, err := ParseFullSingleStockData(GB18030ToUTF8(resp.Body())) - go db.Dao.Model(&StockInfo{}).Create(stockData) + //go db.Dao.Model(&StockInfo{}).Create(stockData) return stockData, err } diff --git a/frontend/src/components/stock.vue b/frontend/src/components/stock.vue index 9948bcf..4f4fc77 100644 --- a/frontend/src/components/stock.vue +++ b/frontend/src/components/stock.vue @@ -126,6 +126,11 @@ function monitor() { let s=(result["当前价格"]-result["昨日收盘价"])*100/result["昨日收盘价"] let roundedNum = s.toFixed(2); // 将数字转换为保留两位小数的字符串形式 result.s=roundedNum+"%" + + result.highRate=((result["今日最高价"]-result["今日开盘价"])*100/result["今日开盘价"]).toFixed(2)+"%" + result.lowRate=((result["今日最低价"]-result["今日开盘价"])*100/result["今日开盘价"]).toFixed(2)+"%" + + if (roundedNum>0) { result.type="error" result.color="#E88080" @@ -141,13 +146,19 @@ function monitor() { result.costPrice=res[0].CostPrice result.volume=res[0].Volume result.profit=((result["当前价格"]-result.costPrice)*100/result.costPrice).toFixed(3) + result.profitAmountToday=(result.volume*(result["当前价格"]-result["昨日收盘价"])).toFixed(2) + result.profitAmount=(result.volume*(result["当前价格"]-result.costPrice)).toFixed(2) + if(result.profitAmount>0){ + result.profitType="error" + }else if(result.profitAmount<0){ + result.profitType="success" + } } results.value[result["股票名称"]]=result }) } } function onSelect(item) { - console.log(item) data.code=item.split(".")[1].toLowerCase()+item.split(".")[0] } @@ -188,18 +199,19 @@ function updateCostPriceAndVolumeNew(code,price,volume){