historic-stock
This commit is contained in:
parent
deb9834cd4
commit
3bdb88ca55
1215
src/views/historic-stock/data.js
Normal file
1215
src/views/historic-stock/data.js
Normal file
File diff suppressed because it is too large
Load Diff
@ -44,7 +44,8 @@ import { NDataTable, NButton, NDropdown, NIcon } from "naive-ui";
|
|||||||
import { reactive, onMounted, h } from "vue";
|
import { reactive, onMounted, h } from "vue";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { ChevronDownOutline } from "@vicons/ionicons5";
|
import { ChevronDownOutline } from "@vicons/ionicons5";
|
||||||
|
import defaultTableData from "../data";
|
||||||
|
console.log("defaultTableData", defaultTableData);
|
||||||
// 数据筛选选项
|
// 数据筛选选项
|
||||||
const periodOptions = [
|
const periodOptions = [
|
||||||
{ label: "Daily", key: "Daily" },
|
{ label: "Daily", key: "Daily" },
|
||||||
@ -130,106 +131,32 @@ const handleDurationChange = (key) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getPageData();
|
getPageDefaultData();
|
||||||
});
|
});
|
||||||
|
|
||||||
const getPageData = async () => {
|
const getPageDefaultData = async () => {
|
||||||
try {
|
try {
|
||||||
// 实际项目中应该根据state.selectedPeriod和state.selectedDuration动态调整API请求
|
// 实际项目中应该根据state.selectedPeriod和state.selectedDuration动态调整API请求
|
||||||
let url =
|
let url =
|
||||||
"https://stockanalysis.com/api/symbol/a/OTC-MINM/history?type=chart";
|
"https://stockanalysis.com/api/symbol/a/OTC-MINM/history?type=chart";
|
||||||
const res = await axios.get(url);
|
const res = await axios.get(url);
|
||||||
|
let originalData = res.data.data;
|
||||||
// 转换API返回的数据为表格需要的格式
|
// 转换为日期格式
|
||||||
// 注意:以下是模拟数据,实际应该根据API返回的数据结构调整
|
let calcApiData = originalData.map((item) => [
|
||||||
state.tableData = [
|
new Date(item[0]).toISOString().split("T")[0], // 转换时间戳为YYYY-MM-DD格式
|
||||||
{
|
item[1],
|
||||||
date: "May 22, 2025",
|
]);
|
||||||
open: "1.87",
|
console.log("接口数据", calcApiData);
|
||||||
high: "2.03",
|
state.tableData = defaultTableData;
|
||||||
low: "1.85",
|
|
||||||
close: "2.00",
|
|
||||||
adjClose: "2.00",
|
|
||||||
change: "-2.44%",
|
|
||||||
volume: "2,103",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "May 21, 2025",
|
|
||||||
open: "2.05",
|
|
||||||
high: "2.05",
|
|
||||||
low: "2.05",
|
|
||||||
close: "2.05",
|
|
||||||
adjClose: "2.05",
|
|
||||||
change: "-",
|
|
||||||
volume: "4",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "May 20, 2025",
|
|
||||||
open: "2.05",
|
|
||||||
high: "2.05",
|
|
||||||
low: "1.86",
|
|
||||||
close: "2.05",
|
|
||||||
adjClose: "2.05",
|
|
||||||
change: "-",
|
|
||||||
volume: "11,042",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "May 19, 2025",
|
|
||||||
open: "2.04",
|
|
||||||
high: "2.05",
|
|
||||||
low: "1.85",
|
|
||||||
close: "2.05",
|
|
||||||
adjClose: "2.05",
|
|
||||||
change: "-",
|
|
||||||
volume: "6,204",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "May 16, 2025",
|
|
||||||
open: "2.05",
|
|
||||||
high: "2.06",
|
|
||||||
low: "1.85",
|
|
||||||
close: "2.05",
|
|
||||||
adjClose: "2.05",
|
|
||||||
change: "2.50%",
|
|
||||||
volume: "3,618",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "May 15, 2025",
|
|
||||||
open: "2.05",
|
|
||||||
high: "2.05",
|
|
||||||
low: "1.93",
|
|
||||||
close: "2.00",
|
|
||||||
adjClose: "2.00",
|
|
||||||
change: "-1.48%",
|
|
||||||
volume: "5,413",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "May 14, 2025",
|
|
||||||
open: "1.95",
|
|
||||||
high: "2.05",
|
|
||||||
low: "1.95",
|
|
||||||
close: "2.03",
|
|
||||||
adjClose: "2.03",
|
|
||||||
change: "4.10%",
|
|
||||||
volume: "8,886",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
date: "May 13, 2025",
|
|
||||||
open: "2.26",
|
|
||||||
high: "2.26",
|
|
||||||
low: "1.80",
|
|
||||||
close: "1.95",
|
|
||||||
adjClose: "1.95",
|
|
||||||
change: "-18.41%",
|
|
||||||
volume: "10,750",
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
console.log("获取到的数据", state.tableData);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取数据失败", error);
|
console.error("获取数据失败", error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
const getPageData = async () => {
|
||||||
|
let url =
|
||||||
|
"https://stockanalysis.com/api/symbol/a/OTC-MINM/history?type=chart";
|
||||||
|
const res = await axios.get(url);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
Loading…
Reference in New Issue
Block a user