2.5 主营业务明细与历史对比表完善,增加非会员弹窗跳转,调整会员页面文字,财务数据模块单季度增加总值展示
This commit is contained in:
@@ -10,45 +10,260 @@ const _sfc_main = {
|
||||
activeIndex: 0,
|
||||
bkList: [],
|
||||
bkFilters: [
|
||||
"按涨幅",
|
||||
"按连板数",
|
||||
"只看龙头"
|
||||
],
|
||||
filterIndex: 0,
|
||||
selectedFullDate: ""
|
||||
selectedFullDate: "",
|
||||
// 年-月-日
|
||||
originData: null,
|
||||
// 原始接口数据
|
||||
allStocks: [],
|
||||
// 所有股票数据(带角色标签)
|
||||
// 角色配置
|
||||
STOCK_ROLES: {
|
||||
dragon: {
|
||||
text: "龙头",
|
||||
color: "#EC3440",
|
||||
bgColor: "#FFE8E9",
|
||||
icon: "/pagesStock/static/icon/first-icon1.png"
|
||||
},
|
||||
follow: {
|
||||
text: "跟风",
|
||||
color: "#F97316",
|
||||
bgColor: "#FFF0E6",
|
||||
icon: "/pagesStock/static/icon/first-icon2.png"
|
||||
},
|
||||
first: {
|
||||
text: "首板",
|
||||
color: "#01AB5D",
|
||||
bgColor: "#E4F9EF",
|
||||
icon: "/pagesStock/static/icon/first-icon.png"
|
||||
},
|
||||
normal: {
|
||||
text: "",
|
||||
color: "",
|
||||
bgColor: "",
|
||||
icon: ""
|
||||
}
|
||||
},
|
||||
// 连板层级样式配置(新规则)
|
||||
BOARD_LEVEL_STYLES: {
|
||||
dragon: {
|
||||
// 5板及以上 龙头
|
||||
color: "#ef4444",
|
||||
bgColor: "#FFE8E9",
|
||||
borderColor: "#ef4444"
|
||||
},
|
||||
high: {
|
||||
// 3-4板 高位
|
||||
color: "#f97316",
|
||||
bgColor: "#FFF0E6",
|
||||
borderColor: "#f97316"
|
||||
},
|
||||
mid: {
|
||||
// 2板 中位
|
||||
color: "#eab308",
|
||||
bgColor: "#FFF9E6",
|
||||
borderColor: "#eab308"
|
||||
},
|
||||
first: {
|
||||
// 1板 首板
|
||||
color: "#22c55e",
|
||||
bgColor: "#E4F9EF",
|
||||
borderColor: "#22c55e"
|
||||
}
|
||||
},
|
||||
// 板块文字颜色配置(新规则)
|
||||
SECTOR_COLOR_RULES: [
|
||||
{ keyword: "公告", color: "#D4AF37" },
|
||||
// 金色
|
||||
{ keyword: "其他", color: "#9CA3AF" },
|
||||
// 灰色
|
||||
{ keyword: ["AI", "人工智能", "芯片"], color: "#8B5CF6" },
|
||||
// 紫色
|
||||
{ keyword: ["锂电", "电池", "新能源"], color: "#10B981" },
|
||||
// 翠绿
|
||||
{ keyword: ["医药", "医疗"], color: "#EC4899" },
|
||||
// 粉色
|
||||
{ keyword: ["金融", "银行"], color: "#F59E0B" },
|
||||
// 橙黄
|
||||
{ keyword: ["军工", "航空"], color: "#EF4444" }
|
||||
// 红色
|
||||
],
|
||||
DEFAULT_SECTOR_COLOR: "#06B6D4"
|
||||
// 默认 青色
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
// 筛选后的股票列表
|
||||
filteredStocks() {
|
||||
var _a;
|
||||
if (!this.allStocks.length)
|
||||
return [];
|
||||
let stocks = [...this.allStocks];
|
||||
if (this.activeIndex >= 0 && this.bkList.length) {
|
||||
const currentSector = (_a = this.bkList[this.activeIndex]) == null ? void 0 : _a.title;
|
||||
if (currentSector) {
|
||||
stocks = stocks.filter((stock) => {
|
||||
const sectorMatch = stock.core_sectors.some((s) => s.includes(currentSector)) || (Array.isArray(stock.sector_category) ? stock.sector_category.includes(currentSector) : stock.sector_category === currentSector);
|
||||
return sectorMatch;
|
||||
});
|
||||
}
|
||||
}
|
||||
switch (this.filterIndex) {
|
||||
case 0:
|
||||
stocks.sort((a, b) => {
|
||||
const aDays = this.parseContinuousDays(a.continuous_days);
|
||||
const bDays = this.parseContinuousDays(b.continuous_days);
|
||||
return bDays - aDays;
|
||||
});
|
||||
break;
|
||||
case 1:
|
||||
stocks = stocks.filter((stock) => this.parseContinuousDays(stock.continuous_days) >= 2);
|
||||
stocks.sort((a, b) => {
|
||||
const aDays = this.parseContinuousDays(a.continuous_days);
|
||||
const bDays = this.parseContinuousDays(b.continuous_days);
|
||||
return bDays - aDays;
|
||||
});
|
||||
break;
|
||||
}
|
||||
return stocks;
|
||||
}
|
||||
},
|
||||
onLoad(e) {
|
||||
this.activeIndex = e.index;
|
||||
this.selectedFullDate = e.data;
|
||||
common_vendor.index.__f__("log", "at pagesStock/stockCenterDetails/bkydmx.vue:237", "selectedFullDate", this.selectedFullDate);
|
||||
this.contentTop = this.navH + 20 / 750 * common_vendor.inject("windowWidth");
|
||||
this.fetchData();
|
||||
},
|
||||
methods: {
|
||||
getPreviousDayDate(dateStr) {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(dateStr)) {
|
||||
common_vendor.index.__f__("error", "at pagesStock/stockCenterDetails/bkydmx.vue:104", "日期格式错误,请传入 YYYY-MM-DD 格式的日期");
|
||||
return "";
|
||||
// 解析连板数
|
||||
parseContinuousDays(continuousDaysStr) {
|
||||
if (!continuousDaysStr)
|
||||
return 0;
|
||||
const match = continuousDaysStr.match(/(\d+)天/);
|
||||
return match ? Number(match[1]) : 0;
|
||||
},
|
||||
// 格式化连板文本(适配新层级)
|
||||
formatBoardText(continuousDaysStr) {
|
||||
const boardDays = this.parseContinuousDays(continuousDaysStr);
|
||||
if (boardDays === 1)
|
||||
return "首板";
|
||||
if (boardDays > 1)
|
||||
return `${boardDays}连板`;
|
||||
return "";
|
||||
},
|
||||
// 获取连板标签样式(按新层级规则)
|
||||
getBoardTagStyleByLevel(continuousDaysStr) {
|
||||
const boardDays = this.parseContinuousDays(continuousDaysStr);
|
||||
let styleConfig = {};
|
||||
if (boardDays >= 5) {
|
||||
styleConfig = this.BOARD_LEVEL_STYLES.dragon;
|
||||
} else if (boardDays >= 3 && boardDays <= 4) {
|
||||
styleConfig = this.BOARD_LEVEL_STYLES.high;
|
||||
} else if (boardDays === 2) {
|
||||
styleConfig = this.BOARD_LEVEL_STYLES.mid;
|
||||
} else if (boardDays === 1) {
|
||||
styleConfig = this.BOARD_LEVEL_STYLES.first;
|
||||
}
|
||||
const [year, month, day] = dateStr.split("-").map(Number);
|
||||
const date = new Date(year, month - 1, day);
|
||||
date.setDate(date.getDate() - 2);
|
||||
const prevYear = date.getFullYear();
|
||||
const prevMonth = String(date.getMonth() + 1).padStart(2, "0");
|
||||
const prevDay = String(date.getDate()).padStart(2, "0");
|
||||
return `${prevYear}${prevMonth}${prevDay}`;
|
||||
return {
|
||||
"color": styleConfig.color || "#FFFFFF",
|
||||
"background-color": styleConfig.bgColor || "#eab308",
|
||||
"border": `1rpx solid ${styleConfig.borderColor || "#eab308"}`
|
||||
};
|
||||
},
|
||||
// 获取板块文字颜色(按关键词匹配)
|
||||
getSectorTextColor(sectorName) {
|
||||
if (!sectorName)
|
||||
return this.DEFAULT_SECTOR_COLOR;
|
||||
for (const rule of this.SECTOR_COLOR_RULES) {
|
||||
if (Array.isArray(rule.keyword)) {
|
||||
const isMatch = rule.keyword.some((key) => sectorName.includes(key));
|
||||
if (isMatch)
|
||||
return rule.color;
|
||||
} else {
|
||||
if (sectorName === rule.keyword)
|
||||
return rule.color;
|
||||
}
|
||||
}
|
||||
return this.DEFAULT_SECTOR_COLOR;
|
||||
},
|
||||
// 获取股票角色
|
||||
getStockRole(stock, sectorStocks, sectorIndex) {
|
||||
var _a;
|
||||
const boardDays = this.parseContinuousDays(stock.continuous_days);
|
||||
if (boardDays >= 5) {
|
||||
return this.STOCK_ROLES.dragon;
|
||||
}
|
||||
if (boardDays === 1) {
|
||||
return this.STOCK_ROLES.first;
|
||||
}
|
||||
if (sectorIndex < 3 && boardDays >= 2 && boardDays < 5) {
|
||||
const sortedByTime = [...sectorStocks].sort(
|
||||
(a, b) => (a.zt_time || "").localeCompare(b.zt_time || "")
|
||||
);
|
||||
if (((_a = sortedByTime[0]) == null ? void 0 : _a.scode) === stock.scode && boardDays >= 3) {
|
||||
return this.STOCK_ROLES.dragon;
|
||||
}
|
||||
return this.STOCK_ROLES.follow;
|
||||
}
|
||||
return this.STOCK_ROLES.normal;
|
||||
},
|
||||
// 获取角色标签样式
|
||||
getRoleTagStyle(role) {
|
||||
return {
|
||||
"background-color": role.bgColor
|
||||
};
|
||||
},
|
||||
// 处理板块切换
|
||||
handleTabChange(index) {
|
||||
this.activeIndex = index;
|
||||
this.setStockRoles();
|
||||
},
|
||||
// 处理筛选切换
|
||||
handleFilterChange(index) {
|
||||
this.filterIndex = index;
|
||||
},
|
||||
// 为所有股票添加角色标签
|
||||
setStockRoles() {
|
||||
if (!this.originData || !this.originData.stocks || !this.bkList.length)
|
||||
return;
|
||||
common_vendor.index.__f__("log", "at pagesStock/stockCenterDetails/bkydmx.vue:357", "setStockRoles", JSON.stringify(this.originData.stocks));
|
||||
this.allStocks = this.originData.stocks.map((stock) => {
|
||||
let sectorIndex = -1;
|
||||
const stockSectors = Array.isArray(stock.sector_category) ? stock.sector_category : [stock.sector_category];
|
||||
this.bkList.some((bk, idx) => {
|
||||
const match = stockSectors.some((s) => s.includes(bk.title));
|
||||
if (match) {
|
||||
sectorIndex = idx;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
const sectorStocks = this.originData.stocks.filter((s) => {
|
||||
const sSectors = Array.isArray(s.sector_category) ? s.sector_category : [s.sector_category];
|
||||
return sSectors.some((ss) => stockSectors.includes(ss));
|
||||
});
|
||||
const stockRole = this.getStockRole(stock, sectorStocks, sectorIndex);
|
||||
return {
|
||||
...stock,
|
||||
stockRole: stockRole.text ? stockRole : null
|
||||
};
|
||||
});
|
||||
},
|
||||
/**
|
||||
* 请求接口数据(优化:动态日期+自动时间戳)
|
||||
*/
|
||||
// 请求接口数据
|
||||
async fetchData() {
|
||||
try {
|
||||
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
||||
const formattedDate = this.getPreviousDayDate(this.selectedFullDate);
|
||||
const formattedDate = this.selectedFullDate;
|
||||
const baseURL = request_http.getBaseURL1();
|
||||
const requestUrl = `${baseURL}/data/zt/daily/${formattedDate}.json?t=${timestamp}`;
|
||||
common_vendor.index.__f__("log", "at pagesStock/stockCenterDetails/bkydmx.vue:137", "请求URL:", requestUrl);
|
||||
common_vendor.index.__f__("log", "at pagesStock/stockCenterDetails/bkydmx.vue:401", "请求URL:", requestUrl);
|
||||
const res = await common_vendor.index.request({
|
||||
url: requestUrl,
|
||||
method: "GET"
|
||||
@@ -59,19 +274,18 @@ const _sfc_main = {
|
||||
const labels = chartData.labels || [];
|
||||
const counts = chartData.counts || [];
|
||||
const maxCount = counts.length > 0 ? Math.max(...counts) : 0;
|
||||
let bkList = [];
|
||||
const maxLen = Math.min(labels.length, counts.length);
|
||||
let bkList = [];
|
||||
for (let i = 0; i < maxLen; i++) {
|
||||
const title = labels[i];
|
||||
const count = counts[i] || 0;
|
||||
bkList.push({
|
||||
title,
|
||||
// 板块名称
|
||||
count
|
||||
// 数量
|
||||
});
|
||||
}
|
||||
this.bkList = bkList;
|
||||
this.setStockRoles();
|
||||
} else {
|
||||
common_vendor.index.showToast({
|
||||
title: "数据请求失败",
|
||||
@@ -79,7 +293,7 @@ const _sfc_main = {
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
common_vendor.index.__f__("error", "at pagesStock/stockCenterDetails/bkydmx.vue:178", "请求异常:", error);
|
||||
common_vendor.index.__f__("error", "at pagesStock/stockCenterDetails/bkydmx.vue:440", "请求异常:", error);
|
||||
common_vendor.index.showToast({
|
||||
title: "网络异常",
|
||||
icon: "none"
|
||||
@@ -118,7 +332,7 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
e: common_vendor.f($data.bkFilters, (item, index, i0) => {
|
||||
return {
|
||||
a: common_vendor.t(item),
|
||||
b: common_vendor.o(($event) => $data.filterIndex = index, index),
|
||||
b: common_vendor.o(($event) => $options.handleFilterChange(index), index),
|
||||
c: $data.filterIndex == index ? "#070707" : "#939393",
|
||||
d: $data.filterIndex == index ? "1rpx solid #F2C369" : "1rpx solid #E5E5E5",
|
||||
e: $data.filterIndex == index ? "#F2C369" : "#fff",
|
||||
@@ -132,13 +346,28 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||||
c: index == 0 ? "left" : "center"
|
||||
};
|
||||
}),
|
||||
g: common_vendor.f(30, (item, index, i0) => {
|
||||
return {
|
||||
a: index % 2 == 0 ? "#fff" : "#FAFAFC"
|
||||
};
|
||||
g: common_vendor.f($options.filteredStocks, (item, index, i0) => {
|
||||
return common_vendor.e({
|
||||
a: item.stockRole
|
||||
}, item.stockRole ? common_vendor.e({
|
||||
b: item.stockRole.icon
|
||||
}, item.stockRole.icon ? {
|
||||
c: item.stockRole.icon
|
||||
} : {}, {
|
||||
d: common_vendor.t(item.stockRole.text),
|
||||
e: item.stockRole.color,
|
||||
f: common_vendor.s($options.getRoleTagStyle(item.stockRole))
|
||||
}) : {}, {
|
||||
g: common_vendor.t(item.sname),
|
||||
h: common_vendor.t($options.formatBoardText(item.continuous_days)),
|
||||
i: common_vendor.s($options.getBoardTagStyleByLevel(item.continuous_days)),
|
||||
j: common_vendor.t(item.core_sectors[0] || "未知板块"),
|
||||
k: $options.getSectorTextColor(item.core_sectors[0] || "未知板块"),
|
||||
l: item.scode,
|
||||
m: index % 2 == 0 ? "#fff" : "#FAFAFC"
|
||||
});
|
||||
}),
|
||||
h: common_assets._imports_1$12,
|
||||
i: common_vendor.s("top:" + $data.contentTop + "px;")
|
||||
h: common_vendor.s("top:" + $data.contentTop + "px;")
|
||||
};
|
||||
}
|
||||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||||
|
||||
Reference in New Issue
Block a user