|
|
@@ -2,6 +2,10 @@
|
|
|
const common_vendor = require("../../common/vendor.js");
|
|
|
const utils_api = require("../../utils/api.js");
|
|
|
const utils_auth = require("../../utils/auth.js");
|
|
|
+if (!Math) {
|
|
|
+ DateSelector();
|
|
|
+}
|
|
|
+const DateSelector = () => "../../components/DateSelector.js";
|
|
|
const _sfc_main = {
|
|
|
__name: "index",
|
|
|
setup(__props) {
|
|
|
@@ -14,6 +18,8 @@ const _sfc_main = {
|
|
|
const suggestions = common_vendor.ref([]);
|
|
|
const showDropdown = common_vendor.ref(false);
|
|
|
const isLoggedIn = common_vendor.ref(false);
|
|
|
+ const selectedDate = common_vendor.ref("");
|
|
|
+ const currentStockCode = common_vendor.ref("");
|
|
|
let timer = null;
|
|
|
common_vendor.onMounted(() => {
|
|
|
isLoggedIn.value = utils_auth.isLoggedIn();
|
|
|
@@ -77,6 +83,22 @@ const _sfc_main = {
|
|
|
}
|
|
|
};
|
|
|
const onSelectSuggestion = (item) => {
|
|
|
+ if (!isLoggedIn.value) {
|
|
|
+ common_vendor.index.showModal({
|
|
|
+ title: "登录提示",
|
|
|
+ content: "此功能需要登录后使用,是否前往登录?",
|
|
|
+ confirmText: "去登录",
|
|
|
+ cancelText: "取消",
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ common_vendor.index.navigateTo({
|
|
|
+ url: "/pages/login/login"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
const searchText = `${item.name} (${item.code})`;
|
|
|
keyword.value = searchText;
|
|
|
suggestions.value = [];
|
|
|
@@ -108,25 +130,48 @@ const _sfc_main = {
|
|
|
suggestions.value = [];
|
|
|
showDropdown.value = false;
|
|
|
try {
|
|
|
- const [stockRes, historyRes] = await Promise.all([
|
|
|
- utils_api.searchStocks(queryCode),
|
|
|
- utils_api.searchStockHistory(queryCode)
|
|
|
- ]);
|
|
|
+ const stockRes = await utils_api.searchStocks(queryCode);
|
|
|
if (stockRes.code === 200 && stockRes.data) {
|
|
|
result.value = stockRes.data;
|
|
|
+ currentStockCode.value = queryCode;
|
|
|
+ try {
|
|
|
+ const historyRes = await utils_api.searchStockHistory(queryCode, selectedDate.value);
|
|
|
+ if (historyRes.code === 200 && historyRes.data && historyRes.data.found) {
|
|
|
+ historyData.value = historyRes.data;
|
|
|
+ console.log("历史数据:", historyData.value);
|
|
|
+ } else {
|
|
|
+ console.log("未找到历史数据");
|
|
|
+ }
|
|
|
+ } catch (historyErr) {
|
|
|
+ console.error("查询历史数据失败:", historyErr);
|
|
|
+ }
|
|
|
} else {
|
|
|
errorMsg.value = stockRes.message || "未查询到相关股票数据";
|
|
|
}
|
|
|
- if (historyRes.code === 200 && historyRes.data && historyRes.data.found) {
|
|
|
- historyData.value = historyRes.data;
|
|
|
- console.log("历史数据:", historyData.value);
|
|
|
- }
|
|
|
} catch (err) {
|
|
|
errorMsg.value = "网络请求失败,请检查网络连接";
|
|
|
} finally {
|
|
|
loading.value = false;
|
|
|
}
|
|
|
};
|
|
|
+ const onDateChange = async (dateStr) => {
|
|
|
+ selectedDate.value = dateStr;
|
|
|
+ console.log("选择的日期:", selectedDate.value);
|
|
|
+ if (currentStockCode.value && hasSearched.value && result.value) {
|
|
|
+ historyData.value = null;
|
|
|
+ try {
|
|
|
+ const historyRes = await utils_api.searchStockHistory(currentStockCode.value, selectedDate.value);
|
|
|
+ if (historyRes.code === 200 && historyRes.data && historyRes.data.found) {
|
|
|
+ historyData.value = historyRes.data;
|
|
|
+ console.log("历史数据:", historyData.value);
|
|
|
+ } else {
|
|
|
+ console.log("未找到该日期的历史数据");
|
|
|
+ }
|
|
|
+ } catch (historyErr) {
|
|
|
+ console.error("查询历史数据失败:", historyErr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
const onInputBlur = () => {
|
|
|
setTimeout(() => {
|
|
|
showDropdown.value = false;
|
|
|
@@ -221,59 +266,67 @@ const _sfc_main = {
|
|
|
}, result.value.score ? {
|
|
|
D: common_vendor.t(result.value.score)
|
|
|
} : {}, {
|
|
|
- E: historyData.value && (historyData.value.strengthScore !== null || historyData.value.highTrend !== null)
|
|
|
- }, historyData.value && (historyData.value.strengthScore !== null || historyData.value.highTrend !== null) ? common_vendor.e({
|
|
|
- F: common_vendor.t(historyData.value.recordDate),
|
|
|
- G: historyData.value.strengthScore !== null && historyData.value.strengthScore !== void 0
|
|
|
+ E: hasSearched.value && result.value
|
|
|
+ }, hasSearched.value && result.value ? common_vendor.e({
|
|
|
+ F: common_vendor.o(onDateChange),
|
|
|
+ G: historyData.value && historyData.value.recordDate
|
|
|
+ }, historyData.value && historyData.value.recordDate ? {
|
|
|
+ H: common_vendor.t(historyData.value.recordDate)
|
|
|
+ } : {}, {
|
|
|
+ I: !historyData.value || !historyData.value.strengthScore && !historyData.value.highTrend
|
|
|
+ }, !historyData.value || !historyData.value.strengthScore && !historyData.value.highTrend ? {
|
|
|
+ J: common_vendor.t(selectedDate.value ? "未找到该日期的历史数据" : "暂无历史数据")
|
|
|
+ } : common_vendor.e({
|
|
|
+ K: historyData.value.strengthScore !== null && historyData.value.strengthScore !== void 0
|
|
|
}, historyData.value.strengthScore !== null && historyData.value.strengthScore !== void 0 ? {
|
|
|
- H: common_vendor.t(formatStrengthScore(historyData.value.strengthScore)),
|
|
|
- I: common_vendor.n(historyData.value.strengthScore >= 0 ? "capsule-up" : "capsule-down")
|
|
|
+ L: common_vendor.t(formatStrengthScore(historyData.value.strengthScore)),
|
|
|
+ M: common_vendor.n(historyData.value.strengthScore >= 0 ? "capsule-up" : "capsule-down")
|
|
|
} : {}, {
|
|
|
- J: historyData.value.closePrice
|
|
|
+ N: historyData.value.closePrice
|
|
|
}, historyData.value.closePrice ? {
|
|
|
- K: common_vendor.t(historyData.value.closePrice)
|
|
|
+ O: common_vendor.t(historyData.value.closePrice)
|
|
|
} : {}, {
|
|
|
- L: historyData.value.changePercent
|
|
|
+ P: historyData.value.changePercent
|
|
|
}, historyData.value.changePercent ? {
|
|
|
- M: common_vendor.t(formatPercent(historyData.value.changePercent)),
|
|
|
- N: common_vendor.n(getChangeClass(historyData.value.changePercent))
|
|
|
+ Q: common_vendor.t(formatPercent(historyData.value.changePercent)),
|
|
|
+ R: common_vendor.n(getChangeClass(historyData.value.changePercent))
|
|
|
} : {}, {
|
|
|
- O: historyData.value.totalAmount
|
|
|
+ S: historyData.value.totalAmount
|
|
|
}, historyData.value.totalAmount ? {
|
|
|
- P: common_vendor.t(formatAmount(historyData.value.totalAmount))
|
|
|
+ T: common_vendor.t(formatAmount(historyData.value.totalAmount))
|
|
|
} : {}, {
|
|
|
- Q: historyData.value.circulationMarketValue
|
|
|
+ U: historyData.value.circulationMarketValue
|
|
|
}, historyData.value.circulationMarketValue ? {
|
|
|
- R: common_vendor.t(formatAmount(historyData.value.circulationMarketValue))
|
|
|
+ V: common_vendor.t(formatAmount(historyData.value.circulationMarketValue))
|
|
|
} : {}, {
|
|
|
- S: historyData.value.mainRisePeriod
|
|
|
+ W: historyData.value.mainRisePeriod
|
|
|
}, historyData.value.mainRisePeriod ? {
|
|
|
- T: common_vendor.t(historyData.value.mainRisePeriod)
|
|
|
+ X: common_vendor.t(historyData.value.mainRisePeriod)
|
|
|
} : {}, {
|
|
|
- U: historyData.value.recentLimitUp
|
|
|
+ Y: historyData.value.recentLimitUp
|
|
|
}, historyData.value.recentLimitUp ? {
|
|
|
- V: common_vendor.t(historyData.value.recentLimitUp)
|
|
|
+ Z: common_vendor.t(historyData.value.recentLimitUp)
|
|
|
} : {}, {
|
|
|
- W: historyData.value.highTrend !== null && historyData.value.highTrend !== void 0
|
|
|
- }, historyData.value.highTrend !== null && historyData.value.highTrend !== void 0 ? common_vendor.e({
|
|
|
- X: historyData.value.dayHighestPrice
|
|
|
+ aa: historyData.value.dayHighestPrice
|
|
|
}, historyData.value.dayHighestPrice ? {
|
|
|
- Y: common_vendor.t(historyData.value.dayHighestPrice)
|
|
|
+ ab: common_vendor.t(historyData.value.dayHighestPrice)
|
|
|
} : {}, {
|
|
|
- Z: historyData.value.dayLowestPrice
|
|
|
+ ac: historyData.value.dayLowestPrice
|
|
|
}, historyData.value.dayLowestPrice ? {
|
|
|
- aa: common_vendor.t(historyData.value.dayLowestPrice)
|
|
|
+ ad: common_vendor.t(historyData.value.dayLowestPrice)
|
|
|
} : {}, {
|
|
|
- ab: historyData.value.dayClosePrice
|
|
|
+ ae: historyData.value.dayClosePrice
|
|
|
}, historyData.value.dayClosePrice ? {
|
|
|
- ac: common_vendor.t(historyData.value.dayClosePrice)
|
|
|
+ af: common_vendor.t(historyData.value.dayClosePrice)
|
|
|
} : {}, {
|
|
|
- ad: common_vendor.t(formatPercent(historyData.value.highTrend)),
|
|
|
- ae: common_vendor.n(getChangeClass(historyData.value.highTrend))
|
|
|
- }) : {}) : {}, {
|
|
|
- af: result.value.history && result.value.history.length > 0
|
|
|
+ ag: historyData.value.highTrend !== null && historyData.value.highTrend !== void 0
|
|
|
+ }, historyData.value.highTrend !== null && historyData.value.highTrend !== void 0 ? {
|
|
|
+ ah: common_vendor.t(formatPercent(historyData.value.highTrend)),
|
|
|
+ ai: common_vendor.n(getChangeClass(historyData.value.highTrend))
|
|
|
+ } : {})) : {}, {
|
|
|
+ aj: result.value.history && result.value.history.length > 0
|
|
|
}, result.value.history && result.value.history.length > 0 ? {
|
|
|
- ag: common_vendor.f(result.value.history, (item, index, i0) => {
|
|
|
+ ak: common_vendor.f(result.value.history, (item, index, i0) => {
|
|
|
return {
|
|
|
a: common_vendor.t(item.date),
|
|
|
b: common_vendor.t(item.score),
|
|
|
@@ -282,9 +335,9 @@ const _sfc_main = {
|
|
|
};
|
|
|
})
|
|
|
} : {}, {
|
|
|
- ah: result.value.factors && result.value.factors.length > 0
|
|
|
+ al: result.value.factors && result.value.factors.length > 0
|
|
|
}, result.value.factors && result.value.factors.length > 0 ? {
|
|
|
- ai: common_vendor.f(result.value.factors, (item, index, i0) => {
|
|
|
+ am: common_vendor.f(result.value.factors, (item, index, i0) => {
|
|
|
return {
|
|
|
a: common_vendor.t(item.name),
|
|
|
b: common_vendor.t(item.value),
|