Files
JiaZhiQianYan/unpackage/dist/dev/mp-weixin/pages/geGuCenter/detail.js

167 lines
5.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use strict";
const common_vendor = require("../../common/vendor.js");
const request_api = require("../../request/api.js");
const common_assets = require("../../common/assets.js");
const _sfc_main = {
data() {
return {
navH: common_vendor.inject("navHeight"),
contentTop: "",
allStockData: [],
filteredData: [],
currentDate: "",
// 最终要赋值的日期
topLists: [
{
title: "超大盘股",
value: ">1000亿"
},
{
title: "大盘股",
value: "500-1000亿"
},
{
title: "中盘股",
value: "100-500亿"
}
],
list2Index: 0
};
},
onLoad(e) {
this.currentDate = e.currentDate;
this.contentTop = this.navH + (20 + 70 + 25) / 750 * common_vendor.inject("windowWidth");
this.marketHeatmap();
},
methods: {
handleTypeClick(index) {
this.list2Index = index;
this.marketHeatmap();
},
getTableItem(obj) {
const marketCap = obj.market_cap ? obj.market_cap.toFixed(2) : "0.00";
const amount = obj.amount ? obj.amount.toFixed(2) : "0.00";
const changePercent = obj.change_percent ? Number(obj.change_percent) : 0;
let changePercentStr = "";
let changeType = "";
if (changePercent > 0) {
changePercentStr = `+${changePercent}%`;
changeType = "positive";
} else if (changePercent < 0) {
changePercentStr = `${changePercent}%`;
changeType = "negative";
} else {
changePercentStr = "0%";
changeType = "zero";
}
return [
[obj.stock_name, obj.stock_code],
[changePercentStr, "", changeType],
// 第三个元素存类型标记
[`${marketCap}亿元`],
[`${amount}亿元`],
[obj.industry || "暂无"]
// 处理行业为空的情况
];
},
marketHeatmap() {
let param = {
limit: 500,
date: this.currentDate
};
request_api.marketHeatmap(param).then((res) => {
this.allStockData = res.data || [];
this.filterStockByMarketCap();
}).catch((error) => {
});
},
// 根据市值区间筛选数据
filterStockByMarketCap() {
const {
list2Index,
allStockData
} = this;
let filtered = [];
switch (list2Index) {
case 0:
filtered = allStockData.filter((item) => item.market_cap > 1e3);
break;
case 1:
filtered = allStockData.filter((item) => item.market_cap >= 500 && item.market_cap <= 1e3);
break;
case 2:
filtered = allStockData.filter((item) => item.market_cap >= 100 && item.market_cap <= 500);
break;
default:
filtered = allStockData;
}
this.filteredData = filtered;
},
itemDetails(item) {
common_vendor.index.navigateTo({
url: "/pagesStock/stockCenterDetails/stockCenterDetails?code=" + item.stock_code
});
}
}
};
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_assets._imports_1,
d: common_vendor.o(($event) => _ctx.clickSearch()),
e: _ctx.keywords,
f: common_vendor.o(($event) => _ctx.keywords = $event.detail.value),
g: common_vendor.s("top:" + $data.navH + "px;"),
h: common_vendor.f($data.topLists, (item, index, i0) => {
return {
a: common_vendor.t(item.title),
b: $data.list2Index == index ? "#BB8520" : "#070707",
c: common_vendor.t(item.value),
d: $data.list2Index == index ? "#BB8520" : "#070707",
e: common_vendor.o(($event) => $options.handleTypeClick(index), index),
f: index,
g: $data.list2Index == index ? "1rpx solid #F2C369" : "none"
};
}),
i: common_vendor.f(["股票名称", "涨跌幅", "市值", "成交额", "行业"], (item, index, i0) => {
return {
a: common_vendor.t(item),
b: index
};
}),
j: common_vendor.f($data.filteredData, (obj, j, i0) => {
return {
a: common_vendor.f($options.getTableItem(obj), (item, index, i1) => {
return common_vendor.e({
a: common_vendor.t(item[0]),
b: index == 0
}, index == 0 ? {
c: common_vendor.t(item[1])
} : {}, {
d: index,
e: index == 0 ? "#222222" : index == 1 ? item[2] === "positive" ? "#EC3440" : "#01AB5D" : "#666666"
});
}),
b: common_vendor.o(($event) => $options.itemDetails(obj)),
c: j % 2 == 0 ? "#fff" : "#FAFAFC"
};
}),
k: 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/pages/geGuCenter/detail.js.map