|
@@ -10,6 +10,7 @@ const _sfc_main = {
|
|
|
const hasSearched = common_vendor.ref(false);
|
|
const hasSearched = common_vendor.ref(false);
|
|
|
const errorMsg = common_vendor.ref("");
|
|
const errorMsg = common_vendor.ref("");
|
|
|
const result = common_vendor.ref(null);
|
|
const result = common_vendor.ref(null);
|
|
|
|
|
+ const historyData = common_vendor.ref(null);
|
|
|
const suggestions = common_vendor.ref([]);
|
|
const suggestions = common_vendor.ref([]);
|
|
|
const showDropdown = common_vendor.ref(false);
|
|
const showDropdown = common_vendor.ref(false);
|
|
|
const isLoggedIn = common_vendor.ref(false);
|
|
const isLoggedIn = common_vendor.ref(false);
|
|
@@ -103,14 +104,22 @@ const _sfc_main = {
|
|
|
hasSearched.value = true;
|
|
hasSearched.value = true;
|
|
|
errorMsg.value = "";
|
|
errorMsg.value = "";
|
|
|
result.value = null;
|
|
result.value = null;
|
|
|
|
|
+ historyData.value = null;
|
|
|
suggestions.value = [];
|
|
suggestions.value = [];
|
|
|
showDropdown.value = false;
|
|
showDropdown.value = false;
|
|
|
try {
|
|
try {
|
|
|
- const res = await utils_api.searchStocks(queryCode);
|
|
|
|
|
- if (res.code === 200 && res.data) {
|
|
|
|
|
- result.value = res.data;
|
|
|
|
|
|
|
+ const [stockRes, historyRes] = await Promise.all([
|
|
|
|
|
+ utils_api.searchStocks(queryCode),
|
|
|
|
|
+ utils_api.searchStockHistory(queryCode)
|
|
|
|
|
+ ]);
|
|
|
|
|
+ if (stockRes.code === 200 && stockRes.data) {
|
|
|
|
|
+ result.value = stockRes.data;
|
|
|
} else {
|
|
} else {
|
|
|
- errorMsg.value = res.message || "未查询到相关股票数据";
|
|
|
|
|
|
|
+ errorMsg.value = stockRes.message || "未查询到相关股票数据";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (historyRes.code === 200 && historyRes.data && historyRes.data.found) {
|
|
|
|
|
+ historyData.value = historyRes.data;
|
|
|
|
|
+ console.log("历史数据:", historyData.value);
|
|
|
}
|
|
}
|
|
|
} catch (err) {
|
|
} catch (err) {
|
|
|
errorMsg.value = "网络请求失败,请检查网络连接";
|
|
errorMsg.value = "网络请求失败,请检查网络连接";
|
|
@@ -132,6 +141,41 @@ const _sfc_main = {
|
|
|
return "price-down";
|
|
return "price-down";
|
|
|
return "";
|
|
return "";
|
|
|
};
|
|
};
|
|
|
|
|
+ const getChangeClass = (value) => {
|
|
|
|
|
+ if (value === null || value === void 0)
|
|
|
|
|
+ return "";
|
|
|
|
|
+ const num = parseFloat(value);
|
|
|
|
|
+ if (num > 0)
|
|
|
|
|
+ return "price-up";
|
|
|
|
|
+ if (num < 0)
|
|
|
|
|
+ return "price-down";
|
|
|
|
|
+ return "";
|
|
|
|
|
+ };
|
|
|
|
|
+ const formatPercent = (value) => {
|
|
|
|
|
+ if (value === null || value === void 0)
|
|
|
|
|
+ return "--";
|
|
|
|
|
+ const num = parseFloat(value);
|
|
|
|
|
+ const prefix = num > 0 ? "+" : "";
|
|
|
|
|
+ return `${prefix}${num.toFixed(2)}%`;
|
|
|
|
|
+ };
|
|
|
|
|
+ const formatAmount = (value) => {
|
|
|
|
|
+ if (!value)
|
|
|
|
|
+ return "--";
|
|
|
|
|
+ const num = parseFloat(value);
|
|
|
|
|
+ if (num >= 1e8) {
|
|
|
|
|
+ return (num / 1e8).toFixed(2) + "亿";
|
|
|
|
|
+ } else if (num >= 1e4) {
|
|
|
|
|
+ return (num / 1e4).toFixed(2) + "万";
|
|
|
|
|
+ }
|
|
|
|
|
+ return num.toFixed(2);
|
|
|
|
|
+ };
|
|
|
|
|
+ const formatStrengthScore = (value) => {
|
|
|
|
|
+ if (value === null || value === void 0)
|
|
|
|
|
+ return "--";
|
|
|
|
|
+ const num = parseFloat(value);
|
|
|
|
|
+ const prefix = num >= 0 ? "+" : "";
|
|
|
|
|
+ return `${prefix}${num.toFixed(2)}`;
|
|
|
|
|
+ };
|
|
|
return (_ctx, _cache) => {
|
|
return (_ctx, _cache) => {
|
|
|
return common_vendor.e({
|
|
return common_vendor.e({
|
|
|
a: common_vendor.o([($event) => keyword.value = $event.detail.value, onKeywordChange]),
|
|
a: common_vendor.o([($event) => keyword.value = $event.detail.value, onKeywordChange]),
|
|
@@ -177,9 +221,59 @@ const _sfc_main = {
|
|
|
}, result.value.score ? {
|
|
}, result.value.score ? {
|
|
|
D: common_vendor.t(result.value.score)
|
|
D: common_vendor.t(result.value.score)
|
|
|
} : {}, {
|
|
} : {}, {
|
|
|
- E: result.value.history && result.value.history.length > 0
|
|
|
|
|
|
|
+ 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
|
|
|
|
|
+ }, 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")
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ J: historyData.value.closePrice
|
|
|
|
|
+ }, historyData.value.closePrice ? {
|
|
|
|
|
+ K: common_vendor.t(historyData.value.closePrice)
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ L: historyData.value.changePercent
|
|
|
|
|
+ }, historyData.value.changePercent ? {
|
|
|
|
|
+ M: common_vendor.t(formatPercent(historyData.value.changePercent)),
|
|
|
|
|
+ N: common_vendor.n(getChangeClass(historyData.value.changePercent))
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ O: historyData.value.totalAmount
|
|
|
|
|
+ }, historyData.value.totalAmount ? {
|
|
|
|
|
+ P: common_vendor.t(formatAmount(historyData.value.totalAmount))
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ Q: historyData.value.circulationMarketValue
|
|
|
|
|
+ }, historyData.value.circulationMarketValue ? {
|
|
|
|
|
+ R: common_vendor.t(formatAmount(historyData.value.circulationMarketValue))
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ S: historyData.value.mainRisePeriod
|
|
|
|
|
+ }, historyData.value.mainRisePeriod ? {
|
|
|
|
|
+ T: common_vendor.t(historyData.value.mainRisePeriod)
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ U: historyData.value.recentLimitUp
|
|
|
|
|
+ }, historyData.value.recentLimitUp ? {
|
|
|
|
|
+ V: 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
|
|
|
|
|
+ }, historyData.value.dayHighestPrice ? {
|
|
|
|
|
+ Y: common_vendor.t(historyData.value.dayHighestPrice)
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ Z: historyData.value.dayLowestPrice
|
|
|
|
|
+ }, historyData.value.dayLowestPrice ? {
|
|
|
|
|
+ aa: common_vendor.t(historyData.value.dayLowestPrice)
|
|
|
|
|
+ } : {}, {
|
|
|
|
|
+ ab: historyData.value.dayClosePrice
|
|
|
|
|
+ }, historyData.value.dayClosePrice ? {
|
|
|
|
|
+ ac: 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
|
|
|
}, result.value.history && result.value.history.length > 0 ? {
|
|
}, result.value.history && result.value.history.length > 0 ? {
|
|
|
- F: common_vendor.f(result.value.history, (item, index, i0) => {
|
|
|
|
|
|
|
+ ag: common_vendor.f(result.value.history, (item, index, i0) => {
|
|
|
return {
|
|
return {
|
|
|
a: common_vendor.t(item.date),
|
|
a: common_vendor.t(item.date),
|
|
|
b: common_vendor.t(item.score),
|
|
b: common_vendor.t(item.score),
|
|
@@ -188,9 +282,9 @@ const _sfc_main = {
|
|
|
};
|
|
};
|
|
|
})
|
|
})
|
|
|
} : {}, {
|
|
} : {}, {
|
|
|
- G: result.value.factors && result.value.factors.length > 0
|
|
|
|
|
|
|
+ ah: result.value.factors && result.value.factors.length > 0
|
|
|
}, result.value.factors && result.value.factors.length > 0 ? {
|
|
}, result.value.factors && result.value.factors.length > 0 ? {
|
|
|
- H: common_vendor.f(result.value.factors, (item, index, i0) => {
|
|
|
|
|
|
|
+ ai: common_vendor.f(result.value.factors, (item, index, i0) => {
|
|
|
return {
|
|
return {
|
|
|
a: common_vendor.t(item.name),
|
|
a: common_vendor.t(item.name),
|
|
|
b: common_vendor.t(item.value),
|
|
b: common_vendor.t(item.value),
|