147 lines
5.0 KiB
JavaScript
147 lines
5.0 KiB
JavaScript
"use strict";
|
||
const common_vendor = require("../../common/vendor.js");
|
||
const request_http = require("../../request/http.js");
|
||
const common_assets = require("../../common/assets.js");
|
||
const _sfc_main = {
|
||
data() {
|
||
return {
|
||
navH: common_vendor.inject("navHeight"),
|
||
contentTop: "",
|
||
activeIndex: 0,
|
||
bkList: [],
|
||
bkFilters: [
|
||
"按涨幅",
|
||
"按连板数",
|
||
"只看龙头"
|
||
],
|
||
filterIndex: 0,
|
||
selectedFullDate: ""
|
||
// 年-月-日
|
||
};
|
||
},
|
||
onLoad(e) {
|
||
this.activeIndex = e.index;
|
||
this.selectedFullDate = e.data;
|
||
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 "";
|
||
}
|
||
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}`;
|
||
},
|
||
/**
|
||
* 请求接口数据(优化:动态日期+自动时间戳)
|
||
*/
|
||
async fetchData() {
|
||
try {
|
||
const timestamp = (/* @__PURE__ */ new Date()).getTime();
|
||
const formattedDate = this.getPreviousDayDate(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);
|
||
const res = await common_vendor.index.request({
|
||
url: requestUrl,
|
||
method: "GET"
|
||
});
|
||
if (res.statusCode === 200 && res.data) {
|
||
this.originData = res.data;
|
||
const chartData = this.originData.chart_data || {};
|
||
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);
|
||
for (let i = 0; i < maxLen; i++) {
|
||
const title = labels[i];
|
||
const count = counts[i] || 0;
|
||
bkList.push({
|
||
title,
|
||
// 板块名称
|
||
count
|
||
// 数量
|
||
});
|
||
}
|
||
this.bkList = bkList;
|
||
} else {
|
||
common_vendor.index.showToast({
|
||
title: "数据请求失败",
|
||
icon: "none"
|
||
});
|
||
}
|
||
} catch (error) {
|
||
common_vendor.index.__f__("error", "at pagesStock/stockCenterDetails/bkydmx.vue:178", "请求异常:", error);
|
||
common_vendor.index.showToast({
|
||
title: "网络异常",
|
||
icon: "none"
|
||
});
|
||
}
|
||
}
|
||
}
|
||
};
|
||
if (!Array) {
|
||
const _easycom_navBar2 = common_vendor.resolveComponent("navBar");
|
||
_easycom_navBar2();
|
||
}
|
||
const _easycom_navBar = () => "../../components/navBar/navBar.js";
|
||
if (!Math) {
|
||
_easycom_navBar();
|
||
}
|
||
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
||
return {
|
||
a: common_vendor.p({
|
||
leftText: "板块异动明细",
|
||
hideNavBg: true
|
||
}),
|
||
b: common_assets._imports_0,
|
||
c: common_vendor.f($data.bkList, (item, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(item.title),
|
||
b: "tab-" + index,
|
||
c: common_vendor.o(($event) => $data.activeIndex = index, index),
|
||
d: index,
|
||
e: $data.activeIndex == index ? "#2B2B2B" : "#999999",
|
||
f: $data.activeIndex == index ? "1rpx solid #F2C369" : "none",
|
||
g: $data.activeIndex == index ? "28rpx" : "26rpx"
|
||
};
|
||
}),
|
||
d: "tab-" + $data.activeIndex,
|
||
e: common_vendor.f($data.bkFilters, (item, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(item),
|
||
b: common_vendor.o(($event) => $data.filterIndex = index, index),
|
||
c: $data.filterIndex == index ? "#070707" : "#939393",
|
||
d: $data.filterIndex == index ? "1rpx solid #F2C369" : "1rpx solid #E5E5E5",
|
||
e: $data.filterIndex == index ? "#F2C369" : "#fff",
|
||
f: index
|
||
};
|
||
}),
|
||
f: common_vendor.f(["名称", "涨幅", "连板", "板块"], (item, index, i0) => {
|
||
return {
|
||
a: common_vendor.t(item),
|
||
b: index,
|
||
c: index == 0 ? "left" : "center"
|
||
};
|
||
}),
|
||
g: common_vendor.f(30, (item, index, i0) => {
|
||
return {
|
||
a: index % 2 == 0 ? "#fff" : "#FAFAFC"
|
||
};
|
||
}),
|
||
h: common_assets._imports_1$12,
|
||
i: common_vendor.s("top:" + $data.contentTop + "px;")
|
||
};
|
||
}
|
||
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
|
||
wx.createPage(MiniProgramPage);
|
||
//# sourceMappingURL=../../../.sourcemap/mp-weixin/pagesStock/stockCenterDetails/bkydmx.js.map
|