index.vue 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662
  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="qwMemberNum" :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>