"use strict";const e=require("../../common/vendor.js"),t=require("../../request/api.js"),s=require("../../utils/util.js"),i=require("../../common/assets.js"),r=require("../../uni_modules/lime-echart/static/echarts.min.js"),o={data:()=>({menuTop:e.inject("menuTop"),menuH:e.inject("menuHeight"),navH:e.inject("navHeight"),windowWidth:e.inject("windowWidth"),contentTop:"",listTop:"",screenCategoryList:[{icon:"/static/icon/home/timeScreen.png",title:"时间筛选"},{icon:"/static/icon/home/industryScreen.png",title:"行业筛选"},{icon:"/static/icon/home/eventLevel.png",title:"事件等级"},{icon:"/static/icon/home/sort.png",title:"最新排序"}],keywords:"",timeCategoryList:[],selectTimeCategory:0,stockCategoryList:[],topScrollWidth:0,secondScrollWidth:0,selectTopCategory:0,topScrollLeft:0,selectSecondCategory:0,secondScrollLeft:0,selectScreenCategory:0,quickTimeList:[{title:"最新",key:"latest"},{title:"盘中",key:"intraday"},{title:"早盘",key:"morning"},{title:"午盘",key:"afternoon"},{title:"今日全天",key:"today"},{title:"昨日",key:"yesterday"},{title:"近一周",key:"week"},{title:"近一月",key:"month"}],selectQuickTimeIndex:-1,startDateStr:"",startTimeStamp:"",endDateStr:"",endTimeStamp:"",yearList:[],monthList:[],dayList:[],startDateValue:[0,0,0],endDateValue:[0,0,0],industryCategoryList:[],industryKeywords:"",searchResultList:[],selectIndustryTopCategory:0,selectIndustrySecondCategory:0,selectIndustryThirdCategory:0,searchIndustryTopCategory:0,searchIndustrySecondCategory:0,searchIndustryThirdCategory:0,importanceList:[],sortTypeList:[],selectSortKey:"",option:{tooltip:{trigger:"axis",axisPointer:{type:"shadow"},confine:!0},grid:{left:"0%",right:"0%",top:"10%",bottom:"20%"},xAxis:[{type:"category",data:["跌停","跌停~5%","5~1%","1~0%","平盘","0~1%","1~5%","5%~涨停","涨停"],axisTick:{show:!1},axisLine:{show:!1},axisLabel:{fontSize:10,interval:"0",textStyle:{color:function(e,t){return 0==t?"#355422":8==t?"#C00000":"#515151"}}}}],yAxis:[{type:"value",show:!1,axisTick:{show:!1}}],series:[{name:"热度",type:"bar",label:{show:!0,position:"top",fontSize:12},itemStyle:{borderRadius:[5,5,0,0]},data:[]}]},eventList:[],page:1,isRefreshing:!1,loadAll:!1,getRateStr:s.getRateStr,getRateUpOrDown:s.getRateUpOrDown,getLocaleTime:s.getLocaleTime}),onLoad(){this.contentTop=this.navH+.192*this.windowWidth,this.listTop=this.contentTop+94/750*this.windowWidth,this.generateDateListData(),Promise.all([this.getEventFilterListData(),this.getIndustryCategoryListData(),this.getStockCategoryListData()]).then((e=>{this.getEventListData()})).catch((e=>{}))},onReady(){},methods:{generateDateListData(){let e=new Date,t=e.getFullYear(),s=e.getMonth(),i=e.getDate(),r=new Date(t,s+1,0).getDate();for(var o=2e3;o<2060;o++)this.yearList.push(o);for(o=0;o<720;o++)this.monthList.push(o%12+1);for(o=0;o<60*r;o++)this.dayList.push(o%r+1);let a=this;setTimeout((function(){a.startDateValue=[t-2e3,s+360,i-1+30*r],a.endDateValue=[t-2e3,s+360,i-1+30*r]}),100)},pullDownRefresh(){this.isRefreshing=!0,this.clickSearch()},loadMoreData(){this.loadAll||(this.page++,0==this.selectTimeCategory?this.getEventListData():this.getHotEventListData())},async init(){(await this.$refs.chartRef.init(r)).setOption(this.option)},clickSearch(){this.loadAll=!1,this.page=1,0==this.selectTimeCategory?this.getEventListData():this.getHotEventListData()},clickTimeCategoryItem(e){this.selectTimeCategory!=e&&(this.selectTimeCategory=e,this.clickSearch())},clickSortListItem(e){this.selectSortKey=e.key,this.$refs.screenPopup.close(),this.clickSearch()},clickScreenItem(e){this.selectScreenCategory=e,this.$refs.screenPopup.open()},clickCancel(){this.$refs.screenPopup.close()},clickCertain(){if(0==this.selectScreenCategory&&-1==this.selectQuickTimeIndex){if(!this.startDateStr)return void e.index.showToast({title:"请选择开始时间",icon:"none"});if(!this.endDateStr)return void e.index.showToast({title:"请选择结束时间",icon:"none"});if(this.endTimeStamp9?r:"0"+r)+"-"+(a>9?a:"0"+a);var c=this.startDateStr.replace(/-/g,"/")+" 00:00:00";this.startTimeStamp=new Date(c).getTime()},endDateChange(e){this.selectQuickTimeIndex=-1;let t=e.detail.value;if(t[1]!=this.endDateValue[1]){let e=t[0]+2e3,i=t[1]%12,r=new Date(e,i+1,0).getDate();this.dayList=[];for(var s=0;s<60*r;s++)this.dayList.push(s%r+1)}this.endDateValue=e.detail.value;let i=t[0]+2e3,r=t[1]%12+1,o=new Date(i,r,0).getDate(),a=t[2]%o+1;this.endDateStr=i+"-"+(r>9?r:"0"+r)+"-"+(a>9?a:"0"+a);var c=this.endDateStr.replace(/-/g,"/")+" 00:00:00";this.endTimeStamp=new Date(c).getTime()},industrySearch(e){let t=e.detail.value;if(this.industryKeywords=t,t){let e=[];for(let s of this.industryCategoryList){let i=this.industryCategoryList.indexOf(s);if(s.level1_sector.indexOf(t)>-1)s.index=i,e.push(s);else{let r=[];for(let e of s.level2_sectors){let o=s.level2_sectors.indexOf(e);if(e.level2_sector.indexOf(t)>-1)e.index=i,e.index1=o,r.push(e);else{let s=[];for(let r of e.level3_sectors){let a=e.level3_sectors.indexOf(r);r.level3_sector.indexOf(t)>-1&&(r.index=i,r.index1=o,r.index2=a,s.push(r))}s.length>0&&(s.unshift({level3_sector:"全部",index:i,index2:0}),r.push({level2_sector:e.level2_sector,level3_sectors:s,index:i,index1:o}))}}r.length>0&&(r.unshift({level2_sector:"全部",level3_sectors:[{level3_sector:"全部",level4_sectors:[]}],index:i,index1:0}),e.push({level1_sector:s.level1_sector,level2_sectors:r,index:i}))}}this.searchResultList=e}else this.searchResultList=this.industryCategoryList,this.searchIndustryTopCategory=this.searchIndustrySecondCategory=this.searchIndustryThirdCategory=0},clickSearchIndustryTopCategoryItem(e,t){this.searchIndustryTopCategory!=e&&(this.searchIndustryTopCategory=e,this.selectIndustryTopCategory=t.index,this.searchIndustrySecondCategory=this.selectIndustrySecondCategory=0)},clickSearchIndustrySecondCategoryItem(e,t){this.searchIndustrySecondCategory!=e&&(this.searchIndustrySecondCategory=e,this.selectIndustrySecondCategory=t.index1,this.searchIndustryThirdCategory=this.selectIndustryThirdCategory=0)},clickSearchIndustryThirdCategoryItem(e,t){this.searchIndustryThirdCategory!=e&&(this.searchIndustryThirdCategory=e,this.selectIndustryThirdCategory=t.index2)},clickIndustryTopCategoryItem(e){this.selectIndustryTopCategory!=e&&(this.selectIndustryTopCategory=e,this.selectIndustrySecondCategory=0)},clickIndustrySecondCategoryItem(e){this.selectIndustrySecondCategory!=e&&(this.selectIndustrySecondCategory=e,this.selectIndustryThirdCategory=0)},clickIndustryThirdCategoryItem(e){this.selectIndustryThirdCategory!=e&&(this.selectIndustryThirdCategory=e)},clickImportanceItem(e){if(e.select=!e.select,"all"==e.key){if(e.select)for(let t of this.importanceList)t.key!=e.key&&(t.select=!1)}else for(let t of this.importanceList)"all"==t.key&&(t.select=!1)},clickExpandOrRetract(e){this.eventList[e].isExpand=!this.eventList[e].isExpand},clickLookRelatedStockItem(t,s){e.index.navigateTo({url:"/pages/index/stockDetails/stockDetails?type=1&code="+s+"&id="+t})},clickFollowEvent(s){t.followEvent(s).then((t=>{e.index.showToast({title:t.message,icon:"none"}),this.clickSearch()})).catch((e=>{}))},clickEventItem(t){let s=this;e.index.$on("editSuccess",(t=>{s.clickSearch(),e.index.$off("editSuccess")})),e.index.navigateTo({url:"/pages/index/eventDetails/eventDetails?id="+t})},getEventFilterListData(){return new Promise(((s,i)=>{t.filterOptions().then((t=>{if(200==t.code){s(1);let e=[...t.data.sort_options];this.timeCategoryList=e.splice(0,2);let i=[...t.data.sort_options];for(let t of i)"最新"==t.name&&(t.icon="/static/icon/home/new.png"),"热门"==t.name&&(t.icon="/static/icon/home/hot.png"),"收益率"==t.name&&(t.icon="/static/icon/home/yield.png");this.sortTypeList=t.data.sort_options.slice(0,3),this.importanceList=t.data.importance_options,this.importanceList.unshift({desc:"全部",key:"all",name:"全部"})}else s(1),e.index.showToast({title:t.message,icon:"none"})})).catch((e=>{i(1)}))}))},getIndustryCategoryListData(){return new Promise(((e,s)=>{t.industryCategoryList().then((t=>{let s=t.data[0].hierarchy;s.unshift({level1_sector:"全部",level2_sectors:[]});for(let e of s){let t=s.indexOf(e);e.index=t,e.level2_sectors.unshift({level2_sector:"全部",level3_sectors:[]});for(let s of e.level2_sectors){let t=e.level2_sectors.indexOf(s);s.index1=t,s.level3_sectors.unshift({level3_sector:"全部",level4_sectors:[]});for(let e of s.level3_sectors){let t=s.level3_sectors.indexOf(e);e.index2=t}}}this.industryCategoryList=s,e(1)})).catch((e=>{s(1)}))}))},getStockCategoryListData(){return new Promise(((s,i)=>{t.stockCategoryList().then((t=>{if(200==t.code){for(let e of t.data)e.sub_sectors.unshift("全部");t.data.unshift({primary_sector:"全部",sub_sectors:[]}),this.stockCategoryList=t.data,s(1)}else e.index.showToast({title:t.message,icon:"none"}),i(1)})).catch((e=>{i(1)}))}))},getEventListData(){let e={page:this.page,q:this.keywords};this.selectTopCategory>0&&(e.stock_sector=this.stockCategoryList[this.selectTopCategory].primary_sector),this.selectSecondCategory>0&&(e.secondary_sector=this.stockCategoryList[this.selectTopCategory].sub_sectors[this.selectSecondCategory]),this.selectQuickTimeIndex>-1&&(e.time_filter=this.quickTimeList[this.selectQuickTimeIndex].key),this.startDateStr&&(e.start_date=this.startDateStr),this.endDateStr&&(e.end_date=this.endDateStr),this.selectIndustryThirdCategory>0?(e.industry_level=4,e.industry_classification=this.industryCategoryList[this.selectIndustryTopCategory].level2_sectors[this.selectIndustrySecondCategory].level3_sectors[this.selectIndustryThirdCategory].level3_sector):this.selectIndustrySecondCategory>0?(e.industry_level=3,e.industry_classification=this.industryCategoryList[this.selectIndustryTopCategory].level2_sectors[this.selectIndustrySecondCategory].level2_sector):this.selectIndustryTopCategory>0&&(e.industry_level=2,e.industry_classification=this.industryCategoryList[this.selectIndustryTopCategory].level1_sector);let s=[];for(let t of this.importanceList)t.select&&s.push(t.key);s.length>0&&(e.importance=s.join(",")),this.selectSortKey&&(e.sort=this.selectSortKey),t.eventList(e).then((e=>{this.isRefreshing=!1,e.success&&(1==this.page?this.eventList=e.data.events:this.eventList=this.eventList.concat(e.data.events),this.loadAll=!e.data.pagination.has_next)})).catch((e=>{this.isRefreshing=!1}))},getHotEventListData(){let s={page:this.page,q:this.keywords};this.selectTopCategory>0&&(s.stock_sector=this.stockCategoryList[this.selectTopCategory].primary_sector),this.selectSecondCategory>0&&(s.secondary_sector=this.stockCategoryList[this.selectTopCategory].sub_sectors[this.selectSecondCategory]),this.selectQuickTimeIndex>-1&&(s.time_filter=this.quickTimeList[this.selectQuickTimeIndex].key),this.startDateStr&&(s.start_date=this.startDateStr),this.endDateStr&&(s.end_date=this.endDateStr),this.selectIndustryThirdCategory>0?(s.industry_level=4,s.industry_classification=this.industryCategoryList[this.selectIndustryTopCategory].level2_sectors[this.selectIndustrySecondCategory].level3_sectors[this.selectIndustryThirdCategory].level3_sector):this.selectIndustrySecondCategory>0?(s.industry_level=3,s.industry_classification=this.industryCategoryList[this.selectIndustryTopCategory].level2_sectors[this.selectIndustrySecondCategory].level2_sector):this.selectIndustryTopCategory>0&&(s.industry_level=2,s.industry_classification=this.industryCategoryList[this.selectIndustryTopCategory].level1_sector);let i=[];for(let e of this.importanceList)e.select&&i.push(e.key);i.length>0&&(s.importance=i.join(",")),this.selectSortKey&&(s.sort=this.selectSortKey),t.homeData(s).then((t=>{200==t.code?1==this.page?this.eventList=t.data.events:this.eventList=this.eventList.concat(t.data.events):e.index.showToast({title:t.message,icon:"none"})})).catch((e=>{}))}}};if(!Array){(e.resolveComponent("navBar")+e.resolveComponent("uni-popup"))()}Math||((()=>"../../components/navBar/navBar.js")+(()=>"../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"))();const a=e._export_sfc(o,[["render",function(t,s,r,o,a,c){return e.e({a:i._imports_0,b:e.p({leftText:"事件中心",hideNavBg:!0,hideBack:!0}),c:i._imports_1,d:e.o((e=>c.clickSearch())),e:a.keywords,f:e.o((e=>a.keywords=e.detail.value)),g:e.f(a.screenCategoryList,((t,s,i)=>e.e({a:t.icon,b:e.t(t.title),c:e.n("item flex "+(2==s?"level":"")),d:e.o((e=>c.clickScreenItem(s)),s),e:s({a:e.t(t.name),b:e.n("item "+(a.selectTimeCategory==s?"select":"")),c:s,d:e.o((e=>c.clickTimeCategoryItem(s)),s)}))),j:e.s("top:"+a.navH+"px;"),k:e.f(a.eventList,((t,s,r)=>e.e({a:e.t(t.importance),b:e.n("level "+t.importance),c:e.t(t.title),d:e.t(t.description),e:e.n("content "+(t.isExpand?"":"retract")),f:e.o((e=>c.clickExpandOrRetract(s)),s),g:a.getRateUpOrDown(t.related_avg_chg)},a.getRateUpOrDown(t.related_avg_chg)?{h:i._imports_1$1}:{i:i._imports_2$1},{j:e.t(a.getRateStr(t.related_avg_chg)),k:e.n("rateItem "+(a.getRateUpOrDown(t.related_avg_chg)?"down":"up")),l:a.getRateUpOrDown(t.related_max_chg)},a.getRateUpOrDown(t.related_max_chg)?{m:i._imports_1$1}:{n:i._imports_2$1},{o:e.t(a.getRateStr(t.related_max_chg)),p:e.n("rateItem "+(a.getRateUpOrDown(t.related_max_chg)?"down":"up")),q:a.getRateUpOrDown(t.related_week_chg)},a.getRateUpOrDown(t.related_week_chg)?{r:i._imports_1$1}:{s:i._imports_2$1},{t:e.t(a.getRateStr(t.related_week_chg)),v:e.n("rateItem "+(a.getRateUpOrDown(t.related_week_chg)?"down":"up")),w:e.t(a.getLocaleTime(t.created_at)),x:e.t(t.view_count),y:e.t(t.post_count),z:e.t(t.follower_count),A:e.o((e=>c.clickFollowEvent(t.id)),s),B:e.o((e=>c.clickEventItem(t.id)),s),C:s}))),l:i._imports_3$1,m:i._imports_4,n:i._imports_10$1,o:e.s("top:"+a.listTop+"px"),p:a.isRefreshing,q:e.o((e=>c.pullDownRefresh())),r:e.o((e=>c.loadMoreData())),s:i._imports_2,t:e.s("height:"+a.menuH+"px;"),v:e.f(a.screenCategoryList,((t,s,i)=>e.e({a:t.icon,b:e.t(t.title),c:e.n("item flex "+(2==s?"level":"")),d:e.o((e=>c.clickScreenItem(s)),s),e:s({a:e.t(t.title),b:e.n("item "+(a.selectQuickTimeIndex==s?"select":"")),c:s,d:e.o((e=>c.clickQuickTimeItem(s,t)),s)}))),z:i._imports_9,A:a.startDateStr},a.startDateStr?{B:e.t(a.startDateStr)}:{},{C:i._imports_9,D:a.endDateStr},a.endDateStr?{E:e.t(a.endDateStr)}:{},{F:e.f(a.yearList,((t,s,i)=>({a:e.t(t),b:s}))),G:e.f(a.monthList,((t,s,i)=>({a:e.t(t),b:s}))),H:e.f(a.dayList,((t,s,i)=>({a:e.t(t),b:s}))),I:a.startDateValue,J:e.o(((...e)=>c.startDateChange&&c.startDateChange(...e))),K:e.f(a.yearList,((t,s,i)=>({a:e.t(t),b:s}))),L:e.f(a.monthList,((t,s,i)=>({a:e.t(t),b:s}))),M:e.f(a.dayList,((t,s,i)=>({a:e.t(t),b:s}))),N:a.endDateValue,O:e.o(((...e)=>c.endDateChange&&c.endDateChange(...e)))}):{},{P:1==a.selectScreenCategory},1==a.selectScreenCategory?e.e({Q:i._imports_10,R:e.o([e=>a.industryKeywords=e.detail.value,(...e)=>c.industrySearch&&c.industrySearch(...e)]),S:a.industryKeywords,T:a.industryKeywords.length>0},a.industryKeywords.length>0?e.e({U:e.f(a.searchResultList,((t,s,i)=>({a:e.t(t.level1_sector),b:e.n("item relative "+(a.searchIndustryTopCategory==s?"select":"")),c:s,d:e.o((e=>c.clickSearchIndustryTopCategoryItem(s,t)),s)}))),V:e.f(a.searchResultList[a.searchIndustryTopCategory].level2_sectors,((t,s,i)=>({a:e.t(t.level2_sector),b:e.n("item relative "+(a.searchIndustrySecondCategory==s?"select":"")),c:s,d:e.o((e=>c.clickSearchIndustrySecondCategoryItem(s,t)),s)}))),W:a.searchResultList[a.searchIndustryTopCategory].level2_sectors.length>0},a.searchResultList[a.searchIndustryTopCategory].level2_sectors.length>0?{X:e.f(a.searchResultList[a.searchIndustryTopCategory].level2_sectors[a.searchIndustrySecondCategory].level3_sectors,((t,s,r)=>e.e({a:e.t(t.level3_sector),b:a.searchIndustryThirdCategory==s},a.searchIndustryThirdCategory==s?{c:i._imports_11}:{},{d:e.n("item flex relative "+(a.searchIndustryThirdCategory==s?"select":"")),e:s,f:e.o((e=>c.clickSearchIndustryThirdCategoryItem(s,t)),s)})))}:{}):e.e({Y:e.f(a.industryCategoryList,((t,s,i)=>({a:e.t(t.level1_sector),b:e.n("item relative "+(a.selectIndustryTopCategory==s?"select":"")),c:s,d:e.o((e=>c.clickIndustryTopCategoryItem(s)),s)}))),Z:e.f(a.industryCategoryList[a.selectIndustryTopCategory].level2_sectors,((t,s,i)=>({a:e.t(t.level2_sector),b:e.n("item relative "+(a.selectIndustrySecondCategory==s?"select":"")),c:s,d:e.o((e=>c.clickIndustrySecondCategoryItem(s)),s)}))),aa:a.industryCategoryList[a.selectIndustryTopCategory].level2_sectors.length>0},a.industryCategoryList[a.selectIndustryTopCategory].level2_sectors.length>0?{ab:e.f(a.industryCategoryList[a.selectIndustryTopCategory].level2_sectors[a.selectIndustrySecondCategory].level3_sectors,((t,s,r)=>e.e({a:e.t(t.level3_sector),b:a.selectIndustryThirdCategory==s},a.selectIndustryThirdCategory==s?{c:i._imports_11}:{},{d:e.n("item flex relative "+(a.selectIndustryThirdCategory==s?"select":"")),e:s,f:e.o((e=>c.clickIndustryThirdCategoryItem(s)),s)})))}:{})):{},{ac:2==a.selectScreenCategory},2==a.selectScreenCategory?{ad:e.f(a.importanceList,((t,s,r)=>e.e({a:e.t(t.name),b:t.select},t.select?{c:i._imports_12}:{},{d:e.n("item flex "+(t.select?"select":"")),e:s,f:e.o((e=>c.clickImportanceItem(t)),s)})))}:{},{ae:3==a.selectScreenCategory},3==a.selectScreenCategory?{af:e.f(a.sortTypeList,((t,s,i)=>({a:t.icon,b:e.t(t.name),c:e.n("item flex "+(a.selectSortKey==t.key?"select":"")),d:s,e:e.o((e=>c.clickSortListItem(t)),s)})))}:{},{ag:3!=a.selectScreenCategory},3!=a.selectScreenCategory?{ah:e.o((e=>c.clickCancel())),ai:e.o((e=>c.clickCertain()))}:{},{aj:e.s("padding-top:"+a.menuTop+"px;"),ak:e.sr("screenPopup","9dfd58d8-1"),al:e.p({type:"top"})})}]]);wx.createPage(a);