Files
JiaZhiQianYan/unpackage/dist/build/mp-weixin/pages/geGuCenter/geGuCenter.js

2 lines
11 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"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}),onLoad(e){this.activeIndex=e.index,this.contentTop=this.navH+115/750*t.inject("windowWidth");const o=new Date,a=o.getFullYear(),i=(o.getMonth()+1).toString().padStart(2,"0"),r=o.getDate().toString().padStart(2,"0");this.currentDate=`${a}-${i}-${r}`},onShow(){this.marketHeatmap(),this.marketStatistics(),this.marketHotspotListOverview()},methods:{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="",r="";return a>0?(i=`+${a}%`,r="positive"):a<0?(i=`${a}%`,r="negative"):(i="0%",r="zero"),[[t.stock_name,t.stock_code],[i,"",r],[`${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};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 r=Math.round(100*i)/100,s=r.toFixed(2);let n="";n=r>0?`+${s}%`:r<0?`${s}%`:"0.00%";const c=r>0?"#EC3440":r<0?"#01AB5D":"#666666";this.topLists[0].value=n,this.topLists[0].color=c;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,r=Math.round(100*o)/100,s=r>0?`+${r.toFixed(2)}`:r.toFixed(2);return{...t,alpha:o,upCount:a,downCount:i,formattedAvg:s}})).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(){t.index.navigateTo({url:"/pages/geGuCenter/detail?currentDate="+this.currentDate})},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.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,r,s,n){return{a:t.p({leftText:"个股中心",hideNavBg:!0,hideBack:!0}),b:o._imports_0,c:o._imports_1,d:t.o((t=>e.clickSearch())),e:e.keywords,f:t.o((t=>e.keywords=t.detail.value)),g:t.s("top:"+s.navH+"px;"),h:t.f(s.topLists,((e,o,a)=>({a:e.backIcon,b:t.t(e.title),c:t.t(e.value),d:e.color,e:o}))),i:t.f(s.topLists2,((e,o,a)=>({a:t.t(e.title),b:s.list2Index==o?"#BB8520":"#070707",c:s.list2Index==o?"#FFFAF1":"#FFFFFF",d:t.t(e.value),e:s.list2Index==o?"#BB8520":"#070707",f:t.o((t=>n.handleTypeClick(o)),o),g:o,h:"1rpx solid "+(s.list2Index==o?"#F2C369":"#D2D2D2")}))),j:t.f(["股票名称","涨跌幅","市值","成交额","行业"],((e,o,a)=>({a:t.t(e),b:o}))),k:t.f(s.filteredData,((e,o,a)=>({a:t.f(n.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=>n.itemDetails(e))),c:o%2==0?"#fff":"#FAFAFC"}))),l:o._imports_1$2,m:t.o(((...t)=>n.moreAction&&n.moreAction(...t))),n:o._imports_3$7,o:o._imports_4$1,p:t.o((t=>n.allAction(1))),q:t.t(s.currentDate),r:o._imports_4$1,s:t.o((t=>n.allAction(2))),t:o._imports_3$7,v:t.f(s.marketAlertsList,((e,o,a)=>{var i,r,c,l;return t.e({a:t.t(e.time),b:t.t(e.concept_name),c:(null==(i=s.alertTypeConfig[e.alert_type])?void 0:i.filter)||"",d:t.t((null==(r=s.alertTypeConfig[e.alert_type])?void 0:r.text)||"异动"),e:(null==(c=s.alertTypeConfig[e.alert_type])?void 0:c.color)||"#FF7A45",f:"1rpx solid "+((null==(l=s.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(n.formatLimitUpRatio(e.limit_up_ratio,0))}:{},{p:o,q:t.o((t=>n.bkydAction(e)),o)})})),w:o._imports_5$3,x:t.s("top:"+s.contentTop+"px;"),y:t.o((t=>n.closeAction(1))),z:t.o((t=>n.confirmAction(1))),A:t.f(s.typeList,((e,o,a)=>({a:e.backIcon,b:t.t(e.title),c:o}))),B:t.sr("typePopup","c7f5c964-1"),C:t.p({type:"bottom",safeArea:!1}),D:t.o((t=>n.closeAction(2))),E:t.o((t=>n.confirmAction(2))),F:t.o(n.handleDateChange),G:t.sr("datePopup","c7f5c964-2"),H:t.p({type:"bottom",safeArea:!1}),I:o._imports_8,J:t.o((t=>n.closeAction(3))),K:t.t(s.formattedAvg),L:Number(s.formattedAvg)>0?"#EC3440":"#01AB5D",M:t.t(s.upCount),N:s.upCount>0?"#EC3440":"#888888",O:t.t(s.downCount),P:s.downCount>0?"#01AB5D":"#888888",Q:t.t(n.formatLimitUpRatio(s.limit_up_ratio,0)),R:t.f(s.conceptStocksList,((e,o,a)=>({a:t.t(e.name),b:t.t(e.code),c:t.t(n.formatChangePct(e.change_pct)),d:n.getChangeColor(e.change_pct),e:o,f:o%2==0?"#fff":"#FAFAFC"}))),S:t.sr("detailPopup","c7f5c964-4"),T:t.p({type:"bottom",safeArea:!1})}}]]);wx.createPage(i);