Browse Source

fix(stock): 修复股票数据显示逻辑和样式问题

- 修复价格为0时显示前收盘价而不是破折号
- 修复涨跌额和涨跌幅为0时显示0.00而不是破折号
- 移除股票价格颜色的CSS变量设置
- 设置默认颜色值为#2e353a确保正确显示
master
zhangf@suq.cn 1 week ago
parent
commit
ff60ad76ec
  1. 6
      app/common.php
  2. 2
      app/controller/frontend/StockController.php
  3. 2
      public/themes/dist_static/static/css/investment.css

6
app/common.php

@ -1855,9 +1855,9 @@ if (!function_exists('fetchStockFromSina')) {
return [ return [
'code' => $stockCode, 'code' => $stockCode,
'name' => $name, 'name' => $name,
'price' => $price > 0 ? number_format($price, 2) : '--',
'change' => $price > 0 ? (($change >= 0 ? '+' : '') . number_format($change, 2)) : '--',
'changePercent' => $price > 0 ? (($changePercent >= 0 ? '+' : '') . number_format($changePercent, 2) . '%') : '--',
'price' => $price > 0 ? number_format($price, 2) : number_format($prevClose, 2),
'change' => $price > 0 ? (($change > 0 ? '+' : '') . number_format($change, 2)) : '0.00',
'changePercent' => $price > 0 ? (($changePercent > 0 ? '+' : '') . number_format($changePercent, 2) . '%') : '0.00%',
'high' => floatval($fields[4]) > 0 ? number_format(floatval($fields[4]), 2) : '--', 'high' => floatval($fields[4]) > 0 ? number_format(floatval($fields[4]), 2) : '--',
'low' => floatval($fields[5]) > 0 ? number_format(floatval($fields[5]), 2) : '--', 'low' => floatval($fields[5]) > 0 ? number_format(floatval($fields[5]), 2) : '--',
'volume' => floatval($fields[8]) > 0 ? round(floatval($fields[8]) / 1000000, 2) : '--', 'volume' => floatval($fields[8]) > 0 ? round(floatval($fields[8]) / 1000000, 2) : '--',

2
app/controller/frontend/StockController.php

@ -23,7 +23,7 @@ class StockController extends BaseController
} }
} }
$change = (string)($stock['change'] ?? '--'); $change = (string)($stock['change'] ?? '--');
$color = '';
$color = '#2e353a';
if ($change !== '--' && $change !== '') { if ($change !== '--' && $change !== '') {
if ($change[0] === '+') { if ($change[0] === '+') {
$color = '#ef4335'; $color = '#ef4335';

2
public/themes/dist_static/static/css/investment.css

@ -212,7 +212,7 @@
display: flex; display: flex;
align-items: baseline; align-items: baseline;
margin-bottom: 5rem; margin-bottom: 5rem;
color: var(--color-primary);
/*color: var(--color-primary);*/
} }
.iv-stock__price { .iv-stock__price {
font-family: "D-DIN-PRO", "MiSans VF", sans-serif; font-family: "D-DIN-PRO", "MiSans VF", sans-serif;

Loading…
Cancel
Save