"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"), listTop: "", conceptId: "", //概念id conceptName: "", //概念名称 weekList: ["一", "二", "三", "四", "五", "六", "日"], monthDateList: [], selectMonthIndex: 0, //选中月份下标 selectMonth: "", //选中年月 selectDateStr: "", //交易日期选中日期 quickTimeList: ["今天", "昨天", "一周前", "一月前"], stockList: [] //个股列表 }; }, onLoad(e) { this.listTop = this.navH + (46 + 22) / 750 * common_vendor.inject("windowWidth"); let currentDate = /* @__PURE__ */ new Date(); let currentYear = currentDate.getFullYear(); let currentMonth = currentDate.getMonth() + 1; let currentDay = currentDate.getDate(); this.selectMonthIndex = 20 * 12 + currentMonth - 1; this.selectMonth = currentYear + "年" + currentMonth + "月"; this.selectDateStr = currentYear + "-" + (currentMonth > 9 ? currentMonth : "0" + currentMonth) + "-" + (currentDay > 9 ? currentDay : "0" + currentDay); this.generateMonthDateListData(); if (e.id) { this.conceptId = e.id; this.getConceptHotStockData(); } }, methods: { /** * 生成日历数据 */ generateMonthDateListData() { let currentDate = /* @__PURE__ */ new Date(); let currentYear = currentDate.getFullYear(); let currentMonth = currentDate.getMonth() + 1; let currentDay = currentDate.getDate(); let monthDateList = []; for (var i = currentYear - 20; i < currentYear + 20; i++) { for (var j = 0; j < 12; j++) { let date = new Date(i, j + 1, 0); let firstDayOfMonth = new Date(i, j + 1, 0); firstDayOfMonth.setDate(1); let currentMonthDay = date.getDate(); let firstDayWeek = firstDayOfMonth.getDay() || 7; let daysOfMonth = []; for (var k = 1; k <= currentMonthDay; k++) { let newDate = new Date(i, j + 1, 0); newDate.setDate(k); let newMonth = newDate.getMonth() + 1; let newDay = newDate.getDate(); let time = newDate.getTime(); let date2 = i + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.push({ date: date2, year: i, month: newMonth, day: newDay, isToday: i == currentYear && newMonth == currentMonth && newDay == currentDay ? true : false, isCurrentMonth: true, timestamp: time }); } for (var k = 0; k < firstDayWeek - 1; k++) { let year = i; let month = j; if (j < 1) { year = i - 1; month = 12; } let lastMonthDay = new Date(year, month, 0).getDate(); let newDate = new Date(year, month - 1, lastMonthDay - k); let newMonth = newDate.getMonth() + 1; let newDay = newDate.getDate(); let time = newDate.getTime(); let date2 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.unshift({ date: date2, year, month: newMonth, day: newDay, isToday: false, isCurrentMonth: false, timestamp: time }); } let nextMonthFirstDay = new Date(i, j + 1, 1); let lastDayOfMonth = new Date(nextMonthFirstDay - 24 * 60 * 60 * 1e3); let lastDayWeek = lastDayOfMonth.getDay() || 7; for (var k = 1; k < 8 - lastDayWeek; k++) { let year = i; let month = j; if (month > 11) { month = 0; year++; } let newDate = new Date(year, month + 1, k); let newMonth = newDate.getMonth() + 1; let newDay = newDate.getDate(); let time = newDate.getTime(); let date2 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.push({ date: date2, year, month: newMonth, day: newDay, isToday: false, isCurrentMonth: false, timestamp: time }); } monthDateList.push(daysOfMonth); } } this.monthDateList = monthDateList; }, /** * 点击时间筛选 */ clickDateScreen() { this.$refs["datePopup"].open(); }, /** * 点击展开或收起 * @param {Object} index */ clickExpandOrRetract(index) { this.stockList[index].isExpand = !this.stockList[index].isExpand; }, /** * 点击取消 */ clickCancel() { this.$refs["datePopup"].close(); }, /** * 点击确认 */ clickConfirm() { this.clickCancel(); this.getConceptHotStockData(); }, /** * 点击上个月 */ clickPreMonth() { if (this.selectMonthIndex > 0) { this.selectMonthIndex--; let monthList = this.monthDateList[this.selectMonthIndex]; let year = ""; let month = ""; for (let item of monthList) { if (item.isCurrentMonth) { year = item.year; month = item.month; break; } } this.selectMonth = year + "年" + month + "月"; } }, /** * 点击下个月 */ clickNextMonth() { if (this.selectMonthIndex < this.monthDateList.length - 1) { this.selectMonthIndex++; let monthList = this.monthDateList[this.selectMonthIndex]; let year = ""; let month = ""; for (let item of monthList) { if (item.isCurrentMonth) { year = item.year; month = item.month; break; } } this.selectMonth = year + "年" + month + "月"; } }, monthChange(e) { let currentDate = /* @__PURE__ */ new Date(); let currentYear = currentDate.getFullYear(); let yearMonth = e.detail.value; let selectYear = parseInt(yearMonth.split("-")[0]); let selectMonth = parseInt(yearMonth.split("-")[1]); this.selectMonthIndex = (selectYear - (currentYear - 20)) * 12 + selectMonth - 1; this.selectMonth = selectYear + "年" + selectMonth + "月"; }, /** * 点击选择开始日期和结束日期 * @param {Object} item */ clickSelectDate(item) { if (this.selectDateStr != item.date) { this.selectDateStr = item.date; } }, /** * 点击快捷时间选择 */ clickQuickTimeItem(index) { let currentDate = /* @__PURE__ */ new Date(); let currentYear = currentDate.getFullYear(); if (index == 0) { let currentMonth = currentDate.getMonth() + 1; let currentDay = currentDate.getDate(); this.selectMonthIndex = 20 * 12 + currentMonth - 1; this.selectMonth = currentYear + "年" + currentMonth + "月"; this.selectDateStr = currentYear + "-" + (currentMonth > 9 ? currentMonth : "0" + currentMonth) + "-" + (currentDay > 9 ? currentDay : "0" + currentDay); } else if (index == 1) { let yesterday = new Date(currentDate); yesterday.setDate(yesterday.getDate() - 1); let yesterdayYear = yesterday.getFullYear(); let yesterdayMonth = yesterday.getMonth() + 1; let yesterdayDay = yesterday.getDate(); this.selectMonthIndex = (20 - (currentYear - yesterdayYear)) * 12 + yesterdayMonth - 1; this.selectMonth = yesterdayYear + "年" + yesterdayMonth + "月"; this.selectDateStr = yesterdayYear + "-" + (yesterdayMonth > 9 ? yesterdayMonth : "0" + yesterdayMonth) + "-" + (yesterdayDay > 9 ? yesterdayDay : "0" + yesterdayDay); } else if (index == 2) { let weekAgo = new Date(currentDate); weekAgo.setDate(weekAgo.getDate() - 7); let weekAgoYear = weekAgo.getFullYear(); let weekAgoMonth = weekAgo.getMonth() + 1; let weekAgoDay = weekAgo.getDate(); this.selectMonthIndex = (20 - (currentYear - weekAgoYear)) * 12 + weekAgoMonth - 1; this.selectMonth = weekAgoYear + "年" + weekAgoMonth + "月"; this.selectDateStr = weekAgoYear + "-" + (weekAgoMonth > 9 ? weekAgoMonth : "0" + weekAgoMonth) + "-" + (weekAgoDay > 9 ? weekAgoDay : "0" + weekAgoDay); } else { let monthAgo = new Date(currentDate); monthAgo.setDate(monthAgo.getDate() - 30); let monthAgoYear = monthAgo.getFullYear(); let monthAgoMonth = monthAgo.getMonth() + 1; let monthAgoDay = monthAgo.getDate(); this.selectMonthIndex = (20 - (currentYear - monthAgoYear)) * 12 + monthAgoMonth - 1; this.selectMonth = monthAgoYear + "年" + monthAgoMonth + "月"; this.selectDateStr = monthAgoYear + "-" + (monthAgoMonth > 9 ? monthAgoMonth : "0" + monthAgoMonth) + "-" + (monthAgoDay > 9 ? monthAgoDay : "0" + monthAgoDay); } }, /** * 获取概念相关个股数据 */ getConceptHotStockData() { let params = { trade_date: this.selectDateStr }; request_api.conceptDetails(this.conceptId, params).then((res) => { this.conceptName = res.concept; this.stockList = res.stocks; let codes = this.stockList.map((item) => { if (item.code != null) return item.code; return ""; }); common_vendor.index.__f__("log", "at pages/concept/hotStock/hotStock.vue:383", codes); request_api.conceptOtherDetails(this.conceptId, { days: 1, codes, isJson: 1 }).then((data) => { this.stockList = this.stockList.map((item) => { if (item.code != null) { item.change_percent = data.data[item.code].stats.change_percent; } return item; }); common_vendor.index.__f__("log", "at pages/concept/hotStock/hotStock.vue:397", "==============="); common_vendor.index.__f__("log", "at pages/concept/hotStock/hotStock.vue:398", this.stockList); }).catch((error) => { common_vendor.index.__f__("log", "at pages/concept/hotStock/hotStock.vue:400", "=-=-=-=-=-=-=-=-="); }); }).catch((error) => { }); } } }; if (!Array) { const _easycom_navBar2 = common_vendor.resolveComponent("navBar"); const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup"); (_easycom_navBar2 + _easycom_uni_popup2)(); } const _easycom_navBar = () => "../../../components/navBar/navBar.js"; const _easycom_uni_popup = () => "../../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"; if (!Math) { (_easycom_navBar + _easycom_uni_popup)(); } 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.t($data.conceptName), d: common_assets._imports_1$9, e: common_vendor.o(($event) => $options.clickDateScreen()), f: common_vendor.s("top:" + $data.navH + "px;"), g: common_vendor.f($data.stockList, (item, index, i0) => { return common_vendor.e({ a: common_vendor.t(item.name), b: common_vendor.t(item.code), c: item.change_percent }, item.change_percent ? { d: common_vendor.t(item.change_percent >= 0 ? "+" + item.change_percent : item.change_percent) } : {}, { e: item.isExpand }, item.isExpand ? { f: common_assets._imports_2$7 } : { g: common_assets._imports_3$7 }, { h: common_vendor.o(($event) => $options.clickExpandOrRetract(index), index), i: item.isExpand }, item.isExpand ? { j: common_vendor.t(item.reason) } : {}, { k: index }); }), h: common_vendor.s("top:" + $data.listTop + "px;"), i: common_vendor.o(($event) => $options.clickCancel()), j: common_vendor.o(($event) => $options.clickConfirm()), k: common_assets._imports_4$1, l: common_vendor.o(($event) => $options.clickPreMonth()), m: common_vendor.t($data.selectMonth), n: common_vendor.o((...args) => $options.monthChange && $options.monthChange(...args)), o: common_assets._imports_1$2, p: common_vendor.o(($event) => $options.clickNextMonth()), q: common_vendor.f($data.weekList, (item, index, i0) => { return { a: common_vendor.t(item), b: index }; }), r: common_vendor.f($data.monthDateList[$data.selectMonthIndex], (item, index, i0) => { return common_vendor.e({ a: item.date == $data.selectDateStr }, item.date == $data.selectDateStr ? { b: common_vendor.t(item.day) } : common_vendor.e({ c: !item.isCurrentMonth }, !item.isCurrentMonth ? { d: common_vendor.t(item.day) } : { e: common_vendor.t(item.day) }), { f: index, g: common_vendor.o(($event) => $options.clickSelectDate(item), index) }); }), s: common_vendor.f($data.quickTimeList, (item, index, i0) => { return { a: common_vendor.t(item), b: index, c: common_vendor.o(($event) => $options.clickQuickTimeItem(index), index) }; }), t: common_vendor.sr("datePopup", "21efe432-1"), v: common_vendor.p({ type: "bottom", safeArea: false }) }; } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../../.sourcemap/mp-weixin/pages/concept/hotStock/hotStock.js.map