Files
JiaZhiQianYan/unpackage/dist/dev/mp-weixin/pages/index/eventDetails/eventDetails.js
2026-01-26 15:34:26 +08:00

647 lines
20 KiB
JavaScript

"use strict";
const common_vendor = require("../../../common/vendor.js");
const request_api = require("../../../request/api.js");
const utils_util = require("../../../utils/util.js");
const common_assets = require("../../../common/assets.js");
const echarts = require("../../../uni_modules/lime-echart/static/echarts.min.js");
const _sfc_main = {
data() {
return {
navH: common_vendor.inject("navHeight"),
windowWidth: common_vendor.inject("windowWidth"),
eventId: "",
//事件id
memberInfo: null,
//会员信息
eventDetails: null,
//事件详情
categoryList: ["相关标的", "相关概念", "历史事件"],
targetList: [],
//相关标的
conceptList: [],
//相关概念
page: 1,
loadAll: false,
//是否加载完毕
historyEventList: [],
//历史事件
historyEventRelatedStockList: [],
//历史事件相关股票
selectCategory: 0,
headingList: ["名称代码", "分时图", "开盘价", "最新价", "涨跌幅"],
getLocaleHourMinute: utils_util.getLocaleHourMinute,
getLocaleTime: utils_util.getLocaleTime,
getRateUpOrDown: utils_util.getRateUpOrDown,
getRateStr: utils_util.getRateStr,
getChgRateStr: utils_util.getChgRateStr,
scoreTop: "",
expectScore: 0,
//预期得分
commentList: [],
//评价列表
eventComment: "",
//事件评论内容
replyId: "",
//回复评论id
replyPid: "",
//回复评论父级id
isFocus: false,
//是否获取焦点
replyComment: "",
//评论回复内容
option: {
tooltip: {
show: false,
trigger: "axis",
axisPointer: {
type: "shadow"
},
confine: true
},
grid: {
left: "10%",
right: "6%",
top: "5%",
bottom: "10%"
},
xAxis: {
type: "category",
scale: true,
data: [],
// axisTick:{ show:false },
axisLine: { show: false },
axisLabel: { show: false }
},
yAxis: [
{
type: "value",
axisTick: { show: false },
scale: true,
axisLabel: { show: false },
splitLine: { show: false }
}
],
series: {
name: "分时图",
type: "line",
label: {
show: true,
position: "top",
fontSize: 12
},
symbol: "none",
silent: true,
data: [],
itemStyle: {
color: ""
},
markLine: {
symbol: ["none", "none"],
lineStyle: {
color: "#AAAAAA",
type: "dashed"
},
data: []
}
}
}
};
},
onLoad(e) {
if (e.id) {
this.eventId = e.id;
this.getEventRelatedStockData();
this.getEventCommentListData();
}
},
methods: {
/**
* 复制标题
*/
copyEventTitle() {
common_vendor.index.setClipboardData({
data: this.eventDetails.event_title,
success() {
common_vendor.index.showToast({
title: "复制成功"
});
}
});
},
async init() {
let that = this;
setTimeout(function() {
that.targetList.map(function(item, index) {
const chartDom = that.$refs["chartRef" + index][0];
chartDom.init(echarts).then((res) => {
let option = { ...that.option };
let categoryData = [];
let valueData = [];
for (let item1 of item.minute_chart_data) {
categoryData.push(item1.time);
valueData.push(item1.close);
}
option.series.data = valueData;
option.xAxis.data = categoryData;
let time = that.eventDetails.event_start_time.split("T")[1];
time = time.substring(0, 5);
let firstOpen = item.minute_chart_data[0].open;
option.series.markLine.data = [
{
xAxis: time,
lineStyle: {
type: "solid",
width: 1,
color: "#ffd700"
}
},
{
yAxis: firstOpen
}
];
let lastClose = item.minute_chart_data.slice(-1)[0].close;
if (lastClose >= firstOpen) {
option.series.itemStyle.color = "#EF5350";
} else
option.series.itemStyle.color = "#26A69A";
res.setOption(option);
});
});
}, 300);
},
loadMoreData() {
if (this.selectCategory == 1) {
if (!this.loadAll) {
this.page++;
this.getEventRelatedConceptData();
}
}
},
/**
* 点击切换分类
*/
clickCategoryItem(index) {
if (this.selectCategory != index) {
this.selectCategory = index;
if (index == 0) {
this.getEventRelatedStockData();
} else if (index == 1) {
this.page = 1;
this.loadAll = false;
this.getEventRelatedConceptData();
} else if (index == 2) {
this.getEventHistoryEventData();
}
}
},
/**
* 点击查看股票详情
*/
clickStockItem(code) {
common_vendor.index.navigateTo({
url: "/pages/index/stockDetails/stockDetails?type=1&code=" + code + "&id=" + this.eventId
});
},
/**
* 点击查看相关概念
*/
clickConceptItem(name) {
let md5 = common_vendor.CryptoJS.MD5(name).toString();
common_vendor.index.navigateTo({
url: "/pages/index/conceptDetails/conceptDetails?name=" + md5
});
},
/**
* 非vip点击
*/
clickNotVip() {
this.$refs["vipPopup"].open();
},
/**
* 点击稍后再说
*/
clickLater() {
this.$refs["vipPopup"].close();
},
/**
* 点击立即升级
*/
clickUpgradeAtOnce() {
this.clickLater();
},
/**
* 点击查看更多个股
*/
clickStockMore(item) {
common_vendor.index.navigateTo({
url: "/pages/concept/hotStock/hotStock?id=" + item.concept_id
});
},
/**
* 点击查看历史时间轴
*/
clickHistoricalTimeline(item) {
common_vendor.index.navigateTo({
url: "/pages/concept/historicalTimeline/historicalTimeline?id=" + item.concept_id
});
},
/**
* 点击查看历史事件的相关股票
*/
clickLookHistoricalEventRelatedStock(item) {
this.historyEventRelatedStockList = item.related_stocks;
this.$refs["stockPopup"].open();
},
/**
* 点击关闭相关股票弹窗
*/
closeRelatedStockPopup() {
this.$refs["stockPopup"].close();
},
/**
* 点击查看超预期得分
*/
clickExpectScore(e) {
this.scoreTop = e.currentTarget.offsetTop + this.navH + (70 + 10) / 750 * this.windowWidth;
this.$refs["expectScorePopup"].open();
},
/**
* 点击发送事件评论
*/
sendEventComment() {
if (!this.eventComment) {
common_vendor.index.showToast({
title: "请输入评论内容",
icon: "none"
});
return;
}
let eventId = this.eventId;
let param = { content: this.eventComment };
request_api.commentEvent(eventId, param).then((res) => {
common_vendor.index.showToast({
title: res.message,
icon: "none"
});
let that = this;
setTimeout(function() {
that.getEventCommentListData();
}, 1e3);
}).catch((error) => {
});
},
/**
* 点击评论
*/
clickComment() {
this.$refs["popup"].open();
},
/**
* 点击关闭评论弹窗
*/
closeCommentPopup() {
this.$refs["popup"].close();
},
/**
* 点击关注
*/
clickFollow() {
let eventId = this.eventId;
request_api.followEvent(eventId).then((res) => {
common_vendor.index.showToast({
title: res.message,
icon: "none"
});
common_vendor.index.$emit("editSuccess");
this.getEventRelatedStockData();
}).catch((error) => {
});
},
/**
* 点击回复评论
*/
clickReplyComment(id, pid) {
this.replyId = id;
if (pid) {
this.replyPid = pid;
}
this.isFocus = true;
},
sendReplyComment() {
if (!this.replyComment) {
common_vendor.index.showToast({
title: "请输入评论内容",
icon: "none"
});
return;
}
let param = { content: this.replyComment };
if (this.replyPid) {
param.parent_id = this.replyPid;
}
request_api.replyComment(this.replyId, param).then((res) => {
}).catch((error) => {
});
},
/**
* 点赞评论
*/
clickLikeComment(id, index, cindex) {
request_api.likeEventComment(id).then((res) => {
common_vendor.index.showToast({
title: res.message,
icon: "none"
});
if (cindex == -1) {
this.commentList[index].likes_count = res.likes_count;
}
}).catch((error) => {
});
},
/**
* 获取事件相关标的数据
*/
getEventRelatedStockData() {
let eventId = this.eventId;
request_api.eventRelatedStock(eventId).then((res) => {
if (res.code == 200) {
this.eventDetails = res.data;
this.targetList = res.data.related_stocks;
this.init();
} else
common_vendor.index.showToast({
title: res.message,
icon: "none",
duration: 3e3
});
}).catch((error) => {
});
},
/**
* 获取事件相关概念数据
*/
getEventRelatedConceptData() {
let eventDetails = this.eventDetails;
let param = { query: eventDetails.event_title, size: 10, page: this.page, sort_by: "_score", isJson: 1 };
request_api.eventRelatedConcept(param).then((res) => {
if (res.page == 1) {
this.conceptList = res.results;
} else {
this.conceptList = this.conceptList.concat(res.results);
}
if (res.page == res.total_pages) {
this.loadAll = true;
}
}).catch((error) => {
});
},
/**
* 获取事件历史事件数据
*/
getEventHistoryEventData() {
let eventId = this.eventId;
request_api.eventHistoryEvent(eventId).then((res) => {
if (res.code == 200) {
this.expectScore = res.data.invest_score;
this.historyEventList = res.data.historical_events;
} else
common_vendor.index.showToast({
title: res.message,
icon: "none"
});
}).catch((error) => {
});
},
/**
* 获取事件评论列表
*/
getEventCommentListData() {
let eventId = this.eventId;
request_api.eventCommentList(eventId).then((res) => {
this.commentList = res.data.posts;
}).catch((error) => {
});
}
}
};
if (!Array) {
const _easycom_navBar2 = common_vendor.resolveComponent("navBar");
const _easycom_l_echart2 = common_vendor.resolveComponent("l-echart");
const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup");
(_easycom_navBar2 + _easycom_l_echart2 + _easycom_uni_popup2)();
}
const _easycom_navBar = () => "../../../components/navBar/navBar.js";
const _easycom_l_echart = () => "../../../uni_modules/lime-echart/components/l-echart/l-echart.js";
const _easycom_uni_popup = () => "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js";
if (!Math) {
(_easycom_navBar + _easycom_l_echart + _easycom_uni_popup)();
}
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return common_vendor.e({
a: common_vendor.p({
leftText: "事件详情",
hideNavBg: true
}),
b: common_assets._imports_0,
c: $data.eventDetails
}, $data.eventDetails ? common_vendor.e({
d: common_vendor.t($data.eventDetails.event_type),
e: common_vendor.t($data.eventDetails.event_title),
f: common_vendor.o(($event) => $options.copyEventTitle()),
g: common_vendor.t($data.eventDetails.event_created_at.substr(0, 16)),
h: common_vendor.t($data.eventDetails.event_desc),
i: common_vendor.f($data.categoryList, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item),
b: $data.selectCategory == index
}, $data.selectCategory == index ? {} : {}, {
c: common_vendor.n("item relative " + ($data.selectCategory == index ? "select" : "")),
d: index,
e: common_vendor.o(($event) => $options.clickCategoryItem(index), index)
});
}),
j: $data.selectCategory == 0
}, $data.selectCategory == 0 ? {
k: common_vendor.f($data.headingList, (item, index, i0) => {
return {
a: common_vendor.t(item),
b: index
};
})
} : {}, {
l: $data.selectCategory == 0
}, $data.selectCategory == 0 ? {
m: common_vendor.f($data.targetList, (item, index, i0) => {
return {
a: common_vendor.t(item.stock_name),
b: common_vendor.t(item.stock_code),
c: common_vendor.sr("chartRef" + index, "7deb901e-1-" + i0, {
"f": 1
}),
d: "chartRef" + index,
e: "7deb901e-1-" + i0,
f: common_vendor.t(item.trade_data ? item.trade_data.open_price : ""),
g: common_vendor.t(item.trade_data ? item.trade_data.latest_price : ""),
h: common_vendor.t(item.trade_data ? item.trade_data.change_pct : ""),
i: common_vendor.n("chg flex1 " + ($data.getRateUpOrDown(item.trade_data ? item.trade_data.change_pct : "") ? "down" : "up")),
j: common_vendor.t(item.relation_desc),
k: index,
l: common_vendor.o(($event) => $options.clickStockItem(item.stock_code), index)
};
})
} : {}, {
n: $data.selectCategory == 1
}, $data.selectCategory == 1 ? {
o: common_vendor.f($data.conceptList, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item.concept),
b: item.price_info
}, item.price_info ? {
c: common_vendor.t($data.getChgRateStr(item.price_info.avg_change_pct)),
d: common_vendor.n("chg " + ($data.getRateUpOrDown(item.price_info.avg_change_pct) ? "down" : "up"))
} : {}, {
e: item.price_info
}, item.price_info ? {
f: common_vendor.t(item.stock_count),
g: common_vendor.n("stockNum " + ($data.getRateUpOrDown(item.price_info.avg_change_pct) ? "down" : "up"))
} : {}, {
h: common_vendor.t(item.description)
}, $data.memberInfo && $data.memberInfo.is_member && $data.memberInfo.subscription_type == "pro" ? {
i: common_vendor.f(item.stocks.slice(0, 3), (sitem, sindex, i1) => {
return {
a: common_vendor.t(sitem.name),
b: sindex
};
}),
j: common_vendor.t(item.stock_count - 3),
k: common_vendor.o(($event) => $options.clickStockMore(item), index)
} : {
l: common_assets._imports_1$5,
m: common_vendor.t(item.stock_count),
n: common_vendor.o(($event) => $options.clickNotVip(), index)
}, {
o: common_vendor.t(item.price_info ? item.price_info.trade_date : ""),
p: common_vendor.o(($event) => $options.clickHistoricalTimeline(item), index),
q: index,
r: common_vendor.o(($event) => $options.clickConceptItem(item.concept), index)
});
}),
p: $data.memberInfo && $data.memberInfo.is_member && $data.memberInfo.subscription_type == "pro",
q: common_assets._imports_1$2
} : {}, {
r: $data.selectCategory == 2
}, $data.selectCategory == 2 ? {
s: common_assets._imports_3$3,
t: common_vendor.t($data.expectScore),
v: common_assets._imports_4$4,
w: common_vendor.o(($event) => $options.clickExpectScore($event)),
x: common_vendor.f($data.historyEventList, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item.title),
b: common_vendor.t(item.relevance * 10),
c: common_vendor.t(item.content),
d: $data.getRateUpOrDown(item.related_avg_chg)
}, $data.getRateUpOrDown(item.related_avg_chg) ? {
e: common_assets._imports_1$1
} : {
f: common_assets._imports_2$1
}, {
g: common_vendor.t($data.getRateStr(item.related_avg_chg)),
h: common_vendor.n("rateItem " + ($data.getRateUpOrDown(item.related_avg_chg) ? "down" : "up")),
i: $data.getRateUpOrDown(item.related_max_chg)
}, $data.getRateUpOrDown(item.related_max_chg) ? {
j: common_assets._imports_1$1
} : {
k: common_assets._imports_2$1
}, {
l: common_vendor.t($data.getRateStr(item.related_max_chg)),
m: common_vendor.n("rateItem " + ($data.getRateUpOrDown(item.related_max_chg) ? "down" : "up")),
n: common_vendor.o(($event) => $options.clickLookHistoricalEventRelatedStock(item), index),
o: common_vendor.t($data.getLocaleTime(item.event_date)),
p: index
});
}),
y: common_assets._imports_5$1,
z: common_assets._imports_3$3
} : {}, {
A: common_vendor.s("top:" + $data.navH + "px;"),
B: common_vendor.o(($event) => $options.loadMoreData())
}) : {}, {
C: $data.eventDetails
}, $data.eventDetails ? {
D: common_assets._imports_8$1,
E: common_vendor.t($data.eventDetails.view_count),
F: common_assets._imports_9$2,
G: common_vendor.t($data.eventDetails.follower_count),
H: common_vendor.o(($event) => $options.clickFollow())
} : {}, {
I: common_assets._imports_13$1,
J: common_vendor.o(($event) => $options.closeCommentPopup()),
K: common_vendor.f($data.commentList, (item, index, i0) => {
return {
a: item.user.avatar_url,
b: common_vendor.t(item.user.username),
c: common_vendor.t(item.content),
d: common_vendor.t($data.getLocaleHourMinute(item.created_at)),
e: common_vendor.o(($event) => $options.clickReplyComment(item.post_id), index),
f: common_vendor.t(item.likes_count),
g: common_vendor.o(($event) => $options.clickLikeComment(item.post_id, index, -1), index),
h: index
};
}),
L: common_assets._imports_11,
M: common_vendor.sr("popup", "7deb901e-2"),
N: common_vendor.p({
type: "bottom"
}),
O: common_assets._imports_12$1,
P: common_vendor.s("margin-top:" + $data.scoreTop + "px;"),
Q: common_vendor.sr("expectScorePopup", "7deb901e-3"),
R: common_vendor.p({
type: "top",
["mask-background-color"]: "transparent",
animation: false
}),
S: common_assets._imports_13$1,
T: common_vendor.o(($event) => $options.closeRelatedStockPopup()),
U: common_vendor.f($data.historyEventRelatedStockList, (item, index, i0) => {
return common_vendor.e({
a: common_vendor.t(item.stock_name + "(" + item.stock_code + ")"),
b: common_vendor.t(item.correlation * 100),
c: common_vendor.t(item.sector),
d: $data.getRateUpOrDown(item.daily_change)
}, $data.getRateUpOrDown(item.daily_change) ? {
e: common_assets._imports_1$1
} : {
f: common_assets._imports_2$1
}, {
g: common_vendor.t($data.getRateStr(item.daily_change)),
h: common_vendor.n("rateC " + ($data.getRateUpOrDown(item.daily_change) ? "down" : "up")),
i: common_vendor.t(item.relation_desc),
j: index,
k: common_vendor.o(($event) => $options.clickStockItem(item.stock_code), index)
});
}),
V: common_vendor.sr("stockPopup", "7deb901e-4"),
W: common_vendor.p({
type: "bottom"
}),
X: common_assets._imports_13,
Y: common_assets._imports_14,
Z: common_assets._imports_15,
aa: common_assets._imports_15,
ab: common_assets._imports_16,
ac: common_assets._imports_16,
ad: common_assets._imports_16,
ae: common_vendor.o(($event) => $options.clickLater()),
af: common_vendor.o(($event) => $options.clickUpgradeAtOnce()),
ag: common_vendor.sr("vipPopup", "7deb901e-5"),
ah: common_vendor.p({
type: "center"
})
});
}
const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]);
wx.createPage(MiniProgramPage);
//# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/index/eventDetails/eventDetails.js.map