index.vue 50 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672
  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="memberCount" :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. <!-- 分析概览 (Analysis Overview) -->
  171. <div class="analysis-section" shadow="never">
  172. <div slot="header" class="header">
  173. <span>分析概览</span>
  174. <div class="tab-group">
  175. <el-radio-group v-model="queryTime" size="medium" @change="handleAnalysis">
  176. <el-radio-button label="今日"></el-radio-button>
  177. <el-radio-button label="昨日"></el-radio-button>
  178. <el-radio-button label="本周"></el-radio-button>
  179. <el-radio-button label="本月"></el-radio-button>
  180. <el-radio-button label="上月"></el-radio-button>
  181. </el-radio-group>
  182. </div>
  183. <div class="action-group">
  184. <el-radio-group v-model="userTypeText" @change="handleUserType">
  185. <el-radio-button label="会员"></el-radio-button>
  186. <el-radio-button label="企微"></el-radio-button>
  187. </el-radio-group>
  188. <el-dropdown @command="handleAutoRefresh" trigger="click">
  189. <el-button size="small" plain>
  190. 自动刷新
  191. <i class="el-icon-arrow-down el-icon--right"></i>
  192. </el-button>
  193. <el-dropdown-menu slot="dropdown">
  194. <el-dropdown-item :command="0" :class="{ 'is-active': !autoRefreshInterval }">关闭</el-dropdown-item>
  195. <el-dropdown-item :command="5" :class="{ 'is-active': autoRefreshInterval === 5 }">5分钟</el-dropdown-item>
  196. <el-dropdown-item :command="10" :class="{ 'is-active': autoRefreshInterval === 10 }">10分钟</el-dropdown-item>
  197. <el-dropdown-item :command="15" :class="{ 'is-active': autoRefreshInterval === 15 }">15分钟</el-dropdown-item>
  198. </el-dropdown-menu>
  199. </el-dropdown>
  200. <el-button size="small" plain icon="el-icon-refresh" type="primary" @click="manualRefresh">手动刷新</el-button>
  201. <!-- <el-button size="small" type="primary" @click="refresh">刷新</el-button>-->
  202. </div>
  203. </div>
  204. </div>
  205. <div>
  206. <el-row :gutter="20">
  207. <el-col :span="12" style="position: relative">
  208. <div class="analysis-card-check" :class="selectedDiv===0?'analysis-card-check-selected color':''" @click="handleToggleDiv(0)">
  209. <div class="analysis-card">
  210. <div class="card-icon"><i class="el-icon-monitor"></i></div>
  211. <div class="card-content">
  212. <div class="card-row">
  213. <span>观看人数</span>
  214. <span class="highlight">
  215. <count-to :start-val="0" :end-val="watchUserCount" :duration="3600" class="card-panel-num" />
  216. </span>
  217. </div>
  218. <div class="card-row">
  219. <span>完播人数</span>
  220. <span class="highlight">
  221. <count-to :start-val="0" :end-val="completedUserCount" :duration="3600" class="card-panel-num" />
  222. </span>
  223. </div>
  224. <div class="card-row">
  225. <span>完播率</span>
  226. <span class="highlight">{{completedRate}}%</span>
  227. </div>
  228. </div>
  229. </div>
  230. <div class="analysis-card">
  231. <div class="card-icon"><i class="el-icon-video-play"></i></div>
  232. <div class="card-content">
  233. <div class="card-row">
  234. <span>观看次数</span>
  235. <span class="highlight">
  236. <count-to :start-val="0" :end-val="watchCount" :duration="3600" class="card-panel-num" /></span>
  237. </div>
  238. <div class="card-row">
  239. <span>完播次数</span>
  240. <span class="highlight">
  241. <count-to :start-val="0" :end-val="completedCount" :duration="3600" class="card-panel-num" />
  242. </span>
  243. </div>
  244. <div class="card-row">
  245. <span>视频完播率</span>
  246. <span class="highlight">{{watchRate}}%</span>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. </el-col>
  252. <el-col :span="6" style="position: relative">
  253. <div class="analysis-card-check" :class="selectedDiv===1?'analysis-card-check-selected color':''" @click="handleToggleDiv(1)">
  254. <div class="analysis-card">
  255. <div class="card-icon"><i class="el-icon-headset"></i></div>
  256. <div class="card-content">
  257. <div class="card-row">
  258. <span>答题人数</span>
  259. <span class="highlight">
  260. <count-to :start-val="0" :end-val="answerMemberCount" :duration="3600" class="card-panel-num" />
  261. </span>
  262. </div>
  263. <div class="card-row">
  264. <span>正确人数</span>
  265. <span class="highlight">
  266. <count-to :start-val="0" :end-val="correctUserCount" :duration="3600" class="card-panel-num" />
  267. </span>
  268. </div>
  269. <div class="card-row">
  270. <span>正确率</span>
  271. <span class="highlight">{{correctRate}}%</span>
  272. </div>
  273. </div>
  274. </div>
  275. </div>
  276. </el-col>
  277. <el-col :span="6" style="position: relative">
  278. <div class="analysis-card-check" :class="selectedDiv===2?'analysis-card-check-selected color':''" @click="handleToggleDiv(2)">
  279. <div class="analysis-card">
  280. <div class="card-icon"><i class="el-icon-present"></i></div>
  281. <div class="card-content">
  282. <div class="card-row">
  283. <span>答题红包个数</span>
  284. <span class="highlight">
  285. <count-to :start-val="0" :end-val="rewardCount" :duration="3600" class="card-panel-num" />
  286. </span>
  287. </div>
  288. <div class="card-row">
  289. <span>答题红包金额(元)</span>
  290. <span class="highlight">
  291. <count-to :start-val="0" :end-val="rewardMoney" :duration="3600" class="card-panel-num" /></span>
  292. </div>
  293. </div>
  294. </div>
  295. </div>
  296. </el-col>
  297. </el-row>
  298. </div>
  299. <!-- 图表区域 (Charts Area) -->
  300. <transition name="fade">
  301. <el-row :gutter="20" class="charts-section" v-show="selectedDiv===0">
  302. <el-col :span="12">
  303. <el-card shadow="never">
  304. <div slot="header" class="chart-header">
  305. <span>会员观看、完播人数趋势图</span>
  306. <div class="legend">
  307. <div class="legend-item">
  308. <span class="dot viewer-dot"></span>
  309. <span>观看人数</span>
  310. </div>
  311. <div class="legend-item">
  312. <span class="dot complete-dot"></span>
  313. <span>完播人数</span>
  314. </div>
  315. </div>
  316. <!-- <el-button size="small" plain class="view-more">平台每日统计 <i class="el-icon-arrow-right"></i></el-button>-->
  317. </div>
  318. <div ref="viewerChart" class="chart-container"></div>
  319. </el-card>
  320. </el-col>
  321. <el-col :span="12">
  322. <el-card shadow="never">
  323. <div slot="header" class="chart-header">
  324. <span>经销商会员观看TOP10</span>
  325. <div class="legend">
  326. <el-radio-group v-model="viewerType" size="small" @change="handleDealerChartData">
  327. <el-radio-button label="0">按观看人数</el-radio-button>
  328. <el-radio-button label="1">按完播人数</el-radio-button>
  329. </el-radio-group>
  330. </div>
  331. <!-- <el-button size="small" plain class="view-more">经销商统计 <i class="el-icon-arrow-right"></i></el-button>-->
  332. </div>
  333. <div ref="dealerChart" class="chart-container"></div>
  334. </el-card>
  335. </el-col>
  336. </el-row>
  337. </transition>
  338. <transition name="fade">
  339. <el-row :gutter="20" class="charts-section" v-show="selectedDiv===1">
  340. <el-card shadow="never">
  341. <div slot="header" class="chart-header">
  342. <span>课程观看TOP10</span>
  343. <div class="legend">
  344. <el-radio-group v-model="viewerType" size="small" @change="handleCourseWatchChart">
  345. <el-radio-button label="0">按观看人数</el-radio-button>
  346. <el-radio-button label="1">按完播人数</el-radio-button>
  347. <el-radio-button label="2">按答题人数</el-radio-button>
  348. <el-radio-button label="3">按正确人数</el-radio-button>
  349. </el-radio-group>
  350. </div>
  351. <div class="legend">
  352. <el-radio-group v-model="delerSort" @change="handleCourseWatchChart">
  353. <el-radio label="DESC">前10名</el-radio>
  354. <el-radio label="ASC">倒数10名</el-radio>
  355. </el-radio-group>
  356. </div>
  357. <div class="legend">
  358. <div class="legend-item">
  359. <span class="dot viewer-dot"></span>
  360. <span>观看人数</span>
  361. </div>
  362. <div class="legend-item">
  363. <span class="dot complete-dot"></span>
  364. <span>完播人数</span>
  365. </div>
  366. <div class="legend-item">
  367. <span class="dot" style="background-color: #E6A23C"></span>
  368. <span>答题人数</span>
  369. </div>
  370. <div class="legend-item">
  371. <span class="dot" style="background-color: #F56C6C"></span>
  372. <span>正确人数</span>
  373. </div>
  374. </div>
  375. <!-- <el-button size="small" plain class="view-more">经销商统计 <i class="el-icon-arrow-right"></i></el-button>-->
  376. </div>
  377. <div ref="courseWatchChart" class="chart-container"></div>
  378. </el-card>
  379. </el-row>
  380. </transition>
  381. <transition name="fade">
  382. <el-row :gutter="20" class="charts-section" v-show="selectedDiv===2">
  383. <el-col :span="12">
  384. <el-card shadow="never">
  385. <div slot="header" class="chart-header">
  386. <span>答题红包金额TOP10</span>
  387. <div class="legend">
  388. <el-radio-group v-model="dataType" size="small" @change="handleAnswerRedPackViewerChart">
  389. <el-radio-button label="0">按经销商排行</el-radio-button>
  390. <el-radio-button label="1">按课程排行</el-radio-button>
  391. </el-radio-group>
  392. </div>
  393. <!-- <el-button size="small" plain class="view-more">红包记录 <i class="el-icon-arrow-right"></i></el-button>-->
  394. </div>
  395. <div ref="answerRedPackViewerChart" class="chart-container"></div>
  396. </el-card>
  397. </el-col>
  398. <el-col :span="12">
  399. <el-card shadow="never">
  400. <div slot="header" class="chart-header">
  401. <span>答题红包金额趋势图</span>
  402. <div class="legend">
  403. <div class="legend-item">
  404. <span class="dot viewer-dot"></span>
  405. <span>答题红包金额</span>
  406. </div>
  407. </div>
  408. <!-- <el-button size="small" plain class="view-more">红包记录 <i class="el-icon-arrow-right"></i></el-button>-->
  409. </div>
  410. <div ref="answerRedPackMoneyViewerChart" class="chart-container"></div>
  411. </el-card>
  412. </el-col>
  413. </el-row>
  414. </transition>
  415. <el-row :gutter="20" class="charts-section">
  416. <el-col :span="12">
  417. <el-card shadow="never">
  418. <div slot="header" class="chart-header">
  419. <span>本月订单数</span>
  420. <div class="legend">
  421. <div class="legend-item">
  422. <span class="dot viewer-dot"></span>
  423. <span>订单数</span>
  424. </div>
  425. <div class="legend-item">
  426. <span class="dot complete-dot"></span>
  427. <span>订单金额</span>
  428. </div>
  429. </div>
  430. </div>
  431. <div ref="viewerOrderChart" class="chart-container"></div>
  432. </el-card>
  433. </el-col>
  434. <el-col :span="12">
  435. <el-card shadow="never">
  436. <div slot="header" class="chart-header">
  437. <span>本月收款数</span>
  438. <div class="legend">
  439. <div class="legend-item">
  440. <span class="dot viewer-dot"></span>
  441. <span>收款数</span>
  442. </div>
  443. <div class="legend-item">
  444. <span class="dot complete-dot"></span>
  445. <span>收款金额</span>
  446. </div>
  447. </div>
  448. </div>
  449. <div ref="viewerReceiveChart" class="chart-container"></div>
  450. </el-card>
  451. </el-col>
  452. </el-row>
  453. <br/>
  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: 120px;
  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>