"use strict";const t=require("../../common/vendor.js"),e=require("../../request/api.js"),o=require("../../common/assets.js"),a={data:()=>({navH:t.inject("navHeight"),contentTop:"",currentDate:"",selectedDate:"",allStockData:[],filteredData:[],conceptStocksList:[],alertTypeConfig:{surge:{text:"异动",color:"#FF7A45",filter:"brightness(0) saturate(100%) invert(54%) sepia(60%) saturate(467%) hue-rotate(344deg) brightness(102%) contrast(101%)"},shrink_surge_up:{text:"缩量急涨",color:"#722ED1",filter:"brightness(0) saturate(100%) invert(24%) sepia(90%) saturate(2865%) hue-rotate(266deg) brightness(87%) contrast(98%)"},volume_surge_up:{text:"放量急涨",color:"#EB2F96",filter:"brightness(0) saturate(100%) invert(34%) sepia(82%) saturate(1970%) hue-rotate(313deg) brightness(91%) contrast(94%)"},volume_oscillation:{text:"放量震荡",color:"#13C2C2",filter:"brightness(0) saturate(100%) invert(71%) sepia(62%) saturate(487%) hue-rotate(142deg) brightness(91%) contrast(93%)"},surge_up:{text:"急涨",color:"#FF4D4F",filter:"brightness(0) saturate(100%) invert(42%) sepia(93%) saturate(727%) hue-rotate(346deg) brightness(102%) contrast(104%)"},surge_down:{text:"急跌",color:"#52C41A",filter:"brightness(0) saturate(100%) invert(68%) sepia(65%) saturate(456%) hue-rotate(71deg) brightness(91%) contrast(86%)"},shrink_surge_down:{text:"缩量急跌",color:"#FF7A45",filter:"brightness(0) saturate(100%) invert(54%) sepia(60%) saturate(467%) hue-rotate(344deg) brightness(102%) contrast(101%)"}},topLists:[{title:"大盘涨跌幅",value:"+0.00%",color:"#EC3440",backIcon:"/static/icon/gegu/gg-top-0.png"},{title:"涨停/跌停",value:"+0.00%",color:"#070707",backIcon:"/static/icon/gegu/gg-top-1.png"},{title:"多空对比",value:"0/0",color:"#070707",backIcon:"/static/icon/gegu/gg-top-2.png"},{title:"今日成交额",value:"0万亿",color:"#070707",backIcon:"/static/icon/gegu/gg-top-3.png"},{title:"A股总市值",value:"0万亿",color:"#070707",backIcon:"/static/icon/gegu/gg-top-4.png"},{title:"连板龙头",value:"0只",color:"#F59B38",backIcon:"/static/icon/gegu/gg-top-5.png"}],topLists2:[{title:"超大盘股",value:"(>1000亿)"},{title:"大盘股",value:"(500-1000亿)"},{title:"中盘股",value:"(100-500亿)"}],list2Index:0,typeList:[{title:"缩量急涨",backIcon:"/static/icon/gegu/cate-0.png"},{title:"异动",backIcon:"/static/icon/gegu/cate-1.png"},{title:"急跌",backIcon:"/static/icon/gegu/cate-2.png"},{title:"急涨",backIcon:"/static/icon/gegu/cate-3.png"},{title:"放量震荡",backIcon:"/static/icon/gegu/cate-4.png"}],marketAlertsList:[],formattedAvg:0,upCount:0,downCount:0,limit_up_ratio:0,searchResultTop:"",contentTop:"",keywords:"",searchShow:!1,searchResultList:[],selectSearchStockInfo:null,isShowTime:!1}),onLoad(e){this.activeIndex=e.index,this.searchResultTop=this.navH+.12*t.inject("windowWidth"),this.contentTop=this.navH+115/750*t.inject("windowWidth"),this.conceptsDailyTop();const o=new Date,a=o.getFullYear(),i=(o.getMonth()+1).toString().padStart(2,"0"),s=o.getDate().toString().padStart(2,"0");this.currentDate=`${a}-${i}-${s}`},onShow(){this.isShowTime=!1,this.marketHeatmap(),this.marketStatistics(),this.marketHotspotListOverview()},methods:{truncateText:(t,e)=>t?t.length>e?t.substring(0,e)+"...":t:"",clickSearch(){this.keywords?this.getSearchStockInfoListData():this.selectSearchStockInfo=null},clickSearchResultBg(){this.searchShow=!1},clickSearchResultListItem(t){this.selectSearchStockInfo=t,this.searchShow=!1,this.getStockBasicInfoData()},getSearchStockInfoListData(){let t={q:this.keywords,limit:10};e.searchStockInfo(t).then((t=>{this.searchResultList=t.data,this.searchShow=this.searchResultList.length>0})).catch((t=>{}))},getStockBasicInfoData(){let e=this.stockCode;this.selectSearchStockInfo&&(e=this.selectSearchStockInfo.stock_code),t.index.navigateTo({url:"/pagesStock/stockCenterDetails/stockCenterDetails?code="+e})},getQuoteDetailsData(){let t=this.stockCode;this.selectSearchStockInfo&&(t=this.selectSearchStockInfo.stock_code),quoteDetailsInfo(t).then((t=>{this.quoteDetailsInfo=t.data})).catch((t=>{}))},formatAlpha:t=>null==t||isNaN(Number(t))?"0.0":Number(t).toFixed(1),handleTypeClick(t){this.list2Index=t,this.marketHeatmap(this.currentDate)},getTableItem(t){const e=t.market_cap?t.market_cap.toFixed(2):"0.00",o=t.amount?t.amount.toFixed(2):"0.00",a=t.change_percent?Number(t.change_percent):0;let i="",s="";return a>0?(i=`+${a}%`,s="positive"):a<0?(i=`${a}%`,s="negative"):(i="0%",s="zero"),[[t.stock_name,t.stock_code],[i,"",s],[`${e}亿元`],[`${o}亿元`],[t.industry||"暂无"]]},formatLimitUpRatio(t,e=0){if(!t||isNaN(Number(t)))return"0%";const o=100*Number(t);return`${0===e?Math.round(o):o.toFixed(e)}%`},conceptsDailyTop(){e.conceptsDailyTop().then((t=>{})).catch((t=>{}))},marketHeatmap(t){let o={limit:500};this.isShowTime&&t&&"undefined"!==t&&""!==t.trim()&&(o.date=t),e.marketHeatmap(o).then((t=>{this.topLists[2].value=t.statistics.rising_count+"/"+t.statistics.falling_count,this.allStockData=t.data||[];const e=this.allStockData.filter((t=>{const e=Number(t.change_percent);return!isNaN(e)&&e>=9.9})).length,o=this.allStockData.filter((t=>{const e=Number(t.change_percent);return!isNaN(e)&&e<=-9.9})).length;this.topLists[1].value=e+"/"+o,this.topLists[5].value=e+"只",this.filterStockByMarketCap()})).catch((t=>{}))},filterStockByMarketCap(){const{list2Index:t,allStockData:e}=this;let o=[];switch(t){case 0:o=e.filter((t=>t.market_cap>1e3));break;case 1:o=e.filter((t=>t.market_cap>=500&&t.market_cap<=1e3));break;case 2:o=e.filter((t=>t.market_cap>=100&&t.market_cap<=500));break;default:o=e}this.filteredData=o.slice(0,10)},marketStatistics(){e.marketStatistics().then((t=>{this.topLists[3].value=this.formatToTrillion(t.summary.total_amount),this.topLists[4].value=this.formatToTrillion(t.summary.total_market_cap)})).catch((t=>{this.topLists[3].value="0.0 万亿",this.topLists[4].value="0.0 万亿"}))},formatToTrillion(t){if("number"!=typeof t||isNaN(t))return"0.0 万亿";return`${(t/1e4).toFixed(1)} 万亿`},marketHotspotListOverview(){let t={date:this.currentDate};e.marketHotspotOverview(t).then((t=>{var e;const o=(null==(e=null==t?void 0:t.data)?void 0:e.alerts)||[],a=t.data.index.change_pct;let i=0;a&&!isNaN(Number(a))&&(i=Number(a));const s=Math.round(100*i)/100,r=s.toFixed(2);let c="";c=s>0?`+${r}%`:s<0?`${r}%`:"0.00%";const n=s>0?"#EC3440":s<0?"#01AB5D":"#666666";this.topLists[0].value=c,this.topLists[0].color=n;const l=o.map((t=>{const e=(t.stocks||[]).filter((t=>null!=t.change_pct&&!isNaN(Number(t.change_pct)))),o=e.length>0?e.reduce(((t,e)=>t+Number(e.change_pct)),0)/e.length:0,a=e.filter((t=>Number(t.change_pct)>0)).length,i=e.filter((t=>Number(t.change_pct)<0)).length,s=Math.round(100*o)/100,r=s>0?`+${s.toFixed(2)}`:s.toFixed(2);return{...t,alpha:o,upCount:a,downCount:i,formattedAvg:r}})).sort(((t,e)=>{const o=t=>{const[e,o]=t.split(":").map(Number);return 60*e+o},a=o(t.time);return o(e.time)-a}));this.marketAlertsList=l})).catch((t=>{}))},itemDetails(e){t.index.navigateTo({url:"/pagesStock/stockCenterDetails/stockCenterDetails?code="+e.stock_code})},moreAction(){this.isShowTime?t.index.navigateTo({url:"/pages/geGuCenter/detail?currentDate="+this.currentDate}):t.index.navigateTo({url:"/pages/geGuCenter/detail"})},allAction(t){1==t?this.$refs.typePopup.open():2==t&&this.$refs.datePopup.open()},closeAction(t){1==t?this.$refs.typePopup.close():2==t?this.$refs.datePopup.close():3==t&&this.$refs.detailPopup.close()},handleDateChange(t){this.selectedDate=t,console.log("选中的日期:",t)},confirmAction(t){if(1==t)this.$refs.typePopup.close();else if(2==t){if(this.selectedDate)this.currentDate=this.selectedDate,console.log("最终确认的日期:",this.currentDate);else{const t=new Date,e=t.getFullYear(),o=(t.getMonth()+1).toString().padStart(2,"0"),a=t.getDate().toString().padStart(2,"0");this.currentDate=`${e}-${o}-${a}`}this.isShowTime=!0,this.marketHeatmap(this.currentDate),this.marketStatistics(),this.marketHotspotListOverview(),this.$refs.datePopup.close()}},bkydAction(t){this.$refs.detailPopup.open(),this.formattedAvg=t.formattedAvg,this.upCount=t.upCount,this.downCount=t.downCount,this.limit_up_ratio=t.limit_up_ratio,this.conceptStocksDetails(t.concept_id)},conceptStocksDetails(t){console.log("concept_id",t),e.conceptStocks(t,{}).then((t=>{if(t.data&&t.data.stocks){let e=t.data.stocks;this.conceptStocksList=e.sort(((t,e)=>{const o=null===t.change_pct||void 0===t.change_pct?-999:Number(t.change_pct);return(null===e.change_pct||void 0===e.change_pct?-999:Number(e.change_pct))-o}))}else console.warn("接口返回数据格式异常",t)})).catch((t=>{}))},formatChangePct(t){if("number"!=typeof t)return"0.00%";return`${t>=0?"+":""}${t.toFixed(2)}%`},getChangeColor:t=>"number"!=typeof t?"#888888":t>0?"#EC3440":t<0?"#00B42A":"#888888"}};if(!Array){(t.resolveComponent("navBar")+t.resolveComponent("uni-popup")+t.resolveComponent("LCCalendar2"))()}Math||((()=>"../../components/navBar/navBar.js")+(()=>"../../uni_modules/uni-popup/components/uni-popup/uni-popup.js")+(()=>"../../components/LCCalendar2/LCCalendar2.js"))();const i=t._export_sfc(a,[["render",function(e,a,i,s,r,c){return t.e({a:t.p({leftText:"个股中心",hideNavBg:!0,hideBack:!0}),b:o._imports_0,c:o._imports_1,d:t.o([t=>r.keywords=t.detail.value,t=>c.clickSearch()]),e:r.keywords,f:t.s("top:"+r.navH+"px;"),g:r.searchShow},r.searchShow?{h:t.f(r.searchResultList,((e,o,a)=>({a:t.t(e.stock_code),b:t.t(e.stock_name),c:o,d:t.o((t=>c.clickSearchResultListItem(e)),o)}))),i:t.s("top:"+r.searchResultTop+"px;"),j:t.o((t=>c.clickSearchResultBg()))}:{},{k:t.f(r.topLists,((e,o,a)=>({a:e.backIcon,b:t.t(e.title),c:t.t(e.value),d:e.color,e:o}))),l:t.f(r.topLists2,((e,o,a)=>({a:t.t(e.title),b:r.list2Index==o?"#BB8520":"#070707",c:r.list2Index==o?"#FFFAF1":"#FFFFFF",d:t.t(e.value),e:r.list2Index==o?"#BB8520":"#070707",f:t.o((t=>c.handleTypeClick(o)),o),g:o,h:"1rpx solid "+(r.list2Index==o?"#F2C369":"#D2D2D2")}))),m:t.f(["股票名称","涨跌幅","市值","成交额","行业"],((e,o,a)=>({a:t.t(e),b:o}))),n:t.f(r.filteredData,((e,o,a)=>({a:t.f(c.getTableItem(e),((e,o,a)=>t.e({a:t.t(e[0]),b:0==o},0==o?{c:t.t(e[1])}:{},{d:o,e:0==o?"#222222":1==o?"positive"===e[2]?"#EC3440":"#01AB5D":"#666666"}))),b:t.o((t=>c.itemDetails(e))),c:o%2==0?"#fff":"#FAFAFC"}))),o:o._imports_2$3,p:t.o(((...t)=>c.moreAction&&c.moreAction(...t))),q:o._imports_3$7,r:t.t(r.currentDate),s:o._imports_4$1,t:t.o((t=>c.allAction(2))),v:o._imports_3$7,w:t.f(r.marketAlertsList,((e,o,a)=>{var i,s,n,l;return t.e({a:t.t(e.time),b:t.t(c.truncateText(e.concept_name,5)),c:(null==(i=r.alertTypeConfig[e.alert_type])?void 0:i.filter)||"",d:t.t((null==(s=r.alertTypeConfig[e.alert_type])?void 0:s.text)||"异动"),e:(null==(n=r.alertTypeConfig[e.alert_type])?void 0:n.color)||"#FF7A45",f:"1rpx solid "+((null==(l=r.alertTypeConfig[e.alert_type])?void 0:l.color)||"#FF7A45"),g:t.t(e.formattedAvg),h:Number(e.alpha)>0?"#EC3440":"#01AB5D",i:t.t(e.upCount),j:e.upCount>0?"#EC3440":"#888888",k:t.t(e.downCount),l:e.downCount>0?"#01AB5D":"#888888",m:t.t(Math.round(e.final_score)),n:e&&Number(e.limit_up_ratio)>0&&!isNaN(Number(e.limit_up_ratio))},e&&Number(e.limit_up_ratio)>0&&!isNaN(Number(e.limit_up_ratio))?{o:t.t(c.formatLimitUpRatio(e.limit_up_ratio,0))}:{},{p:o,q:t.o((t=>c.bkydAction(e)),o)})})),x:o._imports_5$3,y:t.s("top:"+r.contentTop+"px;"),z:t.o((t=>c.closeAction(1))),A:t.o((t=>c.confirmAction(1))),B:t.f(r.typeList,((e,o,a)=>({a:e.backIcon,b:t.t(e.title),c:o}))),C:t.sr("typePopup","c7f5c964-1"),D:t.p({type:"bottom",safeArea:!1}),E:t.o((t=>c.closeAction(2))),F:t.o((t=>c.confirmAction(2))),G:t.o(c.handleDateChange),H:t.sr("datePopup","c7f5c964-2"),I:t.p({type:"bottom",safeArea:!1}),J:o._imports_6$1,K:t.o((t=>c.closeAction(3))),L:t.t(r.formattedAvg),M:Number(r.formattedAvg)>0?"#EC3440":"#01AB5D",N:t.t(r.upCount),O:r.upCount>0?"#EC3440":"#888888",P:t.t(r.downCount),Q:r.downCount>0?"#01AB5D":"#888888",R:t.t(c.formatLimitUpRatio(r.limit_up_ratio,0)),S:t.f(r.conceptStocksList,((e,o,a)=>({a:t.t(e.name),b:t.t(e.code),c:t.t(c.formatChangePct(e.change_pct)),d:c.getChangeColor(e.change_pct),e:o,f:o%2==0?"#fff":"#FAFAFC"}))),T:t.sr("detailPopup","c7f5c964-4"),U:t.p({type:"bottom",safeArea:!1})})}]]);wx.createPage(i);