"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 _sfc_main = { data() { return { menuTop: common_vendor.inject("menuTop"), menuH: common_vendor.inject("menuHeight"), navH: common_vendor.inject("navHeight"), windowWidth: common_vendor.inject("windowWidth"), contentTop: "", keywords: "", //搜索关键字 isRefreshing: false, todayDate: "", //今日日期 calendarDateList: [], //日历日期 selectMonth: "", //选中月份 selectMonthIndex: 0, //选中月份下标 weekList: ["一", "二", "三", "四", "五", "六", "日"], weekDateList: [], //当前周日期 monthDateList: [], //当前月日期 isExpand: false, //是否展开日期 tabList: ["事件", "数据"], selectTab: 0, stockCategoryList: [], selectTopCategory: 0, listTop: "", todayDate: "", //今日日期 selectDate: "", //选择查看的日期 progress: 75, eventList: [], //事件列表 dataList: [], //数据列表 page: 1, loadAll: false, getLocaleHourMinute: utils_util.getLocaleHourMinute, replaceAnswerLabel: utils_util.replaceAnswerLabel, accMul: utils_util.accMul, isData: false //是否请求过数据了 }; }, onLoad() { let date = /* @__PURE__ */ new Date(); this.contentTop = this.navH + (75 + 20) / 750 * common_vendor.inject("windowWidth"); let currentYear = date.getFullYear(); let currentMonth = date.getMonth() + 1; let currentDay = date.getDate(); this.todayDate = this.selectDate = currentYear + "-" + (currentMonth > 9 ? currentMonth : "0" + currentMonth) + "-" + (currentDay > 9 ? currentDay : "0" + currentDay); let week = date.getDay() || 7; let diff = week - 1; let daysOfWeek = []; for (var i = 0; i < 7; i++) { let newDate = /* @__PURE__ */ new Date(); newDate.setDate(currentDay - diff + i); let newDay = newDate.getDate(); let date2 = currentYear + "-" + (currentMonth > 9 ? currentMonth : "0" + currentMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfWeek.push({ date: date2, day: newDay, isToday: newDay == currentDay ? true : false }); } this.weekDateList = daysOfWeek; let calendarDateList = []; this.selectMonthIndex = 20 * 12 + currentMonth - 1; this.selectMonth = currentYear + "-" + (currentMonth > 9 ? currentMonth : "0" + currentMonth); for (var i = currentYear - 20; i < currentYear + 20; i++) { for (var j = 0; j < 12; j++) { let date2 = new Date(i, j + 1, 0); let firstDayOfMonth = new Date(i, j + 1, 0); firstDayOfMonth.setDate(1); let currentMonthDay = date2.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 date3 = i + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.push({ date: date3, 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 date3 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.unshift({ date: date3, 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 date3 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.push({ date: date3, year, month: newMonth, day: newDay, isToday: false, isCurrentMonth: false, timestamp: time }); } calendarDateList.push(daysOfMonth); } } this.calendarDateList = calendarDateList; this.monthDateList = calendarDateList[this.selectMonthIndex]; this.listTop = this.contentTop + (68 + 40 + 96 + 74 + 70 + 22) / 750 * common_vendor.inject("windowWidth"); Promise.all([this.getStockCategoryListData(), this.getCurrentMonthEventCountData()]).then((res) => { this.getEventListData(); }).catch((error) => { }); }, computed: { circumference() { return Math.PI * 100; } }, methods: { reloadData() { this.page = 1; this.loadAll = false; if (this.selectTab == 0) { this.getEventListData(); } else this.getDataListData(); }, pullDownRefresh() { this.isRefreshing = true; this.reloadData(); }, loadMoreData() { if (!this.loadAll) { this.page++; if (this.selectTab == 0) { this.getEventListData(); } else this.getDataListData(); } }, /** * 点击搜索 */ clickSearch() { this.reloadData(); }, /** * 点击选择月份 */ clickSelectMonth() { this.$refs["popup"].open(); }, /** * 点击今日日期 */ clickTodayDate() { if (this.selectDate != this.todayDate) { this.selectDate = this.todayDate; let date = /* @__PURE__ */ new Date(); let currentMonth = date.getMonth() + 1; this.selectMonthIndex = 20 * 12 + currentMonth - 1; this.reloadData(); } }, /** * 点击展开或收起 */ clickExpandOrRetract() { this.isExpand = !this.isExpand; if (this.isExpand) { this.listTop = this.contentTop + (68 + 40 + 96 * 6 + 74 + 70 + 74 + 22) / 750 * this.windowWidth; } else this.listTop = this.contentTop + (68 + 40 + 96 + 74 + 70 + 74 + 22) / 750 * this.windowWidth; }, /** * 点击上个月 */ clickPreMonth() { if (this.selectMonthIndex > 0) { this.selectMonthIndex--; let monthList = this.calendarDateList[this.selectMonthIndex]; let month = ""; for (let item of monthList) { if (item.isCurrentMonth) { month = item.month; break; } } this.selectMonth = this.calendarDateList[this.selectMonthIndex][0].year + "-" + (month > 9 ? month : "0" + month); } }, /** * 点击下个月 */ clickNextMonth() { if (this.selectMonthIndex < this.calendarDateList.length - 1) { this.selectMonthIndex++; let monthList = this.calendarDateList[this.selectMonthIndex]; let month = ""; for (let item of monthList) { if (item.isCurrentMonth) { month = item.month; break; } } this.selectMonth = this.calendarDateList[this.selectMonthIndex][0].year + "-" + (month > 9 ? month : "0" + month); } }, /** * 选中日期 * @param {Object} item */ clickSelectDate(item) { if (this.selectDate != item.date) { this.selectDate = item.date; this.reloadData(); } }, /** * 点击切换事件或者数据 */ clickTabItem(index) { if (this.selectTab != index) { this.selectTab = index; this.reloadData(); } }, /** * 选择一级分类 */ clickTopCategoryItem(index) { if (this.selectTopCategory != index) { this.selectTopCategory = index; this.reloadData(); } }, /** * 点击查看事件详情 */ clickEventItem(id) { common_vendor.index.navigateTo({ url: "/pages/invest/investDetails/investDetails?id=" + id }); }, /** * 获取股票分类 */ getStockCategoryListData() { return new Promise((resolve, reject) => { request_api.stockCategoryList().then((res) => { if (res.code == 200) { res.data.unshift({ primary_sector: "全部", sub_sectors: [] }); this.stockCategoryList = res.data; resolve(1); } else { common_vendor.index.showToast({ title: res.message, icon: "none" }); reject(1); } }).catch((error) => { reject(1); }); }); }, /** * 获取事件列表数据 */ getEventListData() { let param = { start: this.selectDate, q: this.keywords, page: this.page }; if (this.selectTopCategory > 0) { param.category = this.stockCategoryList[this.selectTopCategory].primary_sector; } request_api.calendarEventList(param).then((res) => { this.isData = true; this.isRefreshing = false; if (res.code == 200) { if (res.data.page == 1) { this.eventList = res.data.events; } else this.eventList = this.eventList.concat(res.data.events); if (res.data.page == res.data.total_pages) { this.loadAll = true; } } else common_vendor.index.showToast({ title: res.message, icon: "none" }); }).catch((error) => { this.isRefreshing = false; this.isData = true; }); }, /** * 获取事件列表数据 */ getDataListData() { let param = { start: this.selectDate, q: this.keywords, page: this.page }; if (this.selectTopCategory > 0) { param.category = this.stockCategoryList[this.selectTopCategory].primary_sector; } request_api.calendarDataList(param).then((res) => { this.isRefreshing = false; if (res.code == 200) { this.dataList = res.data.data_list; } else common_vendor.index.showToast({ title: res.message, icon: "none" }); }).catch((error) => { this.isRefreshing = false; }); }, /** * 获取当前月份每一天的事件数量 */ getCurrentMonthEventCountData() { return new Promise((resolve, reject) => { request_api.calendarEventCount().then((res) => { for (let item of res) { let date = item.start; for (let s of this.weekDateList) { if (s.date == date) { s.eventCount = item.title; s.className = item.className; } } for (let s of this.monthDateList) { if (s.date == date) { s.eventCount = item.title; s.className = item.className; } } } resolve(1); }).catch((error) => { reject(1); }); }); } } }; if (!Array) { const _easycom_navBar2 = common_vendor.resolveComponent("navBar"); const _easycom_ua_markdown2 = common_vendor.resolveComponent("ua-markdown"); const _easycom_zui_progress_circle2 = common_vendor.resolveComponent("zui-progress-circle"); const _easycom_uni_popup2 = common_vendor.resolveComponent("uni-popup"); (_easycom_navBar2 + _easycom_ua_markdown2 + _easycom_zui_progress_circle2 + _easycom_uni_popup2)(); } const _easycom_navBar = () => "../../components/navBar/navBar.js"; const _easycom_ua_markdown = () => "../../components/ua-markdown/ua-markdown.js"; const _easycom_zui_progress_circle = () => "../../uni_modules/zui-progress-circle/components/zui-progress-circle/zui-progress-circle.js"; const _easycom_uni_popup = () => "../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"; if (!Math) { (_easycom_navBar + _easycom_ua_markdown + _easycom_zui_progress_circle + _easycom_uni_popup)(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_assets._imports_0, b: common_vendor.p({ leftText: "投资日历", hideNavBg: true, hideBack: true }), c: common_assets._imports_1, d: common_vendor.o(($event) => $options.clickSearch()), e: $data.keywords, f: common_vendor.o(($event) => $data.keywords = $event.detail.value), g: common_vendor.s("top:" + $data.navH + "px;"), h: common_vendor.t($data.selectDate), i: common_vendor.o(($event) => $options.clickSelectMonth()), j: common_vendor.o(($event) => $options.clickTodayDate()), k: common_vendor.f($data.weekList, (item, index, i0) => { return { a: common_vendor.t(item), b: index }; }), l: $data.isExpand }, $data.isExpand ? { m: common_vendor.f($data.monthDateList, (item, index, i0) => { return common_vendor.e({ a: item.className }, item.className ? common_vendor.e({ b: item.className == "bg-gradient-danger" }, item.className == "bg-gradient-danger" ? { c: common_vendor.t(item.day), d: common_vendor.t(item.eventCount), e: common_vendor.n("item flexColumnCenter danger " + ($data.selectDate == item.date ? "select" : "")), f: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}, { g: item.className == "bg-gradient-warning" }, item.className == "bg-gradient-warning" ? { h: common_vendor.t(item.day), i: common_vendor.t(item.eventCount), j: common_vendor.n("item flexColumnCenter warning " + ($data.selectDate == item.date ? "select" : "")), k: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}, { l: item.className == "bg-gradient-info" }, item.className == "bg-gradient-info" ? { m: common_vendor.t(item.day), n: common_vendor.t(item.eventCount), o: common_vendor.n("item flexColumnCenter info " + ($data.selectDate == item.date ? "select" : "")), p: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}, { q: item.className == "bg-gradient-success" }, item.className == "bg-gradient-success" ? { r: common_vendor.t(item.day), s: common_vendor.t(item.eventCount), t: common_vendor.n("item flexColumnCenter success " + ($data.selectDate == item.date ? "select" : "")), v: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}) : { w: common_vendor.t(item.day), x: common_vendor.n("date " + (item.isCurrentMonth ? "" : " notCurrentMonth")) }, { y: index }); }) } : { n: common_vendor.f($data.weekDateList, (item, index, i0) => { return common_vendor.e({ a: item.className }, item.className ? common_vendor.e({ b: item.className == "bg-gradient-danger" }, item.className == "bg-gradient-danger" ? { c: common_vendor.t(item.day), d: common_vendor.t(item.eventCount), e: common_vendor.n("item flex1 flexColumnCenter danger " + ($data.selectDate == item.date ? "select" : "")), f: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}, { g: item.className == "bg-gradient-warning" }, item.className == "bg-gradient-warning" ? { h: common_vendor.t(item.day), i: common_vendor.t(item.eventCount), j: common_vendor.n("item flex1 flexColumnCenter warning " + ($data.selectDate == item.date ? "select" : "")), k: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}, { l: item.className == "bg-gradient-info" }, item.className == "bg-gradient-info" ? { m: common_vendor.t(item.day), n: common_vendor.t(item.eventCount), o: common_vendor.n("item flex1 flexColumnCenter info " + ($data.selectDate == item.date ? "select" : "")), p: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}, { q: item.className == "bg-gradient-success" }, item.className == "bg-gradient-success" ? { r: common_vendor.t(item.day), s: common_vendor.t(item.eventCount), t: common_vendor.n("item flex1 flexColumnCenter success " + ($data.selectDate == item.date ? "select" : "")), v: common_vendor.o(($event) => $options.clickSelectDate(item), index) } : {}) : { w: common_vendor.t(item.day), x: common_vendor.t(item.className ? item.eventCount : ""), y: common_vendor.o(($event) => $options.clickSelectDate(item), index) }, { z: index }); }) }, { o: common_vendor.t($data.isExpand ? "收起" : "展开"), p: $data.isExpand }, $data.isExpand ? { q: common_assets._imports_2$2 } : { r: common_assets._imports_3$2 }, { s: common_vendor.o(($event) => $options.clickExpandOrRetract()), t: common_vendor.f($data.tabList, (item, index, i0) => { return { a: common_vendor.t(item), b: common_vendor.n("item " + ($data.selectTab == index ? "select" : "")), c: index, d: common_vendor.o(($event) => $options.clickTabItem(index), index) }; }), v: $data.selectTab == 0 }, $data.selectTab == 0 ? { w: common_vendor.f($data.eventList, (item, index, i0) => { return common_vendor.e({ a: common_vendor.t($data.getLocaleHourMinute(item.start_time)), b: common_vendor.f(5, (sitem, sindex, i1) => { return { a: sindex < item.category.star_rating ? "/static/icon/invest/star_s.png" : "/static/icon/invest/star.png" }; }), c: index, d: common_vendor.t(item.category.event_type), e: common_vendor.t(item.title), f: "2cf1ca64-1-" + i0, g: common_vendor.p({ source: $data.replaceAnswerLabel(item.description) }), h: item.related_concepts }, item.related_concepts ? { i: common_vendor.f(item.related_concepts, (citem, cindex, i1) => { return { a: common_vendor.t(citem.name), b: common_vendor.t($data.accMul(citem.score, 100)), c: "2cf1ca64-2-" + i0 + "-" + i1, d: common_vendor.p({ position: citem.score, range: [270, 630], size: 26, ["ring-width"]: 2, texture: ["#F3C368", "#E3E3E3"] }), e: cindex }; }) } : {}, { j: index, k: common_vendor.o(($event) => $options.clickEventItem(item.id), index) }); }) } : {}, { x: $data.selectTab == 1 }, $data.selectTab == 1 ? { y: common_vendor.f($data.dataList, (item, index, i0) => { return { a: common_vendor.t($data.getLocaleHourMinute(item.created_at)), b: common_vendor.f(5, (sitem, sindex, i1) => { return { a: sindex < item.star ? "/static/icon/invest/star_s.png" : "/static/icon/invest/star.png" }; }), c: index, d: common_vendor.t(item.title), e: common_vendor.t(item.former), f: common_vendor.t(item.forecast ? item.forecast : "--"), g: common_vendor.t(item.fact ? item.fact : "--"), h: index }; }) } : {}, { z: $data.isData && ($data.selectTab == 0 && $data.eventList.length == 0 || $data.selectTab == 1 && $data.dataList.length == 0) }, $data.isData && ($data.selectTab == 0 && $data.eventList.length == 0 || $data.selectTab == 1 && $data.dataList.length == 0) ? { A: common_assets._imports_4 } : {}, { B: common_vendor.s("top:" + $data.contentTop + "px;"), C: $data.isRefreshing, D: common_vendor.o(($event) => $options.pullDownRefresh()), E: common_vendor.o(($event) => $options.loadMoreData()), F: common_assets._imports_5, G: common_vendor.o(($event) => $options.clickPreMonth()), H: common_vendor.t($data.selectMonth), I: common_assets._imports_6, J: common_vendor.o(($event) => $options.clickNextMonth()), K: common_vendor.f($data.weekList, (item, index, i0) => { return { a: common_vendor.t(item), b: index }; }), L: common_vendor.f($data.calendarDateList[$data.selectMonthIndex], (item, index, i0) => { return common_vendor.e({ a: item.isToday || item.date == $data.selectDate }, item.isToday || item.date == $data.selectDate ? { 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) }); }), M: common_vendor.s("margin-top:" + $data.navH + "px;"), N: common_vendor.sr("popup", "2cf1ca64-3"), O: common_vendor.p({ type: "top" }) }); } const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render]]); wx.createPage(MiniProgramPage); //# sourceMappingURL=../../../.sourcemap/mp-weixin/pages/invest/invest.js.map