Compare commits
2 Commits
b59215e5b0
...
524caed5f2
Author | SHA1 | Date | |
---|---|---|---|
524caed5f2 | |||
1c7a139732 |
@ -15,9 +15,10 @@
|
|||||||
@select="handlePeriodChange"
|
@select="handlePeriodChange"
|
||||||
:value="state.selectedPeriod"
|
:value="state.selectedPeriod"
|
||||||
>
|
>
|
||||||
<n-button
|
<n-button>
|
||||||
>{{ state.selectedPeriod }} <n-icon><chevron-down-outline /></n-icon
|
{{ state.selectedPeriod }}
|
||||||
></n-button>
|
<n-icon><chevron-down-outline /></n-icon>
|
||||||
|
</n-button>
|
||||||
</n-dropdown>
|
</n-dropdown>
|
||||||
|
|
||||||
<n-dropdown
|
<n-dropdown
|
||||||
@ -26,10 +27,10 @@
|
|||||||
@select="handleDurationChange"
|
@select="handleDurationChange"
|
||||||
:value="state.selectedDuration"
|
:value="state.selectedDuration"
|
||||||
>
|
>
|
||||||
<n-button
|
<n-button>
|
||||||
>{{ state.selectedDuration }}
|
{{ state.selectedDuration }}
|
||||||
<n-icon><chevron-down-outline /></n-icon
|
<n-icon><chevron-down-outline /></n-icon>
|
||||||
></n-button>
|
</n-button>
|
||||||
</n-dropdown>
|
</n-dropdown>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -90,21 +91,22 @@ console.log("defaultTableData", defaultTableData);
|
|||||||
|
|
||||||
// 数据筛选选项
|
// 数据筛选选项
|
||||||
const periodOptions = [
|
const periodOptions = [
|
||||||
{ label: "Daily", key: "Daily" },
|
{ label: 'Daily', key: 'Daily' },
|
||||||
{ label: "Weekly", key: "Weekly" },
|
{ label: 'Weekly', key: 'Weekly' },
|
||||||
{ label: "Monthly", key: "Monthly" },
|
{ label: 'Monthly', key: 'Monthly' },
|
||||||
{ label: "Quarterly", key: "Quarterly" },
|
{ label: 'Quarterly', key: 'Quarterly' },
|
||||||
{ label: "Annual", key: "Annual" },
|
{ label: 'Annual', key: 'Annual' },
|
||||||
];
|
]
|
||||||
|
|
||||||
const durationOptions = [
|
const durationOptions = [
|
||||||
{ label: "3 Months", key: "3 Months" },
|
{ label: '3 Months', key: '3 Months' },
|
||||||
{ label: "6 Months", key: "6 Months" },
|
{ label: '6 Months', key: '6 Months' },
|
||||||
{ label: "Year to Date", key: "Year to Date" },
|
{ label: 'Year to Date', key: 'Year to Date' },
|
||||||
{ label: "1 Year", key: "1 Year" },
|
{ label: '1 Year', key: '1 Year' },
|
||||||
{ label: "5 Years", key: "5 Years" },
|
{ label: '5 Years', key: '5 Years' },
|
||||||
{ label: "10 Years", key: "10 Years" },
|
{ label: '10 Years', key: '10 Years' },
|
||||||
];
|
{ label: 'Full History', key: 'Full History', disabled: true },
|
||||||
|
]
|
||||||
|
|
||||||
// 分页大小选项
|
// 分页大小选项
|
||||||
const pageSizeOptions = [
|
const pageSizeOptions = [
|
||||||
@ -115,8 +117,8 @@ const pageSizeOptions = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
selectedPeriod: "Daily",
|
selectedPeriod: 'Daily',
|
||||||
selectedDuration: "3 Months",
|
selectedDuration: '3 Months',
|
||||||
tableData: [],
|
tableData: [],
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
pageSize: 50,
|
pageSize: 50,
|
||||||
@ -137,62 +139,65 @@ const paginatedData = computed(() => {
|
|||||||
// 表格列定义
|
// 表格列定义
|
||||||
const columns = [
|
const columns = [
|
||||||
{
|
{
|
||||||
title: "Date",
|
title: 'Date',
|
||||||
key: "date",
|
key: 'date',
|
||||||
align: "left",
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Open",
|
title: 'Open',
|
||||||
key: "open",
|
key: 'open',
|
||||||
align: "center",
|
align: 'center',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "High",
|
title: 'High',
|
||||||
key: "high",
|
key: 'high',
|
||||||
align: "center",
|
align: 'center',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Low",
|
title: 'Low',
|
||||||
key: "low",
|
key: 'low',
|
||||||
align: "center",
|
align: 'center',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Close",
|
title: 'Close',
|
||||||
key: "close",
|
key: 'close',
|
||||||
align: "center",
|
align: 'center',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Adj. Close",
|
title: 'Adj. Close',
|
||||||
key: "adjClose",
|
key: 'adjClose',
|
||||||
align: "center",
|
align: 'center',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Change",
|
title: 'Change',
|
||||||
key: "change",
|
key: 'change',
|
||||||
align: "center",
|
align: 'center',
|
||||||
render(row) {
|
render(row) {
|
||||||
const value = parseFloat(row.change);
|
const value = parseFloat(row.change)
|
||||||
const color = value < 0 ? "#ff4d4f" : value > 0 ? "#52c41a" : "";
|
const color = value < 0 ? '#ff4d4f' : value > 0 ? '#52c41a' : ''
|
||||||
return h("span", { style: { color } }, row.change);
|
return h('span', { style: { color } }, row.change)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "Volume",
|
title: 'Volume',
|
||||||
key: "volume",
|
key: 'volume',
|
||||||
align: "center",
|
align: 'center',
|
||||||
},
|
},
|
||||||
];
|
]
|
||||||
|
|
||||||
// 处理下拉选项变更
|
// 处理下拉选项变更
|
||||||
const handlePeriodChange = (key) => {
|
const handlePeriodChange = (key) => {
|
||||||
state.selectedPeriod = key;
|
if (key === 'Annual') {
|
||||||
getPageData();
|
handleDurationChange('Full History')
|
||||||
};
|
}
|
||||||
|
state.selectedPeriod = key
|
||||||
|
getPageData()
|
||||||
|
}
|
||||||
|
|
||||||
const handleDurationChange = (key) => {
|
const handleDurationChange = (key) => {
|
||||||
state.selectedDuration = key;
|
state.selectedDuration = key
|
||||||
getPageData();
|
getPageData()
|
||||||
};
|
}
|
||||||
|
|
||||||
// 处理分页
|
// 处理分页
|
||||||
const handlePrevPage = () => {
|
const handlePrevPage = () => {
|
||||||
@ -223,8 +228,8 @@ const scrollToTop = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getPageDefaultData();
|
getPageDefaultData()
|
||||||
});
|
})
|
||||||
|
|
||||||
const getPageDefaultData = async () => {
|
const getPageDefaultData = async () => {
|
||||||
try {
|
try {
|
||||||
@ -264,14 +269,59 @@ const getPageDefaultData = async () => {
|
|||||||
|
|
||||||
state.tableData = updatedTableData;
|
state.tableData = updatedTableData;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("获取数据失败", error);
|
console.error('获取数据失败', error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
|
||||||
const getPageData = async () => {
|
const getPageData = async () => {
|
||||||
let url =
|
let range = ''
|
||||||
"https://stockanalysis.com/api/symbol/a/OTC-MINM/history?type=chart";
|
if (state.selectedDuration === '3 Months') {
|
||||||
const res = await axios.get(url);
|
range = '3M'
|
||||||
};
|
} else if (state.selectedDuration === '6 Months') {
|
||||||
|
range = '6M'
|
||||||
|
} else if (state.selectedDuration === 'Year to Date') {
|
||||||
|
range = 'YTD'
|
||||||
|
} else if (state.selectedDuration === '1 Year') {
|
||||||
|
range = '1Y'
|
||||||
|
} else if (state.selectedDuration === '5 Years') {
|
||||||
|
range = '5Y'
|
||||||
|
} else if (state.selectedDuration === '10 Years') {
|
||||||
|
range = '10Y'
|
||||||
|
} else if (state.selectedDuration === 'Full History') {
|
||||||
|
range = 'Max'
|
||||||
|
}
|
||||||
|
let url = `https://stockanalysis.com/api/symbol/a/OTC-MINM/history?period=${state.selectedPeriod}&range=${range}`
|
||||||
|
const res = await axios.get(url)
|
||||||
|
if(res.data.status === 200){
|
||||||
|
console.error(res.data.data)
|
||||||
|
let resultData = res.data.data.map((item) => {
|
||||||
|
return {
|
||||||
|
date: item.t,
|
||||||
|
open: item.o != null ? Number(item.o).toFixed(2) : '',
|
||||||
|
high: item.h != null ? Number(item.h).toFixed(2) : '',
|
||||||
|
low: item.l != null ? Number(item.l).toFixed(2) : '',
|
||||||
|
close: item.c != null ? Number(item.c).toFixed(2) : '',
|
||||||
|
adjClose: item.a != null ? Number(item.a).toFixed(2) : '',
|
||||||
|
change: item.ch != null ? Number(item.ch).toFixed(2) + '%' : '',
|
||||||
|
volume: item.v,
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.error(resultData, 'resultData')
|
||||||
|
state.tableData = resultData
|
||||||
|
} else {
|
||||||
|
state.tableData = [
|
||||||
|
{
|
||||||
|
date: 'May 22, 2025',
|
||||||
|
open: '1.87',
|
||||||
|
high: '2.03',
|
||||||
|
low: '1.85',
|
||||||
|
close: '',
|
||||||
|
adjClose: '2.00',
|
||||||
|
change: '-2.44%',
|
||||||
|
volume: '2,103',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
Loading…
Reference in New Issue
Block a user