index.vue 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673
  1. <template>
  2. <div class="statistics-dashboard">
  3. <!-- 数据概览 (Data Overview) -->
  4. <el-card class="overview-section" shadow="never">
  5. <div slot="header" class="header">
  6. <span>数据概览</span>
  7. </div>
  8. <el-row :gutter="20">
  9. <el-col :span="3">
  10. <div class="data-card">
  11. <div class="card-title">
  12. <i class="el-icon-user-solid"></i>
  13. 分公司数量
  14. </div>
  15. <div class="card-value highlight">
  16. <count-to :start-val="0" :end-val="dealderCount" :duration="3600" class="card-panel-num" /></div>
  17. </div>
  18. </el-col>
  19. <el-col :span="3">
  20. <div class="data-card">
  21. <div class="card-title">
  22. <i class="el-icon-user"></i>
  23. 销售数量
  24. </div>
  25. <div class="card-value highlight">
  26. <count-to :start-val="0" :end-val="groupMgrCount" :duration="3600" class="card-panel-num" />
  27. </div>
  28. </div>
  29. </el-col>
  30. <el-col :span="3">
  31. <div class="data-card">
  32. <div class="card-title">
  33. <i class="el-icon-shopping-cart-full"></i>
  34. 会员数量
  35. </div>
  36. <div class="card-value highlight">
  37. <count-to :start-val="0" :end-val="memberCount" :duration="3600" class="card-panel-num" />
  38. <span class="highlight-today-add">+{{todayIncreaseUserNum}}</span>
  39. </div>
  40. <div class="card-badge">
  41. </div>
  42. </div>
  43. </el-col>
  44. <el-col :span="3">
  45. <div class="data-card">
  46. <div class="card-title">
  47. <i class="el-icon-shopping-cart-full"></i>
  48. 企微数量
  49. </div>
  50. <div class="card-value highlight">
  51. <count-to :start-val="0" :end-val="qwMemberNum" :duration="3600" class="card-panel-num" /></div>
  52. <div class="card-badge">
  53. </div>
  54. </div>
  55. </el-col>
  56. <el-col :span="3">
  57. <div class="data-card">
  58. <div class="card-title">
  59. <i class="el-icon-money"></i>
  60. 可用余额
  61. </div>
  62. <div class="card-value highlight">
  63. <count-to :start-val="0" :end-val="balance" :duration="3600" class="card-panel-num" />
  64. </div>
  65. </div>
  66. </el-col>
  67. <el-col :span="3">
  68. <div class="data-card">
  69. <div class="card-title">
  70. <span>今日消耗</span>
  71. </div>
  72. <div class="card-value highlight">
  73. <count-to :start-val="0" :end-val="todayComsumption" :duration="3600" class="card-panel-num" />
  74. </div>
  75. <div class="card-sub">
  76. <span>昨日消耗(元)</span>
  77. <span class="sub-value">
  78. <count-to :start-val="0" :end-val="yesterdayComsumption" :duration="3600" class="card-panel-num" />
  79. </span>
  80. </div>
  81. <el-progress :percentage="percentage" :show-text="false" color="#409EFF"></el-progress>
  82. <div class="card-desc">{{remainMessage}}</div>
  83. </div>
  84. </el-col>
  85. <el-col :span="3">
  86. <div class="data-card">
  87. <div class="card-title">
  88. <span class="cdn-label">CDN</span>
  89. 今日
  90. </div>
  91. <div class="card-value highlight">{{formatBytes(this.todayTraffic)}}
  92. </div>
  93. <div class="card-sub">
  94. <span>本月</span>
  95. <span class="sub-value">{{formatBytes(this.thisMonthTraffic)}}</span>
  96. </div>
  97. </div>
  98. </el-col>
  99. <el-col :span="3">
  100. <div class="data-card">
  101. <div class="card-title">
  102. <i class="el-icon-message"></i>
  103. 短信剩余条数
  104. </div>
  105. <div class="card-value highlight">
  106. <count-to :start-val="0" :end-val="smsRemainCount" :duration="3600" class="card-panel-num" />
  107. </div>
  108. </div>
  109. </el-col>
  110. <el-col :span="3">
  111. <div class="data-card">
  112. <div class="card-title">
  113. 平台今日看课人数
  114. </div>
  115. <div class="card-value highlight">
  116. <count-to :start-val="0" :end-val="todayWatchUserCount" :duration="3600" class="card-panel-num" />
  117. </div>
  118. <div class="card-sub">
  119. <span>配额上限</span>
  120. <span class="sub-value">
  121. <count-to :start-val="0" :end-val="todayWatchUserCount" :duration="3600" class="card-panel-num" />/<count-to :start-val="0" :end-val="versionLimit" :duration="3600" class="card-panel-num" /></span>
  122. </div>
  123. <el-progress :percentage="todayWatchUserCount/versionLimit" :show-text="false" color="#409EFF"></el-progress>
  124. </div>
  125. </el-col>
  126. <el-col :span="3">
  127. <div class="data-card">
  128. <div class="card-title">
  129. <i class="el-icon-shopping-cart-full"></i>
  130. 订单总数
  131. </div>
  132. <div class="card-value highlight">
  133. <count-to :start-val="0" :end-val="orderTotalNum" :duration="3600" class="card-panel-num" />
  134. <span class="highlight-today-add">+{{todayOrderNum}}</span>
  135. </div>
  136. <div class="card-badge">
  137. </div>
  138. </div>
  139. </el-col>
  140. <el-col :span="3">
  141. <div class="data-card">
  142. <div class="card-title">
  143. <i class="el-icon-shopping-cart-full"></i>
  144. 收款总数
  145. </div>
  146. <div class="card-value highlight">
  147. <count-to :start-val="0" :end-val="recvTotalNum" :duration="3600" class="card-panel-num" />
  148. <span class="highlight-today-add">+{{recvTodayNum}}</span>
  149. </div>
  150. <div class="card-badge">
  151. </div>
  152. </div>
  153. </el-col>
  154. <el-col :span="3">
  155. <div class="data-card">
  156. <div class="card-title">
  157. <i class="el-icon-shopping-cart-full"></i>
  158. 商品总数
  159. </div>
  160. <div class="card-value highlight">
  161. <count-to :start-val="0" :end-val="goodsTotalNum" :duration="3600" class="card-panel-num" />
  162. <span class="highlight-today-add">+{{todayGoodsNum}}</span>
  163. </div>
  164. <div class="card-badge">
  165. </div>
  166. </div>
  167. </el-col>
  168. </el-row>
  169. </el-card>
  170. <el-row :gutter="20" class="charts-section">
  171. <el-col :span="12">
  172. <el-card shadow="never">
  173. <div slot="header" class="chart-header">
  174. <span>本月订单数</span>
  175. <div class="legend">
  176. <div class="legend-item">
  177. <span class="dot viewer-dot"></span>
  178. <span>订单数</span>
  179. </div>
  180. <div class="legend-item">
  181. <span class="dot complete-dot"></span>
  182. <span>订单金额</span>
  183. </div>
  184. </div>
  185. </div>
  186. <div ref="viewerOrderChart" class="chart-container"></div>
  187. </el-card>
  188. </el-col>
  189. <el-col :span="12">
  190. <el-card shadow="never">
  191. <div slot="header" class="chart-header">
  192. <span>本月收款数</span>
  193. <div class="legend">
  194. <div class="legend-item">
  195. <span class="dot viewer-dot"></span>
  196. <span>收款数</span>
  197. </div>
  198. <div class="legend-item">
  199. <span class="dot complete-dot"></span>
  200. <span>收款金额</span>
  201. </div>
  202. </div>
  203. </div>
  204. <div ref="viewerReceiveChart" class="chart-container"></div>
  205. </el-card>
  206. </el-col>
  207. </el-row>
  208. <br/>
  209. <!-- 分析概览 (Analysis Overview) -->
  210. <div class="analysis-section" shadow="never">
  211. <div slot="header" class="header">
  212. <span>分析概览</span>
  213. <div class="tab-group">
  214. <el-radio-group v-model="queryTime" size="medium" @change="handleAnalysis">
  215. <el-radio-button label="今日"></el-radio-button>
  216. <el-radio-button label="昨日"></el-radio-button>
  217. <el-radio-button label="本周"></el-radio-button>
  218. <el-radio-button label="本月"></el-radio-button>
  219. <el-radio-button label="上月"></el-radio-button>
  220. </el-radio-group>
  221. </div>
  222. <div class="action-group">
  223. <el-radio-group v-model="userTypeText" @change="handleUserType">
  224. <el-radio-button label="个微"></el-radio-button>
  225. <el-radio-button label="企微"></el-radio-button>
  226. </el-radio-group>
  227. <el-dropdown @command="handleAutoRefresh" trigger="click">
  228. <el-button size="small" plain>
  229. 自动刷新
  230. <i class="el-icon-arrow-down el-icon--right"></i>
  231. </el-button>
  232. <el-dropdown-menu slot="dropdown">
  233. <el-dropdown-item :command="0" :class="{ 'is-active': !autoRefreshInterval }">关闭</el-dropdown-item>
  234. <el-dropdown-item :command="5" :class="{ 'is-active': autoRefreshInterval === 5 }">5分钟</el-dropdown-item>
  235. <el-dropdown-item :command="10" :class="{ 'is-active': autoRefreshInterval === 10 }">10分钟</el-dropdown-item>
  236. <el-dropdown-item :command="15" :class="{ 'is-active': autoRefreshInterval === 15 }">15分钟</el-dropdown-item>
  237. </el-dropdown-menu>
  238. </el-dropdown>
  239. <el-button size="small" plain icon="el-icon-refresh" type="primary" @click="manualRefresh">手动刷新</el-button>
  240. <!-- <el-button size="small" type="primary" @click="refresh">刷新</el-button>-->
  241. </div>
  242. </div>
  243. </div>
  244. <div>
  245. <el-row :gutter="20">
  246. <el-col :span="12" style="position: relative">
  247. <div class="analysis-card-check" :class="selectedDiv===0?'analysis-card-check-selected color':''" @click="handleToggleDiv(0)">
  248. <div class="analysis-card">
  249. <div class="card-icon"><i class="el-icon-monitor"></i></div>
  250. <div class="card-content">
  251. <div class="card-row">
  252. <span>观看人数</span>
  253. <span class="highlight">
  254. <count-to :start-val="0" :end-val="watchUserCount" :duration="3600" class="card-panel-num" />
  255. </span>
  256. </div>
  257. <div class="card-row">
  258. <span>完播人数</span>
  259. <span class="highlight">
  260. <count-to :start-val="0" :end-val="completedUserCount" :duration="3600" class="card-panel-num" />
  261. </span>
  262. </div>
  263. <div class="card-row">
  264. <span>完播率</span>
  265. <span class="highlight">{{completedRate}}%</span>
  266. </div>
  267. </div>
  268. </div>
  269. <div class="analysis-card">
  270. <div class="card-icon"><i class="el-icon-video-play"></i></div>
  271. <div class="card-content">
  272. <div class="card-row">
  273. <span>观看次数</span>
  274. <span class="highlight">
  275. <count-to :start-val="0" :end-val="watchCount" :duration="3600" class="card-panel-num" /></span>
  276. </div>
  277. <div class="card-row">
  278. <span>完播次数</span>
  279. <span class="highlight">
  280. <count-to :start-val="0" :end-val="completedCount" :duration="3600" class="card-panel-num" />
  281. </span>
  282. </div>
  283. <div class="card-row">
  284. <span>视频完播率</span>
  285. <span class="highlight">{{watchRate}}%</span>
  286. </div>
  287. </div>
  288. </div>
  289. </div>
  290. </el-col>
  291. <el-col :span="6" style="position: relative">
  292. <div class="analysis-card-check" :class="selectedDiv===1?'analysis-card-check-selected color':''" @click="handleToggleDiv(1)">
  293. <div class="analysis-card">
  294. <div class="card-icon"><i class="el-icon-headset"></i></div>
  295. <div class="card-content">
  296. <div class="card-row">
  297. <span>答题人数</span>
  298. <span class="highlight">
  299. <count-to :start-val="0" :end-val="answerMemberCount" :duration="3600" class="card-panel-num" />
  300. </span>
  301. </div>
  302. <div class="card-row">
  303. <span>正确人数</span>
  304. <span class="highlight">
  305. <count-to :start-val="0" :end-val="correctUserCount" :duration="3600" class="card-panel-num" />
  306. </span>
  307. </div>
  308. <div class="card-row">
  309. <span>正确率</span>
  310. <span class="highlight">{{correctRate}}%</span>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. </el-col>
  316. <el-col :span="6" style="position: relative">
  317. <div class="analysis-card-check" :class="selectedDiv===2?'analysis-card-check-selected color':''" @click="handleToggleDiv(2)">
  318. <div class="analysis-card">
  319. <div class="card-icon"><i class="el-icon-present"></i></div>
  320. <div class="card-content">
  321. <div class="card-row">
  322. <span>答题红包个数</span>
  323. <span class="highlight">
  324. <count-to :start-val="0" :end-val="rewardCount" :duration="3600" class="card-panel-num" />
  325. </span>
  326. </div>
  327. <div class="card-row">
  328. <span>答题红包金额(元)</span>
  329. <span class="highlight">
  330. <count-to :start-val="0" :end-val="rewardMoney" :duration="3600" class="card-panel-num" /></span>
  331. </div>
  332. </div>
  333. </div>
  334. </div>
  335. </el-col>
  336. </el-row>
  337. </div>
  338. <!-- 图表区域 (Charts Area) -->
  339. <transition name="fade">
  340. <el-row :gutter="20" class="charts-section" v-show="selectedDiv===0">
  341. <el-col :span="12">
  342. <el-card shadow="never">
  343. <div slot="header" class="chart-header">
  344. <span>会员观看、完播人数趋势图</span>
  345. <div class="legend">
  346. <div class="legend-item">
  347. <span class="dot viewer-dot"></span>
  348. <span>观看人数</span>
  349. </div>
  350. <div class="legend-item">
  351. <span class="dot complete-dot"></span>
  352. <span>完播人数</span>
  353. </div>
  354. </div>
  355. <el-button size="small" plain class="view-more">平台每日统计 <i class="el-icon-arrow-right"></i></el-button>
  356. </div>
  357. <div ref="viewerChart" class="chart-container"></div>
  358. </el-card>
  359. </el-col>
  360. <el-col :span="12">
  361. <el-card shadow="never">
  362. <div slot="header" class="chart-header">
  363. <span>经销商会员观看TOP10</span>
  364. <div class="legend">
  365. <el-radio-group v-model="viewerType" size="small" @change="handleDealerChartData">
  366. <el-radio-button label="0">按观看人数</el-radio-button>
  367. <el-radio-button label="1">按完播人数</el-radio-button>
  368. </el-radio-group>
  369. </div>
  370. <el-button size="small" plain class="view-more">经销商统计 <i class="el-icon-arrow-right"></i></el-button>
  371. </div>
  372. <div ref="dealerChart" class="chart-container"></div>
  373. </el-card>
  374. </el-col>
  375. </el-row>
  376. </transition>
  377. <transition name="fade">
  378. <el-row :gutter="20" class="charts-section" v-show="selectedDiv===1">
  379. <el-card shadow="never">
  380. <div slot="header" class="chart-header">
  381. <span>课程观看TOP10</span>
  382. <div class="legend">
  383. <el-radio-group v-model="viewerType" size="small" @change="handleCourseWatchChart">
  384. <el-radio-button label="0">按观看人数</el-radio-button>
  385. <el-radio-button label="1">按完播人数</el-radio-button>
  386. <el-radio-button label="2">按答题人数</el-radio-button>
  387. <el-radio-button label="3">按正确人数</el-radio-button>
  388. </el-radio-group>
  389. </div>
  390. <div class="legend">
  391. <el-radio-group v-model="delerSort" @change="handleCourseWatchChart">
  392. <el-radio label="DESC">前10名</el-radio>
  393. <el-radio label="ASC">倒数10名</el-radio>
  394. </el-radio-group>
  395. </div>
  396. <div class="legend">
  397. <div class="legend-item">
  398. <span class="dot viewer-dot"></span>
  399. <span>观看人数</span>
  400. </div>
  401. <div class="legend-item">
  402. <span class="dot complete-dot"></span>
  403. <span>完播人数</span>
  404. </div>
  405. <div class="legend-item">
  406. <span class="dot" style="background-color: #E6A23C"></span>
  407. <span>答题人数</span>
  408. </div>
  409. <div class="legend-item">
  410. <span class="dot" style="background-color: #F56C6C"></span>
  411. <span>正确人数</span>
  412. </div>
  413. </div>
  414. <el-button size="small" plain class="view-more">经销商统计 <i class="el-icon-arrow-right"></i></el-button>
  415. </div>
  416. <div ref="courseWatchChart" class="chart-container"></div>
  417. </el-card>
  418. </el-row>
  419. </transition>
  420. <transition name="fade">
  421. <el-row :gutter="20" class="charts-section" v-show="selectedDiv===2">
  422. <el-col :span="12">
  423. <el-card shadow="never">
  424. <div slot="header" class="chart-header">
  425. <span>答题红包金额TOP10</span>
  426. <div class="legend">
  427. <el-radio-group v-model="dataType" size="small" @change="handleAnswerRedPackViewerChart">
  428. <el-radio-button label="0">按经销商排行</el-radio-button>
  429. <el-radio-button label="1">按课程排行</el-radio-button>
  430. </el-radio-group>
  431. </div>
  432. <el-button size="small" plain class="view-more">红包记录 <i class="el-icon-arrow-right"></i></el-button>
  433. </div>
  434. <div ref="answerRedPackViewerChart" class="chart-container"></div>
  435. </el-card>
  436. </el-col>
  437. <el-col :span="12">
  438. <el-card shadow="never">
  439. <div slot="header" class="chart-header">
  440. <span>答题红包金额趋势图</span>
  441. <div class="legend">
  442. <div class="legend-item">
  443. <span class="dot viewer-dot"></span>
  444. <span>答题红包金额</span>
  445. </div>
  446. </div>
  447. <el-button size="small" plain class="view-more">红包记录 <i class="el-icon-arrow-right"></i></el-button>
  448. </div>
  449. <div ref="answerRedPackMoneyViewerChart" class="chart-container"></div>
  450. </el-card>
  451. </el-col>
  452. </el-row>
  453. </transition>
  454. </div>
  455. </template>
  456. <script>
  457. import * as echarts from 'echarts'
  458. import CountTo from "vue-count-to";
  459. import {
  460. analysisPreview,
  461. authorizationInfo,
  462. dealerAggregated, deaMemberTopTen, rechargeComsumption, rewardMoneyTopTen, rewardMoneyTrend,
  463. smsBalance, thisMonthOrderCount, thisMonthRecvCount, trafficLog,
  464. watchCourseTopTen, watchEndPlayTrend
  465. } from "@/api/statistics/statistics";
  466. import dayjs from 'dayjs';
  467. const viewCharOption = {
  468. tooltip: {
  469. trigger: 'axis',
  470. axisPointer: {
  471. type: 'shadow'
  472. }
  473. },
  474. grid: {
  475. left: '3%',
  476. right: '4%',
  477. bottom: '3%',
  478. containLabel: true
  479. },
  480. xAxis: {
  481. type: 'category',
  482. data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23']
  483. },
  484. yAxis: {
  485. type: 'value'
  486. },
  487. series: [
  488. {
  489. name: '观看人数',
  490. type: 'bar',
  491. data: [],
  492. itemStyle: {
  493. color: '#409EFF'
  494. }
  495. },
  496. {
  497. name: '完播人数',
  498. type: 'bar',
  499. data: [],
  500. itemStyle: {
  501. color: '#67C23A'
  502. }
  503. }
  504. ]
  505. }
  506. const thisMonthOrderCountOption = {
  507. tooltip: {
  508. trigger: 'axis',
  509. axisPointer: {
  510. type: 'shadow'
  511. }
  512. },
  513. grid: {
  514. left: '3%',
  515. right: '4%',
  516. bottom: '3%',
  517. containLabel: true
  518. },
  519. xAxis: {
  520. type: 'category',
  521. data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23']
  522. },
  523. yAxis: {
  524. type: 'value'
  525. },
  526. series: [
  527. {
  528. name: '订单数',
  529. type: 'line',
  530. data: [],
  531. itemStyle: {
  532. color: '#409EFF'
  533. }
  534. },
  535. {
  536. name: '订单金额',
  537. type: 'line',
  538. data: [],
  539. itemStyle: {
  540. color: '#67C23A'
  541. }
  542. }
  543. ]
  544. }
  545. const thisMonthRecvCountOption = {
  546. tooltip: {
  547. trigger: 'axis',
  548. axisPointer: {
  549. type: 'shadow'
  550. }
  551. },
  552. grid: {
  553. left: '3%',
  554. right: '4%',
  555. bottom: '3%',
  556. containLabel: true
  557. },
  558. xAxis: {
  559. type: 'category',
  560. data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23']
  561. },
  562. yAxis: {
  563. type: 'value'
  564. },
  565. series: [
  566. {
  567. name: '收款数',
  568. type: 'line',
  569. data: [],
  570. itemStyle: {
  571. color: '#409EFF'
  572. }
  573. },
  574. {
  575. name: '收款金额',
  576. type: 'line',
  577. data: [],
  578. itemStyle: {
  579. color: '#67C23A'
  580. }
  581. }
  582. ]
  583. }
  584. const dealerOption = {
  585. tooltip: {
  586. trigger: 'axis',
  587. axisPointer: {
  588. type: 'shadow'
  589. }
  590. },
  591. grid: {
  592. left: '3%',
  593. right: '4%',
  594. bottom: '3%',
  595. containLabel: true
  596. },
  597. xAxis: {
  598. type: 'value'
  599. },
  600. yAxis: {
  601. type: 'category',
  602. data: []
  603. },
  604. series: [
  605. {
  606. name: '观看人数',
  607. type: 'bar',
  608. data: [],
  609. itemStyle: {
  610. color: '#409EFF'
  611. }
  612. }
  613. ]
  614. }
  615. const courseWatchOption = {
  616. tooltip: {
  617. trigger: 'axis',
  618. axisPointer: {
  619. type: 'shadow'
  620. }
  621. },
  622. grid: {
  623. left: '3%',
  624. right: '4%',
  625. bottom: '8%',
  626. top: '3%',
  627. containLabel: true
  628. },
  629. xAxis: {
  630. type: 'category',
  631. data: [],
  632. axisLabel: {
  633. interval: 0,
  634. rotate: 30,
  635. fontSize: 10,
  636. width: 100,
  637. overflow: 'truncate'
  638. }
  639. },
  640. yAxis: {
  641. type: 'value',
  642. splitLine: {
  643. lineStyle: {
  644. type: 'dashed'
  645. }
  646. }
  647. },
  648. series: [
  649. {
  650. name: '观看人数',
  651. type: 'bar',
  652. data: [],
  653. itemStyle: {
  654. color: '#409EFF'
  655. }
  656. },
  657. {
  658. name: '完播人数',
  659. type: 'bar',
  660. data: [],
  661. itemStyle: {
  662. color: '#67C23A'
  663. }
  664. },
  665. {
  666. name: '答题人数',
  667. type: 'bar',
  668. data: [],
  669. itemStyle: {
  670. color: '#E6A23C'
  671. }
  672. },
  673. {
  674. name: '正确人数',
  675. type: 'bar',
  676. data: [],
  677. itemStyle: {
  678. color: '#F56C6C'
  679. }
  680. }
  681. ]
  682. }
  683. const lineChartOption = {
  684. tooltip: {
  685. trigger: 'axis',
  686. axisPointer: {
  687. type: 'cross' // 改为 'cross' 更适合折线图
  688. }
  689. },
  690. grid: {
  691. left: '3%',
  692. right: '4%',
  693. bottom: '8%', // 如果x轴标签旋转,可能需要更大的 bottom
  694. top: '5%', // 增加一点顶部空间给可能的 Y 轴名称
  695. containLabel: true
  696. },
  697. xAxis: {
  698. type: 'time', // X轴类型改为 'time'
  699. // data: [], // 时间轴不需要单独设置 data,数据在 series 中提供
  700. axisLabel: {
  701. // interval: 0, // 时间轴通常自动处理间隔,可以先移除或注释掉
  702. rotate: 30, // 保留旋转,如果标签可能重叠
  703. fontSize: 10,
  704. // width: 100, // width 和 overflow 对于时间轴可能行为不同,按需调整
  705. // overflow: 'truncate',
  706. formatter: null // ECharts 会自动格式化时间,如需特定格式可用 function 或字符串模板
  707. }
  708. },
  709. yAxis: {
  710. type: 'value',
  711. name: '金额 (元)', // 添加 Y 轴名称
  712. nameLocation: 'end', // 名称位置
  713. nameTextStyle: {
  714. align: 'right',
  715. padding: [0, 10, 0, 0] // 调整名称与轴线的距离
  716. },
  717. splitLine: {
  718. lineStyle: {
  719. type: 'dashed'
  720. }
  721. },
  722. axisLabel: {
  723. formatter: '{value} 元' // 可选:给 Y 轴刻度添加单位
  724. }
  725. },
  726. series: [
  727. {
  728. name: '答题红包金额',
  729. type: 'line', // 系列类型改为 'line'
  730. data: [
  731. ],
  732. itemStyle: { // 控制数据点(标记)的样式
  733. color: '#409EFF'
  734. },
  735. lineStyle: { // 控制线的样式
  736. color: '#409EFF'
  737. },
  738. smooth: false, // 是否平滑曲线,可设为 true
  739. symbol: 'circle', // 数据点标记形状,'emptyCircle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow', 'none'
  740. symbolSize: 4 // 数据点标记大小
  741. }
  742. ]
  743. };
  744. const redPackageOption = {
  745. tooltip: {
  746. trigger: 'axis',
  747. axisPointer: {
  748. type: 'shadow'
  749. }
  750. },
  751. grid: {
  752. left: '3%',
  753. right: '4%',
  754. bottom: '8%',
  755. top: '3%',
  756. containLabel: true
  757. },
  758. xAxis: {
  759. type: 'category',
  760. data: [],
  761. axisLabel: {
  762. interval: 0,
  763. rotate: 30,
  764. fontSize: 10,
  765. width: 100,
  766. overflow: 'truncate'
  767. }
  768. },
  769. yAxis: {
  770. type: 'value',
  771. splitLine: {
  772. lineStyle: {
  773. type: 'dashed'
  774. }
  775. }
  776. },
  777. series: [
  778. {
  779. name: '答题红包金额',
  780. type: 'bar',
  781. data: [],
  782. itemStyle: {
  783. color: '#409EFF'
  784. }
  785. }
  786. ]
  787. }
  788. export default {
  789. name: 'StatisticsDashboard',
  790. components: {CountTo},
  791. data() {
  792. return {
  793. percentage: 0,
  794. // 预测message
  795. remainMessage: '',
  796. // 当天使用流量
  797. todayTraffic: 0,
  798. // 当月使用流量
  799. thisMonthTraffic: 0,
  800. dataType: '0',
  801. delerSort: 'DESC',
  802. smsRemainCount: 0,
  803. viewerType: '0',
  804. viewerChart: null,
  805. userTypeText: '个微',
  806. userType: 1,
  807. dealerChart: null,
  808. // 分公司数量
  809. dealderCount: 0,
  810. // 销售数量
  811. groupMgrCount: 0,
  812. // 会员总数量
  813. memberCount: 0,
  814. // 企微数量
  815. qwMemberNum: 0,
  816. // 正常会员数量
  817. normalNum: 0,
  818. // 黑名单会员数量
  819. blackNum: 0,
  820. // 观看人数
  821. watchUserCount: 0,
  822. // 完播人数
  823. completedUserCount: 0,
  824. // 完播率
  825. completedRate: 0,
  826. // 观看次数
  827. watchCount:0,
  828. // 完播次数
  829. completedCount: 0,
  830. // 视频完播率
  831. watchRate: 0,
  832. // 答题人数
  833. answerMemberCount: 0,
  834. // 正确人数
  835. correctUserCount: 0,
  836. correctRate: 0.0,
  837. // 答题红包个数
  838. rewardCount: 0,
  839. // 答题红包金额
  840. rewardMoney: 0.0,
  841. queryTime: '今日',
  842. todayWatchUserCount: 0,
  843. versionLimit: 0,
  844. /// 选中的分析概览
  845. selectedDiv: 0,
  846. filterType: 0,
  847. answerRedPackViewerChart: null,
  848. answerRedPackMoneyViewerChart: null,
  849. todayComsumption: 0,
  850. yesterdayComsumption: 0,
  851. balance: 0,
  852. autoRefreshInterval: null,
  853. // 今日新增用户数
  854. todayIncreaseUserNum: 0,
  855. // 订单总数
  856. orderTotalNum: 0,
  857. // 今日新增订单数
  858. todayOrderNum: 0,
  859. // 收款总数
  860. recvTotalNum: 0,
  861. // 今日收款总数
  862. recvTodayNum: 0,
  863. // 商品总数
  864. goodsTotalNum: 0,
  865. // 今日商品总数
  866. todayGoodsNum: 0
  867. }
  868. },
  869. mounted() {
  870. this.$nextTick(() => {
  871. this.initViewerChart()
  872. this.initDealerChart()
  873. this.initCourseWatchChart();
  874. this.initAnswerRedPackViewerChart();
  875. this.initAnswerRedPackMoneyViewerChart();
  876. this.initThisMonthOrderChart();
  877. this.initThisMonthRecvChart()
  878. // 监听窗口大小变化,重新渲染图表
  879. window.addEventListener('resize', () => {
  880. this.viewerChart && this.viewerChart.resize()
  881. this.dealerChart && this.dealerChart.resize()
  882. })
  883. })
  884. },
  885. created() {
  886. this.refresh();
  887. },
  888. methods: {
  889. handleUserType(){
  890. if(this.userTypeText === '个微'){
  891. this.userType = 1
  892. }else{
  893. this.userType = 2
  894. }
  895. this.refresh()
  896. },
  897. /**
  898. * 计算余额预计可持续的天数
  899. * @param {number} balance - 当前账户余额
  900. * @param {number} todayConsumption - 今日消耗金额
  901. * @param {number} yesterdayConsumption - 昨日消耗金额
  902. * @return {Object} 包含天数和进度百分比的对象
  903. */
  904. calculateRemainingDays(balance, todayConsumption, yesterdayConsumption) {
  905. // 如果今日和昨日消耗都为0,则无法预测(避免除以0)
  906. if (todayConsumption === 0 && yesterdayConsumption === 0) {
  907. return {
  908. days: Infinity,
  909. percentage: 0,
  910. message: '暂无消耗数据'
  911. };
  912. }
  913. // 计算每日平均消耗量
  914. const avgDailyConsumption = (todayConsumption + yesterdayConsumption) / 2;
  915. // 如果平均消耗为0,则无法预测
  916. if (avgDailyConsumption === 0) {
  917. return {
  918. days: Infinity,
  919. percentage: 0,
  920. message: '暂无消耗数据'
  921. };
  922. }
  923. // 计算剩余天数(向下取整)
  924. const remainingDays = Math.floor(balance / avgDailyConsumption);
  925. // 计算进度条百分比,最大为100
  926. // 这里假设100天是满值,可以根据需要调整
  927. const maxDays = 100;
  928. const percentage = Math.min(100, Math.max(0, Math.round((remainingDays / maxDays) * 100)));
  929. let message = '';
  930. if (remainingDays > 365) {
  931. message = '预测余额充足';
  932. } else {
  933. message = `预测不足${remainingDays}天`;
  934. }
  935. return {
  936. days: remainingDays,
  937. percentage: 100 - percentage,
  938. message: message
  939. };
  940. },
  941. /**
  942. * 将字节数转换为合适的单位表示(Byte、KB、MB、GB、TB)
  943. * @param {number} bytes - 字节数
  944. * @param {number} [decimals=2] - 小数点后保留的位数
  945. * @returns {string} 格式化后的字符串,包含数值和单位
  946. */
  947. formatBytes(bytes, decimals = 2) {
  948. if (bytes === 0) return '0 Byte';
  949. const k = 1024;
  950. const sizes = ['Byte', 'KB', 'MB', 'GB', 'TB'];
  951. // 计算合适的单位级别
  952. const i = Math.floor(Math.log(bytes) / Math.log(k));
  953. // 转换为对应单位的值
  954. const value = bytes / Math.pow(k, i);
  955. // 格式化为指定小数位的字符串
  956. return parseFloat(value.toFixed(decimals)) + ' ' + sizes[Math.min(i, sizes.length - 1)];
  957. },
  958. // 手动刷新
  959. manualRefresh() {
  960. this.refresh();
  961. },
  962. // 处理自动刷新选项
  963. handleAutoRefresh(command) {
  964. // 清除之前的定时器
  965. if (this.timer) {
  966. clearInterval(this.timer);
  967. this.timer = null;
  968. }
  969. // 设置新的刷新间隔
  970. this.autoRefreshInterval = parseInt(command);
  971. // 如果间隔大于0,设置新的定时器
  972. if (this.autoRefreshInterval > 0) {
  973. this.timer = setInterval(() => {
  974. this.refresh();
  975. }, this.autoRefreshInterval * 60 * 1000); // 转换为毫秒
  976. this.$message.success(`已设置${this.autoRefreshInterval}分钟自动刷新`);
  977. } else {
  978. this.$message.info('已关闭自动刷新');
  979. }
  980. },
  981. refresh() {
  982. rechargeComsumption().then(res=>{
  983. if(res.code === 200){
  984. this.balance = res.data.balance;
  985. this.todayComsumption = res.data.todayComsumption;
  986. this.yesterdayComsumption = res.data.yesterdayComsumption;
  987. let calculateRemainingDays1 = this.calculateRemainingDays(this.balance,this.todayComsumption,this.yesterdayComsumption);
  988. this.percentage = calculateRemainingDays1.percentage;
  989. this.remainMessage = calculateRemainingDays1.message;
  990. }
  991. });
  992. trafficLog().then(res=>{
  993. if(res.code === 200) {
  994. this.todayTraffic = res.data.today;
  995. this.thisMonthTraffic = res.data.thisMonth;
  996. }
  997. })
  998. dealerAggregated().then(res=>{
  999. if(res.code === 200){
  1000. this.dealderCount = res.data.dealderCount??0;
  1001. this.groupMgrCount = res.data.groupMgrCount??0;
  1002. this.memberCount = res.data.memberCount??0;
  1003. this.qwMemberNum = res.data.qwMemberNum??0;
  1004. this.normalNum = res.data.normalNum??0;
  1005. this.blackNum = res.data.blackNum??0;
  1006. this.todayIncreaseUserNum = res.data.todayIncreaseUserNum??0;
  1007. this.orderTotalNum = res.data.orderTotalNum??0;
  1008. this.todayOrderNum = res.data.todayOrderNum??0;
  1009. this.recvTotalNum = res.data.recvTotalNum??0;
  1010. this.recvTodayNum = res.data.recvTodayNum??0;
  1011. this.goodsTotalNum = res.data.goodsTotalNum??0;
  1012. this.todayGoodsNum = res.data.todayGoodsNum??0;
  1013. }
  1014. })
  1015. let param = this.getParam();
  1016. // 获取当前日期时间
  1017. const today = dayjs();
  1018. param.startTime = this.formatDate(today);
  1019. param.endTime = this.formatDate(today);
  1020. analysisPreview(param).then(res=>{
  1021. if(res.code === 200){
  1022. this.watchUserCount = res.data.watchUserCount;
  1023. this.completedUserCount = res.data.completedUserCount;
  1024. this.completedRate = res.data.completedRate;
  1025. this.watchCount = res.data.watchCount;
  1026. this.completedCount = res.data.completedCount;
  1027. this.answerMemberCount = res.data.answerMemberCount;
  1028. this.correctUserCount = res.data.correctUserCount;
  1029. this.correctRate = res.data.correctRate;
  1030. this.rewardCount = res.data.rewardCount;
  1031. this.rewardMoney = res.data.rewardMoney;
  1032. this.watchRate = res.data.watchRate;
  1033. }
  1034. })
  1035. smsBalance().then(res=>{
  1036. if(res.code === 200){
  1037. if(res.data == null) {
  1038. this.smsRemainCount = 0;
  1039. } else {
  1040. this.smsRemainCount = res.data;
  1041. }
  1042. }
  1043. })
  1044. authorizationInfo().then(res=>{
  1045. if(res.code === 200){
  1046. this.todayWatchUserCount = res.data.todayWatchUserCount;
  1047. this.versionLimit = res.data.versionLimit;
  1048. }
  1049. })
  1050. this.handleCourseWatchChart()
  1051. this.handleViewChartData()
  1052. // 经销商会员观看TOP10
  1053. this.handleDealerChartData()
  1054. this.handleAnswerRedPackViewerChart()
  1055. this.handleAnswerRedPackMoneyViewerChart()
  1056. this.handleThisMonthRecvCount();
  1057. this.handleThisMonthOrderCount();
  1058. },
  1059. /**
  1060. * 将数字添加千位分隔符
  1061. * @param {number|string} num - 需要格式化的数字
  1062. * @return {string} 添加千位分隔符后的字符串
  1063. */
  1064. formatNumberWithCommas(num) {
  1065. if (num === null || num === undefined || isNaN(Number(num))) {
  1066. return '0';
  1067. }
  1068. const numStr = String(num);
  1069. // 处理负数
  1070. const isNegative = numStr.startsWith('-');
  1071. const absNumStr = isNegative ? numStr.slice(1) : numStr;
  1072. // 分离整数部分和小数部分
  1073. const parts = absNumStr.split('.');
  1074. const integerPart = parts[0];
  1075. const decimalPart = parts.length > 1 ? '.' + parts[1] : '';
  1076. const formattedInteger = integerPart.replace(/\B(?=(\d{3})+(?!\d))/g, ',');
  1077. return (isNegative ? '-' : '') + formattedInteger + decimalPart;
  1078. },
  1079. handleToggleDiv(selected){
  1080. this.selectedDiv = selected;
  1081. if (selected === 1) {
  1082. this.$nextTick(() => {
  1083. if (this.courseWatchChart) {
  1084. this.courseWatchChart.resize();
  1085. } else {
  1086. }
  1087. });
  1088. }
  1089. else if (selected === 0) {
  1090. this.$nextTick(() => {
  1091. if (this.viewerChart) this.viewerChart.resize();
  1092. if (this.dealerChart) this.dealerChart.resize();
  1093. });
  1094. } else if (selected === 2) {
  1095. this.$nextTick(() => {
  1096. if (this.answerRedPackViewerChart) this.answerRedPackViewerChart.resize();
  1097. if (this.answerRedPackMoneyViewerChart) this.answerRedPackMoneyViewerChart.resize();
  1098. });
  1099. }
  1100. if(this.selectedDiv === 0){
  1101. this.handleViewChartData()
  1102. this.handleDealerChartData()
  1103. } else if(this.selectedDiv === 1) {
  1104. this.handleCourseWatchChart()
  1105. } else if(this.selectedDiv === 2) {
  1106. this.handleAnswerRedPackViewerChart()
  1107. this.handleAnswerRedPackMoneyViewerChart()
  1108. }
  1109. },
  1110. formatDate(date) {
  1111. return dayjs(date).format('YYYY-MM-DD');
  1112. },
  1113. getParam(){
  1114. let param = {
  1115. startTime: '',
  1116. endTime: '',
  1117. userType: this.userType
  1118. };
  1119. // 获取当前日期时间
  1120. const today = dayjs();
  1121. let type = 0;
  1122. if (this.queryTime === '今日') {
  1123. param.startTime = this.formatDate(today);
  1124. param.endTime = this.formatDate(today);
  1125. type = 0;
  1126. } else if (this.queryTime === '昨日') {
  1127. const yesterday = today.subtract(1, 'day');
  1128. param.startTime = this.formatDate(yesterday);
  1129. param.endTime = this.formatDate(yesterday);
  1130. type = 1;
  1131. } else if (this.queryTime === '本周') {
  1132. param.startTime = this.formatDate(today.startOf('week'));
  1133. param.endTime = this.formatDate(today.endOf('week'));
  1134. type = 2;
  1135. } else if (this.queryTime === '本月') {
  1136. param.startTime = this.formatDate(today.startOf('month'));
  1137. param.endTime = this.formatDate(today.endOf('month'));
  1138. type = 3;
  1139. } else if (this.queryTime === '上月') {
  1140. const lastMonth = today.subtract(1, 'month');
  1141. param.startTime = this.formatDate(lastMonth.startOf('month'));
  1142. param.endTime = this.formatDate(lastMonth.endOf('month'));
  1143. type = 4;
  1144. } else {
  1145. console.warn(`未知的 queryTime: ${this.queryTime}, 默认使用今日`);
  1146. param.startTime = this.formatDate(today);
  1147. param.endTime = this.formatDate(today);
  1148. }
  1149. param.type = type;
  1150. param.sort = this.delerSort;
  1151. return param;
  1152. },
  1153. // 分析概览
  1154. handleAnalysis(e){
  1155. let param = this.getParam();
  1156. analysisPreview(param).then(res=>{
  1157. if(res.code === 200){
  1158. this.watchUserCount = res.data.watchUserCount;
  1159. this.completedUserCount = res.data.completedUserCount;
  1160. this.completedRate = res.data.completedRate;
  1161. this.watchCount = res.data.watchCount;
  1162. this.completedCount = res.data.completedCount;
  1163. this.answerMemberCount = res.data.answerMemberCount;
  1164. this.correctUserCount = res.data.correctUserCount;
  1165. this.correctRate = res.data.correctRate;
  1166. this.rewardCount = res.data.rewardCount;
  1167. this.rewardMoney = res.data.rewardMoney;
  1168. this.watchRate = res.data.watchRate;
  1169. }
  1170. })
  1171. if(this.selectedDiv === 0){
  1172. this.handleViewChartData()
  1173. this.handleDealerChartData()
  1174. } else if(this.selectedDiv === 1) {
  1175. this.handleCourseWatchChart()
  1176. } else if(this.selectedDiv === 2) {
  1177. this.handleAnswerRedPackViewerChart()
  1178. this.handleAnswerRedPackMoneyViewerChart()
  1179. }
  1180. },
  1181. handleAnswerRedPackViewerChart(){
  1182. let param = this.getParam();
  1183. param = {...param,statisticalType:this.viewerType,dataType: this.dataType};
  1184. rewardMoneyTopTen(param).then(res=>{
  1185. if(res.code === 200){
  1186. let data = res.data;
  1187. let companyNameList = data.map(e=>e.companyName)
  1188. let courseNameList = data.map(e=>e.courseName)
  1189. let rewardMoneyList = data.map(e=>e.rewardMoney)
  1190. if(this.dataType === '0'){
  1191. redPackageOption.xAxis.data = companyNameList;
  1192. }else{
  1193. redPackageOption.xAxis.data = courseNameList;
  1194. }
  1195. redPackageOption.series[0].data = rewardMoneyList;
  1196. this.answerRedPackViewerChart.setOption(redPackageOption)
  1197. }
  1198. })
  1199. },
  1200. handleAnswerRedPackMoneyViewerChart(){
  1201. let param = this.getParam();
  1202. param = {...param,statisticalType:this.viewerType,dataType: this.dataType};
  1203. rewardMoneyTrend(param).then(res=>{
  1204. if(res.code === 200){
  1205. let data = res.data;
  1206. let option = data.map(e=>[e.x,e.rewardMoney])
  1207. lineChartOption.series[0].data = option;
  1208. this.answerRedPackMoneyViewerChart.setOption(lineChartOption)
  1209. }
  1210. })
  1211. },
  1212. handleCourseWatchChart() {
  1213. let param = this.getParam();
  1214. param = {...param,statisticalType:this.viewerType};
  1215. watchCourseTopTen(param).then(res=>{
  1216. if(res.code === 200){
  1217. let data = res.data;
  1218. let watchUserCountList = data.map(e=>e.watchUserCount);
  1219. let completedUserCountList = data.map(e=>e.completedUserCount);
  1220. let answerUserCountList = data.map(e=>e.answerUserCount);
  1221. let correctUserCountList = data.map(e=>e.correctUserCount);
  1222. let courseNameList = data.map(e=>e.courseName);
  1223. courseWatchOption.xAxis.data = courseNameList;
  1224. courseWatchOption.series[0].data = watchUserCountList;
  1225. courseWatchOption.series[1].data = completedUserCountList;
  1226. courseWatchOption.series[2].data = answerUserCountList;
  1227. courseWatchOption.series[3].data = correctUserCountList;
  1228. this.courseWatchChart.setOption(courseWatchOption)
  1229. }
  1230. })
  1231. },
  1232. handleDealerChartData(){
  1233. let param = this.getParam();
  1234. // 经销商会员观看TOP10
  1235. deaMemberTopTen({...param,statisticalType: this.viewerType}).then(res=>{
  1236. if(res.code === 200){
  1237. let data = res.data;
  1238. let companyNameList = data.map(e=>e.companyName);
  1239. let watchUserList = data.map(e=>e.watchUserCount);
  1240. dealerOption.yAxis.data = companyNameList;
  1241. dealerOption.series[0].data = watchUserList;
  1242. this.dealerChart.setOption(dealerOption)
  1243. }
  1244. })
  1245. },
  1246. handleThisMonthOrderCount(){
  1247. thisMonthOrderCount().then(res=>{
  1248. if(res.code === 200){
  1249. let dates = res.dates;
  1250. let orderCount = res.orderCount;
  1251. let payPrice = res.payPrice;
  1252. thisMonthOrderCountOption.series[0].data = orderCount;
  1253. thisMonthOrderCountOption.series[1].data = payPrice;
  1254. thisMonthOrderCountOption.xAxis.data = dates;
  1255. this.thisMonthOrderChart.setOption(thisMonthOrderCountOption)
  1256. }
  1257. })
  1258. },
  1259. handleThisMonthRecvCount(){
  1260. thisMonthRecvCount().then(res=>{
  1261. if(res.code === 200){
  1262. let dates = res.dates;
  1263. let orderCount = res.orderCount;
  1264. let payMoney = res.payMoney;
  1265. thisMonthRecvCountOption.series[0].data = orderCount;
  1266. thisMonthRecvCountOption.series[1].data = payMoney;
  1267. thisMonthRecvCountOption.xAxis.data = dates;
  1268. this.thisMonthRecvChart.setOption(thisMonthRecvCountOption)
  1269. }
  1270. })
  1271. },
  1272. handleViewChartData(){
  1273. let param = this.getParam();
  1274. watchEndPlayTrend({...param}).then(res=>{
  1275. if(res.code === 200){
  1276. let data = res.data;
  1277. let watchUserCountList = data.map(e=>e.watchUserCount);
  1278. let completedUserCountList = data.map(e=>e.completedUserCount);
  1279. let xAxis = data.map(e=>e.x);
  1280. viewCharOption.series[0].data = watchUserCountList;
  1281. viewCharOption.series[1].data = completedUserCountList;
  1282. viewCharOption.xAxis.data = xAxis;
  1283. this.viewerChart.setOption(viewCharOption);
  1284. }
  1285. })
  1286. },
  1287. initThisMonthOrderChart(){
  1288. this.thisMonthOrderChart = echarts.init(this.$refs.viewerOrderChart)
  1289. this.thisMonthOrderChart.setOption(thisMonthOrderCountOption)
  1290. },
  1291. initThisMonthRecvChart(){
  1292. this.thisMonthRecvChart = echarts.init(this.$refs.viewerReceiveChart)
  1293. this.thisMonthRecvChart.setOption(thisMonthOrderCountOption)
  1294. },
  1295. initViewerChart() {
  1296. this.viewerChart = echarts.init(this.$refs.viewerChart)
  1297. this.viewerChart.setOption(viewCharOption)
  1298. },
  1299. initDealerChart() {
  1300. this.dealerChart = echarts.init(this.$refs.dealerChart)
  1301. this.dealerChart.setOption(dealerOption)
  1302. },
  1303. initCourseWatchChart() {
  1304. this.courseWatchChart = echarts.init(this.$refs.courseWatchChart)
  1305. this.courseWatchChart.setOption(courseWatchOption)
  1306. },
  1307. initAnswerRedPackViewerChart(){
  1308. this.answerRedPackViewerChart = echarts.init(this.$refs.answerRedPackViewerChart)
  1309. this.answerRedPackViewerChart.setOption(redPackageOption)
  1310. },
  1311. initAnswerRedPackMoneyViewerChart(){
  1312. this.answerRedPackMoneyViewerChart = echarts.init(this.$refs.answerRedPackMoneyViewerChart)
  1313. this.answerRedPackMoneyViewerChart.setOption(lineChartOption)
  1314. }
  1315. },
  1316. beforeDestroy() {
  1317. // 组件销毁时清除定时器
  1318. if (this.timer) {
  1319. clearInterval(this.timer);
  1320. this.timer = null;
  1321. }
  1322. // window.removeEventListener('resize', this.resizeHandler)
  1323. this.viewerChart && this.viewerChart.dispose()
  1324. this.dealerChart && this.dealerChart.dispose()
  1325. }
  1326. }
  1327. </script>
  1328. <style scoped>
  1329. .highlight-today-add{
  1330. color:green;font-size:17px;font-weight: normal;
  1331. }
  1332. .action-group .el-button + .el-button,
  1333. .action-group .el-dropdown {
  1334. margin-left: 10px;
  1335. }
  1336. .is-active {
  1337. color: #409EFF;
  1338. font-weight: bold;
  1339. }
  1340. ::v-deep .el-radio-button__inner:hover {
  1341. color: #409EFF; /* 鼠标悬浮时的文字颜色,可以根据需要调整 */
  1342. }
  1343. ::v-deep .el-radio-button.is-active .el-radio-button__inner {
  1344. background-color: #409EFF; /* 选中时的背景色 */
  1345. border-color: #409EFF; /* 选中时的边框色 */
  1346. color: #FFFFFF; /* 选中时的文字颜色 (通常是白色) */
  1347. box-shadow: -1px 0 0 0 #409EFF; /* 处理按钮间的连接缝隙 */
  1348. }
  1349. /* 如果需要,也可以修改非选中状态下的聚焦(focus)或悬浮(hover)样式 */
  1350. /* 例如,让非选中按钮悬浮时边框和文字也变蓝 */
  1351. ::v-deep .el-radio-button:not(.is-active) .el-radio-button__inner:hover {
  1352. color: #409EFF;
  1353. /* border-color: #b3d8ff; Element UI 默认悬浮边框色,可以按需修改 */
  1354. }
  1355. /* 聚焦时的外框,如果需要的话 */
  1356. ::v-deep .el-radio-button:focus:not(.is-checked) .el-radio-button__inner {
  1357. /* border-color: #409EFF; */ /* Element UI 默认的 focus 颜色通常关联主题色 */
  1358. /* box-shadow: 0 0 2px 2px rgba(64, 158, 255, 0.2); */ /* 示例 focus 光晕 */
  1359. }
  1360. .statistics-dashboard {
  1361. padding: 20px;
  1362. background-color: #f5f7fa;
  1363. }
  1364. .overview-section,
  1365. .analysis-section {
  1366. margin-bottom: 20px;
  1367. border-radius: 4px;
  1368. }
  1369. .header {
  1370. display: flex;
  1371. justify-content: space-between;
  1372. align-items: center;
  1373. font-size: 16px;
  1374. font-weight: 500;
  1375. }
  1376. .data-card {
  1377. background-color: #fff;
  1378. border-radius: 4px;
  1379. padding: 15px;
  1380. height: 100px;
  1381. display: flex;
  1382. flex-direction: column;
  1383. position: relative;
  1384. transition: background-color 0.3s ease-in-out;
  1385. }
  1386. .data-card:hover{
  1387. border: 1px solid #4592ff;
  1388. background-color: #e7f1ff;
  1389. }
  1390. .card-title {
  1391. color: #606266;
  1392. font-size: 14px;
  1393. margin-bottom: 10px;
  1394. }
  1395. .card-value {
  1396. font-size: 24px;
  1397. font-weight: bold;
  1398. margin-top: auto;
  1399. }
  1400. .highlight {
  1401. color: #409EFF;
  1402. }
  1403. .card-sub {
  1404. display: flex;
  1405. justify-content: space-between;
  1406. font-size: 12px;
  1407. color: #909399;
  1408. margin-top: 5px;
  1409. }
  1410. .card-desc {
  1411. font-size: 12px;
  1412. color: #909399;
  1413. margin-top: 5px;
  1414. }
  1415. .card-badge {
  1416. position: absolute;
  1417. top: 15px;
  1418. right: 15px;
  1419. background: #f0f9eb;
  1420. color: #67c23a;
  1421. padding: 2px 5px;
  1422. border-radius: 4px;
  1423. }
  1424. .cdn-label {
  1425. background-color: #409EFF;
  1426. color: white;
  1427. padding: 2px 5px;
  1428. border-radius: 4px;
  1429. margin-right: 5px;
  1430. font-size: 12px;
  1431. }
  1432. .tab-group {
  1433. display: flex;
  1434. gap: 10px;
  1435. }
  1436. .action-group {
  1437. display: flex;
  1438. gap: 10px;
  1439. }
  1440. .analysis-card {
  1441. border-radius: 4px;
  1442. padding: 20px;
  1443. display: flex;
  1444. align-items: center;
  1445. }
  1446. .card-icon {
  1447. width: 50px;
  1448. height: 50px;
  1449. background-color: rgba(64, 158, 255, 0.1);
  1450. border-radius: 8px;
  1451. display: flex;
  1452. justify-content: center;
  1453. align-items: center;
  1454. font-size: 24px;
  1455. color: #409EFF;
  1456. margin-right: 20px;
  1457. }
  1458. .card-content {
  1459. display: flex;
  1460. }
  1461. .card-row {
  1462. display: flex;
  1463. justify-content: center;
  1464. justify-items: center;
  1465. flex-direction: column;
  1466. padding: 10px;
  1467. .highlight{
  1468. text-align: center;
  1469. margin-top: 1em;
  1470. font-family: BebasNeue;
  1471. color: #1677ff;
  1472. font-size: 26px;
  1473. line-height: 42px;
  1474. font-weight: 400;
  1475. margin-top: 8px;
  1476. }
  1477. font-size: 15px;
  1478. color: #000;
  1479. }
  1480. .charts-section {
  1481. margin-top: 20px;
  1482. }
  1483. .chart-header {
  1484. display: flex;
  1485. justify-content: space-between;
  1486. align-items: center;
  1487. }
  1488. .view-more {
  1489. font-size: 12px;
  1490. }
  1491. .legend {
  1492. display: flex;
  1493. gap: 15px;
  1494. }
  1495. .legend-item {
  1496. display: flex;
  1497. align-items: center;
  1498. font-size: 12px;
  1499. }
  1500. .dot {
  1501. width: 10px;
  1502. height: 10px;
  1503. border-radius: 50%;
  1504. margin-right: 5px;
  1505. }
  1506. .viewer-dot {
  1507. background-color: #409EFF;
  1508. }
  1509. .complete-dot {
  1510. background-color: #67C23A;
  1511. }
  1512. .chart-container {
  1513. height: 350px;
  1514. width: 100%;
  1515. }
  1516. .analysis-card-check{
  1517. display: flex;
  1518. flex-direction: row;
  1519. border: 1px solid transparent;
  1520. background-color: #fff;
  1521. border-radius: 4px;
  1522. }
  1523. .analysis-card-check:hover{
  1524. cursor: pointer;
  1525. }
  1526. .analysis-card-check-selected:after{
  1527. content: "";
  1528. display: block;
  1529. border-width: 15px;
  1530. position: absolute;
  1531. bottom: -30px;
  1532. left: 50%;
  1533. margin-left: -32px;
  1534. border-style: solid dashed dashed solid;
  1535. border-color: #4592FF transparent transparent transparent;
  1536. font-size: 0;
  1537. line-height: 0;
  1538. z-index:1;
  1539. }
  1540. .analysis-card-check-selected:before{
  1541. content: "";
  1542. display: block;
  1543. border-width: 15px;
  1544. position: absolute;
  1545. bottom: -30px;
  1546. left: 50%;
  1547. margin-left: -32px;
  1548. border-style: solid dashed dashed solid;
  1549. border-color: #4592FF transparent transparent transparent;
  1550. font-size: 0;
  1551. line-height: 0;
  1552. z-index:1;
  1553. }
  1554. .analysis-card-check-selected{
  1555. border: 1px solid #4592FF;
  1556. background-color: #e7f1ff;
  1557. }
  1558. .color{
  1559. position: relative;
  1560. border: 1px solid #4592FF;
  1561. background-color: #e7f1ff;
  1562. }
  1563. .color:after {
  1564. bottom: -27px;
  1565. border-color: #E7F1FF transparent transparent transparent;
  1566. }
  1567. .legend-group{
  1568. }
  1569. </style>