"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: "", todayDate: "", //今日日期 weekList: ["一", "二", "三", "四", "五", "六", "日"], weekDateList: [], //当前周日期 monthDateList: [], //当前月日期 isExpand: false, //是否展开日期 tabList: ["事件", "数据"], selectTab: 0, stockCategoryList: [], selectTopCategory: 0, listTop: "", todayDate: "", //今日日期 selectDate: "", //选择查看的日期 progress: 75, eventList: [], //事件列表 dataList: [], //数据列表 getLocaleHourMinute: utils_util.getLocaleHourMinute }; }, onLoad() { let date = /* @__PURE__ */ new Date(); this.contentTop = this.navH + (75 + 20) / 750 * common_vendor.inject("windowWidth"); let year = date.getFullYear(); let month = date.getMonth() + 1; let day = date.getDate(); this.todayDate = this.selectDate = date.getFullYear() + "-" + (month > 9 ? month : "0" + month) + "-" + (day > 9 ? day : "0" + day); 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(day - diff + i); let newDay = newDate.getDate(); let date2 = year + "-" + (month > 9 ? month : "0" + month) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfWeek.push({ date: date2, day: newDay, isToday: newDay == day ? true : false }); } this.weekDateList = daysOfWeek; let firstDayOfMonth = /* @__PURE__ */ new Date(); firstDayOfMonth.setDate(1); let currentMonthDay = new Date(year, month, 0).getDate(); let firstDayWeek = firstDayOfMonth.getDay() || 7; let daysOfMonth = []; for (var i = 1; i <= currentMonthDay; i++) { let newDate = /* @__PURE__ */ new Date(); newDate.setDate(i); let newDay = newDate.getDate(); let date2 = year + "-" + (month > 9 ? month : "0" + month) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.push({ date: date2, day: newDay, isToday: newDay == day ? true : false, isCurrentMonth: true }); } for (var i = 0; i < firstDayWeek - 1; i++) { let lastMonthDay = new Date(year, month - 1, 0).getDate(); let newDate = new Date(year, month - 2, lastMonthDay - i); let newMonth = newDate.getMonth() + 1; let newDay = newDate.getDate(); let date2 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.unshift({ date: date2, day: newDay, isToday: false, isCurrentMonth: false }); } let nextMonthFirstDay = new Date(year, month, 1); let lastDayOfMonth = new Date(nextMonthFirstDay - 24 * 60 * 60 * 1e3); let lastDayWeek = lastDayOfMonth.getDay() || 7; for (var i = 1; i < 8 - lastDayWeek; i++) { if (month > 11) { month = -1; year++; } let newDate = new Date(year, month + 1, i); let newMonth = newDate.getMonth() + 1; let newDay = newDate.getDate(); let date2 = year + "-" + (newMonth > 9 ? newMonth : "0" + newMonth) + "-" + (newDay > 9 ? newDay : "0" + newDay); daysOfMonth.push({ date: date2, day: newDay, isToday: false, isCurrentMonth: false }); } this.monthDateList = daysOfMonth; this.listTop = this.contentTop + (68 + 40 + 96 + 74 + 70 + 74 + 22) / 750 * common_vendor.inject("windowWidth"); this.getStockCategoryListData(); this.getEventListData(); this.getCurrentMonthEventCountData(); }, computed: { circumference() { return Math.PI * 100; } }, methods: { /** * 点击今日日期 */ clickTodayDate() { if (this.selectDate != this.todayDate) { this.selectDate = this.todayDate; if (this.selectTab == 0) { this.getEventListData(); } else this.getDataListData(); } }, /** * 点击展开或收起 */ 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; }, /** * 选中日期 * @param {Object} item */ clickSelectDate(item) { if (this.selectDate != item.date) { this.selectDate = item.date; if (this.selectTab == 0) { this.getEventListData(); } else this.getDataListData(); } }, /** * 点击切换事件或者数据 */ clickTabItem(index) { if (this.selectTab != index) { this.selectTab = index; if (this.selectTab == 0) { this.getEventListData(); } else this.getDataListData(); } }, /** * 选择一级分类 */ clickTopCategoryItem(index) { if (this.selectTopCategory != index) { this.selectTopCategory = index; if (this.selectTab == 0) { this.getEventListData(); } else this.getDataListData(); } }, /** * 点击查看事件详情 */ clickEventItem(id) { common_vendor.index.navigateTo({ url: "/pages/invest/investDetails/investDetails?id=" + id }); }, /** * 获取股票分类 */ getStockCategoryListData() { request_api.stockCategoryList().then((res) => { if (res.code == 200) { res.data.unshift({ primary_sector: "全部", sub_sectors: [] }); this.stockCategoryList = res.data; } else common_vendor.index.showToast({ title: res.message, icon: "none" }); }).catch((error) => { }); }, /** * 获取事件列表数据 */ getEventListData() { let param = { start: this.selectDate }; if (this.selectTopCategory > 0) { param.category = this.stockCategoryList[this.selectTopCategory].primary_sector; } request_api.calendarEventList(param).then((res) => { if (res.code == 200) { this.eventList = res.data.events; } else common_vendor.index.showToast({ title: res.message, icon: "none" }); }).catch((error) => { }); }, /** * 获取事件列表数据 */ getDataListData() { let param = { start: this.selectDate }; request_api.calendarDataList(param).then((res) => { if (res.code == 200) { this.dataList = res.data.data_list; } else common_vendor.index.showToast({ title: res.message, icon: "none" }); }).catch((error) => { }); }, /** * 获取当前月份每一天的事件数量 */ getCurrentMonthEventCountData() { 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; } } } }).catch((error) => { }); } } }; if (!Array) { const _easycom_zui_progress_circle2 = common_vendor.resolveComponent("zui-progress-circle"); _easycom_zui_progress_circle2(); } const _easycom_zui_progress_circle = () => "../../uni_modules/zui-progress-circle/components/zui-progress-circle/zui-progress-circle.js"; if (!Math) { _easycom_zui_progress_circle(); } function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_assets._imports_0, b: common_vendor.s("top:" + $data.menuTop + "px;line-height:" + $data.menuH + "px;"), c: common_assets._imports_1, d: common_vendor.s("top:" + $data.navH + "px;"), e: common_vendor.t($data.selectDate), f: common_assets._imports_2$3, g: common_vendor.o(($event) => $options.clickExpandOrRetract()), h: common_vendor.o(($event) => $options.clickTodayDate()), i: common_vendor.f($data.weekList, (item, index, i0) => { return { a: common_vendor.t(item), b: index }; }), j: $data.isExpand }, $data.isExpand ? { k: common_vendor.f($data.monthDateList, (item, index, i0) => { return common_vendor.e($data.selectDate != $data.todayDate ? common_vendor.e({ a: $data.selectDate == item.date }, $data.selectDate == item.date ? { b: common_vendor.t(item.day) } : { c: common_vendor.t(item.day), d: common_vendor.n("date " + (item.isCurrentMonth ? "" : " notCurrentMonth")) }) : { e: common_vendor.t(item.day), f: common_vendor.n("date " + (item.isToday ? "today" : item.isCurrentMonth ? "" : " notCurrentMonth")) }, { g: item.className }, item.className ? common_vendor.e({ h: item.className == "bg-gradient-danger" }, item.className == "bg-gradient-danger" ? { i: common_vendor.t(item.eventCount) } : {}, { j: item.className == "bg-gradient-warning" }, item.className == "bg-gradient-warning" ? { k: common_vendor.t(item.eventCount) } : {}, { l: item.className == "bg-gradient-info" }, item.className == "bg-gradient-info" ? { m: common_vendor.t(item.eventCount) } : {}, { n: item.className == "bg-gradient-success" }, item.className == "bg-gradient-success" ? { o: common_vendor.t(item.eventCount) } : {}) : {}, { p: index, q: common_vendor.o(($event) => $options.clickSelectDate(item), index) }); }), l: $data.selectDate != $data.todayDate } : { m: common_vendor.f($data.weekDateList, (item, index, i0) => { return common_vendor.e($data.selectDate != $data.todayDate ? common_vendor.e({ a: $data.selectDate == item.date }, $data.selectDate == item.date ? { b: common_vendor.t(item.day) } : { c: common_vendor.t(item.day), d: common_vendor.n("date " + (item.isCurrentMonth ? "" : " notCurrentMonth")) }) : { e: common_vendor.t(item.day), f: common_vendor.n("date " + (item.isToday ? "today" : item.isCurrentMonth ? "" : " notCurrentMonth")) }, { g: item.className }, item.className ? common_vendor.e({ h: item.className == "bg-gradient-danger" }, item.className == "bg-gradient-danger" ? { i: common_vendor.t(item.eventCount) } : {}, { j: item.className == "bg-gradient-warning" }, item.className == "bg-gradient-warning" ? { k: common_vendor.t(item.eventCount) } : {}, { l: item.className == "bg-gradient-info" }, item.className == "bg-gradient-info" ? { m: common_vendor.t(item.eventCount) } : {}, { n: item.className == "bg-gradient-success" }, item.className == "bg-gradient-success" ? { o: common_vendor.t(item.eventCount) } : {}) : {}, { p: common_vendor.o(($event) => $options.clickSelectDate(item), index), q: index }); }), n: $data.selectDate != $data.todayDate }, { o: common_vendor.t($data.isExpand ? "收起" : "展开"), p: common_assets._imports_3$2, q: common_vendor.o(($event) => $options.clickExpandOrRetract()), r: 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) }; }), s: common_vendor.f($data.stockCategoryList, (item, index, i0) => { return common_vendor.e({ a: common_vendor.t(item.primary_sector), b: $data.selectTopCategory == index }, $data.selectTopCategory == index ? {} : {}, { c: common_vendor.n("item relative " + ($data.selectTopCategory == index ? "select" : "")), d: index, e: common_vendor.o(($event) => $options.clickTopCategoryItem(index), index) }); }), t: $data.selectTab == 0 }, $data.selectTab == 0 ? { v: 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.star ? "/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: common_vendor.t(item.description), g: item.concepts }, item.concepts ? { h: common_vendor.f(JSON.parse(item.concepts), (citem, cindex, i1) => { return { a: common_vendor.t(citem[0]), b: common_vendor.t(citem[2] * 100), c: "2cf1ca64-0-" + i0 + "-" + i1, d: common_vendor.p({ position: citem[2], range: [270, 630], size: 26, ["ring-width"]: 2, texture: ["#F97316", "#E3E3E3"] }), e: cindex }; }) } : {}, { i: index, j: common_vendor.o(($event) => $options.clickEventItem(item.id), index) }); }) } : {}, { w: $data.selectTab == 1 }, $data.selectTab == 1 ? { x: common_vendor.f($data.dataList, (item, index, i0) => { return { a: common_vendor.t($data.getLocaleHourMinute(item.created_at)), b: common_vendor.f(5, (item2, index2, i1) => { return { a: index2 }; }), c: common_vendor.f(5, (item2, index2, i1) => { return { a: index2 }; }), d: common_vendor.t(item.title), e: index }; }), y: common_assets._imports_4$1, z: common_assets._imports_5 } : {}, { A: 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/invest/invest.js.map