Files
JiaZhiQianYan/unpackage/dist/build/mp-weixin/pages/concept/concept.js
zw199166 1f3a3ca8bb 1.
2026-01-22 14:34:38 +08:00

2 lines
14 KiB
JavaScript

"use strict";const t=require("../../common/vendor.js"),e=require("../../request/api.js"),s=require("../../utils/util.js"),a=require("../../common/assets.js"),c={data:()=>({navH:t.inject("navHeight"),listTop:"",sortListTop:"",keywords:"",newestPriceDate:"",popType:"",cycleList:["3天","7天","14天","自定义"],selectCycleIndex:0,startDateStr:"",endDateStr:"",selectStartDateStr:"",selectStartMonthIndex:0,selectStartMonth:"",selectEndDateStr:"",selectEndMonthIndex:0,selectEndMonth:"",rankTabList:[{icon:"/static/icon/home/conceptCenter/increaseRate.png",selectIcon:"/static/icon/home/conceptCenter/increaseRate_s.png",title:"涨幅榜"},{icon:"/static/icon/home/conceptCenter/decreaseRate.png",selectIcon:"/static/icon/home/conceptCenter/decreaseRate_s.png",title:"跌幅榜"},{icon:"/static/icon/home/conceptCenter/active.png",selectIcon:"/static/icon/home/conceptCenter/active_s.png",title:"活跃榜"},{icon:"/static/icon/home/conceptCenter/fluctuate.png",selectIcon:"/static/icon/home/conceptCenter/fluctuate_s.png",title:"波动榜"},{icon:"/static/icon/home/conceptCenter/continuousRise.png",selectIcon:"/static/icon/home/conceptCenter/continuousRise_s.png",title:"连涨榜"}],selectTab:0,rankList:[],sortTypeList:[{icon:"/static/icon/home/conceptCenter/chgSort.png",name:"涨跌幅",key:"change_pct"},{icon:"/static/icon/home/conceptCenter/correlationSort.png",name:"相关度",key:"_score"},{icon:"/static/icon/home/conceptCenter/stockNumSort.png",name:"股票数量",key:"stock_count"},{icon:"/static/icon/home/conceptCenter/conceptNameSort.png",name:"概念名称",key:"concept_name"}],sortType:"change_pct",sortTypeStr:"涨跌幅",weekList:["一","二","三","四","五","六","日"],monthDateList:[],selectMonthIndex:0,selectMonth:"",selectDateStr:"",selectTradeDateStr:"",selectTradeMonthIndex:0,selectTradeMonth:"",quickTimeList:["今天","昨天","一周前","一月前"],conceptList:[],page:1,isRefreshing:!1,loadAll:!1,getRateUpOrDown:s.getRateUpOrDown,getChgRateStr:s.getChgRateStr,memberInfo:null}),onLoad(){this.listTop=this.navH+160/750*t.inject("windowWidth"),this.sortListTop=this.navH+160/750*t.inject("windowWidth");let e=new Date,s=e.getFullYear(),a=e.getMonth()+1,c=e.getDate();this.selectMonthIndex=this.selectTradeMonthIndex=this.selectEndMonthIndex=240+a-1,this.selectMonth=this.selectTradeMonth=this.selectEndMonth=s+"年"+a+"月",this.selectDateStr=this.selectTradeDateStr=this.endDateStr=this.selectEndDateStr=s+"-"+(a>9?a:"0"+a)+"-"+(c>9?c:"0"+c);let n=new Date(e);n.setDate(n.getDate()-3);let i=n.getFullYear(),o=n.getMonth()+1,l=n.getDate();this.selectStartMonthIndex=12*(20+s-i)+o-1,this.selectStartMonth=i+"年"+o+"月",this.startDateStr=this.selectStartDateStr=i+"-"+(o>9?o:"0"+o)+"-"+(l>9?l:"0"+l),this.generateMonthDateListData(),this.getNewestPriceDateData(),this.getRankListData(),this.getMemberStatusData()},methods:{generateMonthDateListData(){let t=new Date,e=t.getFullYear(),s=t.getMonth()+1,a=t.getDate(),c=[];for(var n=e-20;n<e+20;n++)for(var i=0;i<12;i++){let t=new Date(n,i+1,0),l=new Date(n,i+1,0);l.setDate(1);let r=t.getDate(),h=l.getDay()||7,p=[];for(var o=1;o<=r;o++){let t=new Date(n,i+1,0);t.setDate(o);let c=t.getMonth()+1,l=t.getDate(),r=t.getTime(),h=n+"-"+(c>9?c:"0"+c)+"-"+(l>9?l:"0"+l);p.push({date:h,year:n,month:c,day:l,isToday:n==e&&c==s&&l==a,isCurrentMonth:!0,timestamp:r})}for(o=0;o<h-1;o++){let t=n,e=i;i<1&&(t=n-1,e=12);let s=new Date(t,e,0).getDate(),a=new Date(t,e-1,s-o),c=a.getMonth()+1,l=a.getDate(),r=a.getTime(),h=t+"-"+(c>9?c:"0"+c)+"-"+(l>9?l:"0"+l);p.unshift({date:h,year:t,month:c,day:l,isToday:!1,isCurrentMonth:!1,timestamp:r})}let d=new Date(n,i+1,1),D=new Date(d-864e5).getDay()||7;for(o=1;o<8-D;o++){let t=n,e=i;e>11&&(e=0,t++);let s=new Date(t,e+1,o),a=s.getMonth()+1,c=s.getDate(),l=s.getTime(),r=t+"-"+(a>9?a:"0"+a)+"-"+(c>9?c:"0"+c);p.push({date:r,year:t,month:a,day:c,isToday:!1,isCurrentMonth:!1,timestamp:l})}c.push(p)}this.monthDateList=c},pullDownRefresh(){this.isRefreshing=!0,this.clickSearch()},loadMoreData(){this.loadAll||(this.page++,this.getConceptCenterData())},clickSearch(){this.page=1,this.getConceptCenterData()},clickRank(){this.$refs.rankPopup.open()},clickRankClose(){this.$refs.rankPopup.close()},clickRankCycleListItem(t){if(this.selectCycleIndex!=t)if(this.selectCycleIndex=t,3==t);else{let e=new Date,s=e.getFullYear(),a=e.getMonth()+1,c=e.getDate(),n=new Date(e);0==t?n.setDate(n.getDate()-3):1==t?n.setDate(n.getDate()-7):2==t&&n.setDate(n.getDate()-14);let i=n.getFullYear(),o=n.getMonth()+1,l=n.getDate();this.endDateStr=this.selectEndDateStr=s+"-"+(a>9?a:"0"+a)+"-"+(c>9?c:"0"+c),this.startDateStr=this.selectStartdateStr=i+"-"+(o>9?o:"0"+o)+"-"+(l>9?l:"0"+l),this.getRankListData()}},clickCustomDateCycle(t){this.popType=t,2==t?(this.selectDateStr=this.selectStartDateStr,this.selectMonth=this.selectStartMonth,this.selectMonthIndex=this.selectStartMonthIndex):(this.selectDateStr=this.selectEndDateStr,this.selectMonth=this.selectEndMonth,this.selectMonthIndex=this.selectEndMonthIndex),this.$refs.transactionDatePopup.open()},clickApply(){new Date(this.selectStartDateStr)>new Date(this.selectEndDateStr)?t.index.showToast({title:"开始日期不能晚于结束日期",icon:"none"}):(this.startDateStr=this.selectStartDateStr,this.endDateStr=this.selectEndDateStr,this.getRankListData())},clickRankTabItem(t){this.selectTab!=t&&(this.selectTab=t,this.getRankListData())},clickSortType(){this.$refs.sortTypePopup.open()},clickSortListItem(t){this.sortType=t.key,this.sortTypeStr=t.name,this.clickSearch(),this.$refs.sortTypePopup.close()},clickTransactionDate(){this.popType=1,this.selectDateStr=this.selectTradeDateStr,this.selectMonth=this.selectTradeMonth,this.selectMonthIndex=this.selectTradeMonthIndex,this.$refs.transactionDatePopup.open()},clickCancel(){this.$refs.transactionDatePopup.close()},clickConfirm(){this.clickCancel(),1==this.popType?(this.selectTradeDateStr=this.selectDateStr,this.selectTradeMonth=this.selectMonth,this.selectTradeMonthIndex=this.selectMonthIndex,this.getConceptCenterData()):2==this.popType?(this.selectStartDateStr=this.selectDateStr,this.selectStartMonth=this.selectMonth,this.selectStartMonthIndex=this.selectMonthIndex):(this.selectEndDateStr=this.selectDateStr,this.selectEndMonth=this.selectMonth,this.selectEndMonthIndex=this.selectMonthIndex)},clickPreMonth(){if(this.selectMonthIndex>0){this.selectMonthIndex--;let t=this.monthDateList[this.selectMonthIndex],e="",s="";for(let a of t)if(a.isCurrentMonth){e=a.year,s=a.month;break}this.selectMonth=e+"年"+s+"月"}},clickNextMonth(){if(this.selectMonthIndex<this.monthDateList.length-1){this.selectMonthIndex++;let t=this.monthDateList[this.selectMonthIndex],e="",s="";for(let a of t)if(a.isCurrentMonth){e=a.year,s=a.month;break}this.selectMonth=e+"年"+s+"月"}},monthChange(t){let e=(new Date).getFullYear(),s=t.detail.value,a=parseInt(s.split("-")[0]),c=parseInt(s.split("-")[1]);this.selectMonthIndex=12*(a-(e-20))+c-1,this.selectMonth=a+"年"+c+"月"},clickSelectDate(t){this.selectDateStr!=t.date&&(this.selectDateStr=t.date)},clickQuickTimeItem(t){let e=new Date,s=e.getFullYear();if(0==t){let t=e.getMonth()+1,a=e.getDate();this.selectMonthIndex=240+t-1,this.selectMonth=s+"年"+t+"月",this.selectDateStr=s+"-"+(t>9?t:"0"+t)+"-"+(a>9?a:"0"+a)}else if(1==t){let t=new Date(e);t.setDate(t.getDate()-1);let a=t.getFullYear(),c=t.getMonth()+1,n=t.getDate();this.selectMonthIndex=12*(20-(s-a))+c-1,this.selectMonth=a+"年"+c+"月",this.selectDateStr=a+"-"+(c>9?c:"0"+c)+"-"+(n>9?n:"0"+n)}else if(2==t){let t=new Date(e);t.setDate(t.getDate()-7);let a=t.getFullYear(),c=t.getMonth()+1,n=t.getDate();this.selectMonthIndex=12*(20-(s-a))+c-1,this.selectMonth=a+"年"+c+"月",this.selectDateStr=a+"-"+(c>9?c:"0"+c)+"-"+(n>9?n:"0"+n)}else{let t=new Date(e);t.setDate(t.getDate()-30);let a=t.getFullYear(),c=t.getMonth()+1,n=t.getDate();this.selectMonthIndex=12*(20-(s-a))+c-1,this.selectMonth=a+"年"+c+"月",this.selectDateStr=a+"-"+(c>9?c:"0"+c)+"-"+(n>9?n:"0"+n)}},clickNotVip(){this.$refs.vipPopup.open()},clickLater(){this.$refs.vipPopup.close()},clickUpgradeAtOnce(){this.clickLater()},clickConceptItem(e){let s=t.CryptoJS.MD5(e).toString();t.index.navigateTo({url:"/pages/index/conceptDetails/conceptDetails?name="+s})},clickStockMore(e){t.index.navigateTo({url:"/pages/concept/hotStock/hotStock?id="+e.concept_id})},clickHistoricalTimeline(e){t.index.navigateTo({url:"/pages/concept/historicalTimeline/historicalTimeline?id="+e.concept_id})},getConceptCenterData(){let t=this.selectDateStr;new Date(this.selectDateStr).getTime()>new Date(this.newestPriceDate).getTime()&&(t=this.newestPriceDate);let s={query:this.keywords,size:10,page:this.page,sort_by:this.sortType,isJson:1,trade_date:t};e.eventRelatedConcept(s).then((t=>{this.isRefreshing=!1,1==t.page?this.conceptList=t.results:this.conceptList=this.conceptList.concat(t.results),t.page==t.total_pages&&(this.loadAll=!0)})).catch((t=>{this.isRefreshing=!1}))},getNewestPriceDateData(){e.newestPriceDate().then((t=>{this.newestPriceDate=t.latest_trade_date,this.getConceptCenterData()})).catch((t=>{}))},getMemberStatusData(){t.index.getStorageSync("token")&&e.membershipStatus().then((e=>{200==e.code?this.memberInfo=e.data:t.index.showToast({title:e.message,icon:"none"})})).catch((t=>{}))},getRankListData(){var t={};3==this.selectCycleIndex?(t.start_date=this.startDateStr,t.end_date=this.endDateStr):(t.days=3,1==this.selectCycleIndex?t.days=7:2==this.selectCycleIndex&&(t.days=14),t.min_stock_count=3),e.conceptRankList(t).then((t=>{0==this.selectTab?this.rankList=t.data.hot_concepts:1==this.selectTab?this.rankList=t.data.cold_concepts:2==this.selectTab?this.rankList=t.data.active_concepts:3==this.selectTab?this.rankList=t.data.volatile_concepts:this.rankList=t.data.momentum_concepts})).catch((t=>{}))}}};if(!Array){(t.resolveComponent("navBar")+t.resolveComponent("uni-popup"))()}Math||((()=>"../../components/navBar/navBar.js")+(()=>"../../uni_modules/uni-popup/components/uni-popup/uni-popup.js"))();const n=t._export_sfc(c,[["render",function(e,s,c,n,i,o){return t.e({a:t.p({leftText:"概念中心",hideNavBg:!0,hideBack:!0}),b:a._imports_0,c:a._imports_1,d:t.o((t=>o.clickSearch())),e:i.keywords,f:t.o((t=>i.keywords=t.detail.value)),g:t.o((t=>o.clickRank())),h:t.t(i.newestPriceDate),i:a._imports_2$3,j:t.t(i.sortTypeStr),k:a._imports_3,l:t.o((t=>o.clickSortType())),m:a._imports_4$2,n:a._imports_3,o:t.o((t=>o.clickTransactionDate())),p:t.s("top: "+i.navH+"px;"),q:t.f(i.conceptList,((e,s,a)=>t.e({a:t.t(e.concept),b:t.o((t=>o.clickConceptItem(e.concept)),s),c:e.price_info},e.price_info?{d:t.t(i.getChgRateStr(e.price_info.avg_change_pct)),e:t.n("chg "+(i.getRateUpOrDown(e.price_info.avg_change_pct)?"down":"up"))}:{},{f:e.price_info},e.price_info?{g:t.t(e.stock_count),h:t.n("stockNum "+(i.getRateUpOrDown(e.price_info.avg_change_pct)?"down":"up"))}:{},{i:t.t(e.description),j:t.o((t=>o.clickConceptItem(e.concept)),s),k:t.f(e.stocks.slice(0,3),((e,s,a)=>({a:t.t(e.name),b:s}))),l:t.t(e.stock_count-3),m:t.o((t=>o.clickStockMore(e)),s),n:t.t(e.price_info?e.price_info.trade_date:""),o:t.o((t=>o.clickHistoricalTimeline(e)),s),p:s}))),r:a._imports_1$3,s:t.s("top: "+i.listTop+"px;"),t:i.isRefreshing,v:t.o((t=>o.pullDownRefresh())),w:t.o((t=>o.loadMoreData())),x:a._imports_13$1,y:t.o((t=>o.clickRankClose())),z:a._imports_7$1,A:t.t(i.startDateStr),B:t.t(i.endDateStr),C:t.f(i.cycleList,((e,s,a)=>({a:t.t(e),b:t.n("item "+(i.selectCycleIndex==s?"select":"")),c:s,d:t.o((t=>o.clickRankCycleListItem(s)),s)}))),D:3==i.selectCycleIndex},3==i.selectCycleIndex?{E:t.t(i.selectStartDateStr),F:t.o((t=>o.clickCustomDateCycle(2))),G:t.t(i.selectEndDateStr),H:t.o((t=>o.clickCustomDateCycle(3))),I:t.o((t=>o.clickApply()))}:{},{J:t.f(i.rankTabList,((e,s,a)=>t.e({a:i.selectTab==s},i.selectTab==s?{b:e.selectIcon}:{c:e.icon},{d:t.t(e.title),e:t.n("item flex1 flexCenter "+(i.selectTab==s?"select":"")),f:s,g:t.o((t=>o.clickRankTabItem(s)),s)}))),K:t.f(i.rankList,((e,s,c)=>t.e({a:0==s},0==s?{b:a._imports_8}:{},{c:1==s},1==s?{d:a._imports_9$1}:{},{e:2==s},2==s?{f:a._imports_10$1}:{},{g:s>2},s>2?{h:t.t(s+1)}:{},{i:t.t(e.name),j:t.o((t=>o.clickConceptItem(e.name)),s)},3==i.selectTab||4==i.selectTab?t.e({k:3==i.selectTab},3==i.selectTab?{l:t.t(e.avg_change)}:{},{m:4==i.selectTab},4==i.selectTab?{n:t.t(e.total_change)}:{}):t.e({o:0==i.selectTab||1==i.selectTab},0==i.selectTab||1==i.selectTab?{p:a._imports_11$2,q:t.t(e.news_count)}:{},{r:a._imports_12$2,s:t.t(e.news_count),t:2==i.selectTab},2==i.selectTab?{v:a._imports_13$2,w:t.t(e.report_count)}:{}),0==i.selectTab?{x:t.t(e.change_pct)}:{},1==i.selectTab?{y:t.t(e.change_pct)}:{},2==i.selectTab?{z:t.t(e.total_mentions)}:{},3==i.selectTab?{A:t.t(e.volatility)}:{},4==i.selectTab?{B:t.t(e.consecutive_days)}:{},{C:s}))),L:3==i.selectTab||4==i.selectTab,M:t.n("icon "+(4==i.selectTab?"continuousRise":"")),N:i.rankTabList[i.selectTab].selectIcon,O:0==i.selectTab,P:1==i.selectTab,Q:2==i.selectTab,R:3==i.selectTab,S:4==i.selectTab,T:t.sr("rankPopup","66af7f00-1"),U:t.p({type:"bottom",safeArea:!1}),V:a._imports_12$1,W:t.f(i.sortTypeList,((e,s,a)=>({a:e.icon,b:t.t(e.name),c:s,d:t.o((t=>o.clickSortListItem(e)),s)}))),X:t.s("margin-top:"+i.sortListTop+"px;"),Y:t.sr("sortTypePopup","66af7f00-2"),Z:t.p({type:"top","mask-background-color":"transparent",animation:!1}),aa:t.o((t=>o.clickCancel())),ab:t.o((t=>o.clickConfirm())),ac:a._imports_4$1,ad:t.o((t=>o.clickPreMonth())),ae:t.t(i.selectMonth),af:t.o((()=>{})),ag:a._imports_1$2,ah:t.o((t=>o.clickNextMonth())),ai:t.f(i.weekList,((e,s,a)=>({a:t.t(e),b:s}))),aj:t.f(i.monthDateList[i.selectMonthIndex],((e,s,a)=>t.e({a:e.date==i.selectDateStr},e.date==i.selectDateStr?{b:t.t(e.day)}:t.e({c:!e.isCurrentMonth},e.isCurrentMonth?{e:t.t(e.day)}:{d:t.t(e.day)}),{f:s,g:t.o((t=>o.clickSelectDate(e)),s)}))),ak:t.f(i.quickTimeList,((e,s,a)=>({a:t.t(e),b:s,c:t.o((t=>o.clickQuickTimeItem(s)),s)}))),al:t.sr("transactionDatePopup","66af7f00-3"),am:t.p({type:"bottom",safeArea:!1}),an:a._imports_13,ao:a._imports_14,ap:a._imports_15,aq:a._imports_15,ar:a._imports_16,as:a._imports_16,at:a._imports_16,av:t.o((t=>o.clickLater())),aw:t.o((t=>o.clickUpgradeAtOnce())),ax:t.sr("vipPopup","66af7f00-4"),ay:t.p({type:"center"})})}]]);wx.createPage(n);