index.vue 49 KB

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