|
|
|
@ -140,21 +140,6 @@ |
|
|
|
</div> |
|
|
|
</section> |
|
|
|
{/hcTaglib:category} |
|
|
|
|
|
|
|
{php} |
|
|
|
// 获取股票信息 |
|
|
|
$stockInfo = getStockInfo('603933'); |
|
|
|
// 判断涨跌颜色 |
|
|
|
$priceColor = ''; |
|
|
|
if ($stockInfo['change'] !== '--') { |
|
|
|
$changeVal = floatval(str_replace(['+', '-'], '', $stockInfo['change'])); |
|
|
|
if ($stockInfo['change'][0] === '+') { |
|
|
|
$priceColor = 'color: #ef4335'; // 上涨红色 |
|
|
|
} elseif ($stockInfo['change'][0] === '-') { |
|
|
|
$priceColor = 'color: #00b894'; // 下跌绿色 |
|
|
|
} |
|
|
|
} |
|
|
|
{/php} |
|
|
|
<section class="iv-stock section__wrap" id="stock" data-header-dark> |
|
|
|
<h2 class="iv-stock__title">股票信息</h2> |
|
|
|
<div class="iv-stock__body"> |
|
|
|
@ -162,7 +147,7 @@ |
|
|
|
<p class="iv-stock__code">股票代码:{$stockInfo.code}</p> |
|
|
|
<div class="iv-stock__quote"> |
|
|
|
<span class="iv-stock__price" id="stock-price" style="{$priceColor}">{$stockInfo.price}</span> |
|
|
|
<span class="iv-stock__unit">元</span> |
|
|
|
<span class="iv-stock__unit" style="{$priceColor}">元</span> |
|
|
|
<span class="iv-stock__change" id="stock-change" style="{$priceColor}">{$stockInfo.change} {$stockInfo.changePercent}</span> |
|
|
|
</div> |
|
|
|
<ul class="iv-stock__metrics"> |
|
|
|
@ -186,7 +171,7 @@ |
|
|
|
<p class="iv-stock__note" id="stock-time">截止 {$stockInfo.updateTime}*报价有十五分钟或以上延迟。</p> |
|
|
|
</div> |
|
|
|
<div class="iv-stock__chart"> |
|
|
|
<img src="/themes/dist_static/static/images/section-3-img-CK6u5Hdw.png" alt="股票走势图" width="720" height="450" /> |
|
|
|
<img id="stock-chart" src="https://image.sinajs.cn/newchart/min/n/sh603933.gif" alt="睿能科技分时走势图" width="720" height="450" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</section> |
|
|
|
@ -289,6 +274,50 @@ |
|
|
|
<script src="https://cdn.jsdelivr.net.cn/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> |
|
|
|
<script src="https://cdn.jsdelivr.net/npm/aos@2.3.4/dist/aos.min.js"></script> |
|
|
|
<script src="https://unpkg.com/counterup2@2.0.2/dist/index.js"></script> |
|
|
|
|
|
|
|
<script> |
|
|
|
(function() { |
|
|
|
// 股票图表定时刷新(只刷新图片,不刷新整个页面) |
|
|
|
var refreshInterval = 60000; // 1分钟 |
|
|
|
var stockTimer = null; |
|
|
|
var chartImg = document.getElementById('stock-chart'); |
|
|
|
|
|
|
|
// 刷新图片 |
|
|
|
function refreshChartImage() { |
|
|
|
if (chartImg) { |
|
|
|
var timestamp = new Date().getTime(); |
|
|
|
chartImg.src = 'https://image.sinajs.cn/newchart/min/n/sh603933.gif?t=' + timestamp; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 开始定时刷新 |
|
|
|
function startChartRefresh() { |
|
|
|
stockTimer = setInterval(refreshChartImage, refreshInterval); |
|
|
|
} |
|
|
|
|
|
|
|
// 页面加载完成后开始 |
|
|
|
if (document.readyState === 'loading') { |
|
|
|
document.addEventListener('DOMContentLoaded', startChartRefresh); |
|
|
|
} else { |
|
|
|
startChartRefresh(); |
|
|
|
} |
|
|
|
|
|
|
|
// 页面可见性变化时处理 |
|
|
|
document.addEventListener('visibilitychange', function() { |
|
|
|
if (document.hidden) { |
|
|
|
if (stockTimer) { |
|
|
|
clearInterval(stockTimer); |
|
|
|
stockTimer = null; |
|
|
|
} |
|
|
|
} else { |
|
|
|
if (!stockTimer) { |
|
|
|
refreshChartImage(); // 立即刷新一次 |
|
|
|
startChartRefresh(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
})(); |
|
|
|
</script> |
|
|
|
</body> |
|
|
|
|
|
|
|
</html> |