From bd4f92d465be94058805a8605508b406c1fe7d60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=A8=E6=B0=B4=E6=B7=BC?= Date: Sat, 19 Jul 2025 10:01:53 +0800 Subject: [PATCH] =?UTF-8?q?=20=E6=9B=B4=E6=96=B0=EF=BC=9Aajax=20=E8=BD=BD?= =?UTF-8?q?=E5=85=A5=E5=8A=A8=E5=9B=BE=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/head.php | 2 +- index.php | 3 +- js/pubfunc.js | 16 ++++---- stock_trend.php | 5 --- stockep.php | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 108 insertions(+), 15 deletions(-) create mode 100644 stockep.php diff --git a/html/head.php b/html/head.php index 14e5c2f..9200d77 100644 --- a/html/head.php +++ b/html/head.php @@ -6,7 +6,7 @@ - + <?=$title?> diff --git a/index.php b/index.php index 7fd44c9..82e3d0e 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,4 @@ - + @@ -18,6 +18,7 @@ $_REQUEST['ts_code']=$_REQUEST['ts_code']?$_REQUEST['ts_code']:'600000';
个股:股票代码: ' >
+
个股:股价VS EP
diff --git a/js/pubfunc.js b/js/pubfunc.js index 62ef1a6..cc36ad1 100644 --- a/js/pubfunc.js +++ b/js/pubfunc.js @@ -2,7 +2,7 @@ * @Author: 杨水淼 yangshuimiao@jsjd.cc * @Date: 2025-03-21 11:58:51 * @LastEditors: 杨水淼 yangshuimiao@jsjd.cc - * @LastEditTime: 2025-07-09 12:28:30 + * @LastEditTime: 2025-07-16 16:15:16 * @FilePath: \echarts\js\pubfunc.js * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ @@ -87,18 +87,18 @@ function formatDateToYYYYMMDD(dateStr) { return dateStr.replace(/-/g, ''); } -function pickData(data, dateKey, valueKey) { +function pickData(data, dateKey, valueKey,fixed=2) { data.sort((a, b) => a[dateKey] - b[dateKey]); return data.map(item => ({ value: [ item[dateKey].slice(0, 4) + '-' + item[dateKey].slice(4, 6) + '-' + item[dateKey].slice(6, 8), // 格式化日期 yyyymmdd 转为 yyyy-mm-dd - item[valueKey].toFixed(2) // 保留两位小数 + item[valueKey].toFixed(fixed) // 保留两位小数 ] })); } /* 将上述pickData函数返回的结果,value计算返回最大值,最小值,均值,以及最后一个值 */ -function calculateStats(data) { +function calculateStats(data,fixed=2) { if (data.length === 0) { return { max: null, @@ -129,9 +129,9 @@ function calculateStats(data) { const avg = sum / data.length; return { - max: max.toFixed(2), - min: min.toFixed(2), - avg: avg.toFixed(2), - last: last.toFixed(2) + max: max.toFixed(fixed), + min: min.toFixed(fixed), + avg: avg.toFixed(fixed), + last: last.toFixed(fixed) }; } \ No newline at end of file diff --git a/stock_trend.php b/stock_trend.php index f029847..6516985 100644 --- a/stock_trend.php +++ b/stock_trend.php @@ -26,8 +26,6 @@ include_once "html/head.php";

正在加载数据,请稍候...

- -
@@ -38,9 +36,6 @@ include_once "html/head.php"; +
+股票代码: ' > +开始时间: ' > +结束时间: ' > + +
 
+ +
+
EP=100*TTM每股收益/股价。如:EP=5表示每股收益率5%
+ +
+
+
+

正在加载数据,请稍候...

+
+ +
+ + + + + + + +