index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  1. <template>
  2. <div class="layout-padding">
  3. <div class="!overflow-auto px-1">
  4. <Lcard :height="440">
  5. <template #default>
  6. <Title style="margin-bottom: 10px;" title="整体趋势">
  7. <el-popover class="box-item" placement="right" trigger="hover" width="250">
  8. <template #reference>
  9. <el-icon class="ml-1" style="color: #a4b8cf">
  10. <InfoFilled />
  11. </el-icon>
  12. </template>
  13. <template #default>
  14. <div class="ant-popover-inner-content">
  15. <div class="um-page-tips-content" style="line-height: 24px">
  16. <p><span class="highlight">新增用户:</span><span>第一次启动应用的用户(以设备为判断标准)</span></p>
  17. <p><span class="highlight">新增账号:</span><span>第一次启动应用的账号</span></p>
  18. <p><span class="highlight">新增用户占比:</span><span>某时段内新增用户占该时段活跃用户的比例</span></p>
  19. <p>
  20. <span>
  21. 按天、周或月查看数据可进行版本、渠道的交叉筛选,小时数据最多展示7天并且不支持筛选。周区间定义为周日至次周周六。按周(按月)显示时,界面上用每周的周日(每个月的第一日)来代表该周(该月)
  22. </span>
  23. </p>
  24. </div>
  25. </div>
  26. </template>
  27. </el-popover>
  28. </Title>
  29. <div class="msg">
  30. <el-icon class="ml-1" style="color: #a4b8cf; vertical-align: middle;">
  31. <InfoFilled />
  32. </el-icon>
  33. 前往
  34. <span class="link">U-DOP数据开放平台</span>
  35. ,获取用户访问明细日志,点击查看
  36. <span class="link">支持返还的字段</span>
  37. </div>
  38. <div class="box1">
  39. <Lcard :height="280" style="margin-right: 20px;">
  40. <div class="card-box1">
  41. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  42. <template #icon>
  43. <img src="./icons/icon1.svg" alt="icon">
  44. </template>
  45. </InfoCard>
  46. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  47. <template #icon>
  48. <img src="./icons/icon2.svg" alt="icon">
  49. </template>
  50. </InfoCard>
  51. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  52. <template #icon>
  53. <img src="./icons/icon3.svg" alt="icon">
  54. </template>
  55. </InfoCard>
  56. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  57. <template #icon>
  58. <img src="./icons/icon4.svg" alt="icon">
  59. </template>
  60. </InfoCard>
  61. </div>
  62. </Lcard>
  63. <Lcard :height="280">
  64. <div class="card-box2">
  65. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  66. <template #icon>
  67. <img src="./icons/icon5.svg" alt="icon">
  68. </template>
  69. </InfoCard>
  70. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  71. <template #icon>
  72. <img src="./icons/icon6.svg" alt="icon">
  73. </template>
  74. </InfoCard>
  75. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  76. <template #icon>
  77. <img src="./icons/icon7.svg" alt="icon">
  78. </template>
  79. </InfoCard>
  80. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  81. <template #icon>
  82. <img src="./icons/icon8.svg" alt="icon">
  83. </template>
  84. </InfoCard>
  85. <InfoCard title="订单数量" value="1,234" description="较昨日减少 1.2%">
  86. <template #icon>
  87. <img src="./icons/icon9.svg" alt="icon">
  88. </template>
  89. </InfoCard>
  90. </div>
  91. </Lcard>
  92. </div>
  93. </template>
  94. </Lcard>
  95. <Lcard :height="975">
  96. <el-date-picker style="float: left;" v-model="timeRange" type="datetimerange" range-separator="To"
  97. start-placeholder="Start date" end-placeholder="End date" />
  98. <div class="link" style="float: right;">订阅</div>
  99. <div class="link" style="float: right;">编辑指标</div>
  100. <div class="link" style="float: right;">生成AI简报</div>
  101. <div class="line"></div>
  102. <div class="flex items-center justify-between mb-2 mt-3">
  103. <el-form>
  104. <el-form-item>
  105. <el-select style="width: 140px" placeholder="渠道对比">
  106. <!-- <el-option v-for="item in channelCompareOptions" :key="item.value" :label="item.label" :value="item.value" /> -->
  107. </el-select>
  108. <el-button class="ml-2">对比时间</el-button>
  109. </el-form-item>
  110. </el-form>
  111. <div class="flex items-center">
  112. <el-radio-group v-model="lineChartUser">
  113. <el-radio-button label="hour">新增用户</el-radio-button>
  114. <el-radio-button label="day">活跃用户</el-radio-button>
  115. <el-radio-button label="week">启动次数</el-radio-button>
  116. <el-radio-button label="month">累计用户</el-radio-button>
  117. </el-radio-group>
  118. </div>
  119. </div>
  120. <div class="relative">
  121. <div ref="qChartRef" style="width: 100%; height: 320px"></div>
  122. </div>
  123. <div class="mt-3">
  124. <div class="flex items-center justify-between mb-2">
  125. <div class="text-base font-medium cursor-pointer select-none" @click="showDetail1 = !showDetail1">
  126. {{ showDetail1 ? '收起明细数据' : '展开明细数据' }}
  127. </div>
  128. <div>
  129. <el-button>导出</el-button>
  130. </div>
  131. </div>
  132. <el-table v-if="showDetail1" :data="pagedTableRows" border>
  133. <el-table-column prop="date" label="日期" min-width="140" />
  134. <el-table-column label="新增用户(占比)" min-width="220">
  135. <template #default="scope">
  136. <div class="flex items-center justify-between w-full">
  137. <span>{{ scope.row.newUsers }}</span>
  138. <span class="text-gray-500 text-xs">{{ scope.row.ratio }}</span>
  139. </div>
  140. </template>
  141. </el-table-column>
  142. </el-table>
  143. <div v-if="showDetail1" class="flex justify-end mt-3">
  144. <el-pagination v-model:current-page="currentPage" v-model:page-size="pageSize" background
  145. layout="total, prev, pager, next, sizes" :total="tableRows.length" :page-sizes="[5, 10, 20]" />
  146. </div>
  147. </div>
  148. </Lcard>
  149. <Lcard :height="660">
  150. <div class="msg">
  151. <el-icon class="ml-1" style="color: #a4b8cf; vertical-align: middle;">
  152. <InfoFilled />
  153. </el-icon>
  154. 点击下列环形图中单个版本/渠道将跳转到对应的详情页
  155. </div>
  156. <div class="box1">
  157. <lcard :height="540" style="margin-right: 20px;">
  158. <div class="box1-title" style="float: left;">TOP版本</div>
  159. <div class="link" style="float: right;">详情</div>
  160. <div class="line" style="margin-top: 40px;"></div>
  161. <el-radio-group v-model="circleEchartUser1">
  162. <el-radio-button label="hour">新增用户</el-radio-button>
  163. <el-radio-button label="day">活跃用户</el-radio-button>
  164. <el-radio-button label="month">累计用户</el-radio-button>
  165. </el-radio-group>
  166. <div ref="circleEchartRef1" style="width: 100%; height: 380px;"></div>
  167. </lcard>
  168. <lcard :height="540">
  169. <div class="box1-title" style="float: left;">TOP版本</div>
  170. <div class="link" style="float: right;">详情</div>
  171. <div class="line" style="margin-top: 40px;"></div>
  172. <el-radio-group v-model="circleEchartUser1">
  173. <el-radio-button label="hour">新增用户</el-radio-button>
  174. <el-radio-button label="day">活跃用户</el-radio-button>
  175. <el-radio-button label="month">累计用户</el-radio-button>
  176. </el-radio-group>
  177. <div ref="circleEchartRef2" style="width: 100%; height: 380px;"></div>
  178. </lcard>
  179. </div>
  180. </Lcard>
  181. </div>
  182. </div>
  183. </template>
  184. <script lang="ts" name="countMainTrend" setup>
  185. // import { ref, onMounted, watch, computed, defineAsyncComponent } from 'vue';
  186. import { useI18n } from 'vue-i18n';
  187. import * as echarts from 'echarts';
  188. // 引入组件
  189. const Lcard = defineAsyncComponent(() => import('/@/components/LYcom/Lcard/index.vue'));
  190. const Title = defineAsyncComponent(() => import('/@/components/Title/index.vue'));
  191. const InfoCard = defineAsyncComponent(() => import('./infoCard.vue'));
  192. const { t } = useI18n();
  193. const timeRange = ref(null);
  194. const qChartRef = ref<HTMLDivElement | null>(null);
  195. let qualityChart: echarts.ECharts | null = null;
  196. onMounted(() => {
  197. setTimeout(() => {
  198. initQualityChart();
  199. initCircleChart2()
  200. initCircleChart1()
  201. }, 500);
  202. });
  203. const qualityXAxis = ref<string[]>([
  204. '2025-07-01',
  205. '2025-07-08',
  206. '2025-07-15',
  207. '2025-07-22',
  208. '2025-07-29',
  209. '2025-08-05',
  210. '2025-08-12',
  211. '2025-08-19',
  212. '2025-08-26',
  213. '2025-09-02',
  214. '2025-09-09',
  215. '2025-09-16',
  216. ]);
  217. const retentionSeries = ref<number[]>([20, 23, 27, 24, 22, 15, 5, 4, 16, 26, 25, 2]);
  218. const industryAvgSeries = ref<number[]>([16, 18, 20, 24, 25, 24, 16, 10, 15, 22, 21, 12]);
  219. const peerSameScaleSeries = ref<number[]>([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]);
  220. function initQualityChart(): void {
  221. console.log(qChartRef.value, qChartRef);
  222. if (!qChartRef.value) return;
  223. if (qualityChart) qualityChart.dispose();
  224. qualityChart = echarts.init(qChartRef.value);
  225. const option: echarts.EChartsOption = {
  226. tooltip: { trigger: 'axis', valueFormatter: (v) => `${v}%` },
  227. legend: { data: ['留存率', '同行业App', '同行业同规模App'] },
  228. grid: { left: 40, right: 20, top: 30, bottom: 30 },
  229. xAxis: { type: 'category', data: qualityXAxis.value },
  230. yAxis: {
  231. type: 'value',
  232. min: 0,
  233. max: 30,
  234. axisLabel: { formatter: '{value}%' },
  235. splitLine: { lineStyle: { color: '#f3f4f6' } },
  236. },
  237. series: [
  238. { name: '留存率', type: 'line', smooth: true, data: retentionSeries.value },
  239. { name: '同行业App', type: 'line', smooth: true, data: industryAvgSeries.value, color: '#f59e0b' },
  240. { name: '同行业同规模App', type: 'line', smooth: true, data: peerSameScaleSeries.value, color: '#60a5fa' },
  241. ],
  242. };
  243. qualityChart.setOption(option);
  244. }
  245. interface TableRow {
  246. date: string;
  247. newUsers: number;
  248. ratio: string;
  249. }
  250. // 展开/收起明细
  251. const showDetail1 = ref(true);
  252. const pagedTableRows = computed(() => {
  253. const startIndex = (currentPage.value - 1) * pageSize.value;
  254. return tableRows.value.slice(startIndex, startIndex + pageSize.value);
  255. });
  256. // 表格相关(静态数据)
  257. const currentPage = ref(1);
  258. const pageSize = ref(5);
  259. const tableRows = ref<TableRow[]>(
  260. Array.from({ length: 42 }).map((_, idx) => ({
  261. date: `2025-08-${String(11).padStart(2, '0')}`,
  262. newUsers: 727,
  263. ratio: '97.45%',
  264. }))
  265. );
  266. // 环形图
  267. // 添加圆环图相关的引用和数据
  268. const circleEchartRef1 = ref(null);
  269. let circleChart1: echarts.ECharts | null = null;
  270. const circleEchartUser1 = ref('hour');
  271. const circleEchartRef2 = ref(null);
  272. let circleChart2: echarts.ECharts | null = null;
  273. const circleEchartUser2 = ref('hour');
  274. // 初始化圆环图
  275. function initCircleChart1(): void {
  276. if (!circleEchartRef1.value) return;
  277. if (circleChart1) circleChart1.dispose();
  278. circleChart1 = echarts.init(circleEchartRef1.value);
  279. const option: echarts.EChartsOption = {
  280. tooltip: {
  281. trigger: 'item'
  282. },
  283. legend: {
  284. bottom: '0',
  285. left: 'center'
  286. },
  287. series: [
  288. {
  289. name: '版本分布',
  290. type: 'pie',
  291. radius: ['50%', '70%'], // 设置内半径和外半径,形成圆环效果
  292. avoidLabelOverlap: false,
  293. padAngle: 2, // 扇区间隙
  294. itemStyle: {
  295. borderRadius: 5 // 扇区圆角
  296. },
  297. label: {
  298. show: true,
  299. formatter: '{b}: {d}%' // 显示标签和百分比
  300. },
  301. emphasis: {
  302. label: {
  303. show: true,
  304. fontSize: 14,
  305. fontWeight: 'bold'
  306. }
  307. },
  308. labelLine: {
  309. show: true
  310. },
  311. data: [
  312. { value: 35, name: 'v3.2.1' },
  313. { value: 25, name: 'v3.1.5' },
  314. { value: 20, name: 'v3.0.8' },
  315. { value: 10, name: 'v2.9.3' },
  316. { value: 10, name: '其他' }
  317. ]
  318. }
  319. ]
  320. };
  321. circleChart1.setOption(option);
  322. }
  323. // 初始化圆环图
  324. function initCircleChart2(): void {
  325. if (!circleEchartRef2.value) return;
  326. if (circleChart2) circleChart2.dispose();
  327. circleChart2 = echarts.init(circleEchartRef2.value);
  328. const option: echarts.EChartsOption = {
  329. tooltip: {
  330. trigger: 'item'
  331. },
  332. legend: {
  333. bottom: '0',
  334. left: 'center'
  335. },
  336. series: [
  337. {
  338. name: '版本分布',
  339. type: 'pie',
  340. radius: ['50%', '70%'], // 设置内半径和外半径,形成圆环效果
  341. avoidLabelOverlap: false,
  342. padAngle: 2, // 扇区间隙
  343. itemStyle: {
  344. borderRadius: 5 // 扇区圆角
  345. },
  346. label: {
  347. show: true,
  348. formatter: '{b}: {d}%' // 显示标签和百分比
  349. },
  350. emphasis: {
  351. label: {
  352. show: true,
  353. fontSize: 14,
  354. fontWeight: 'bold'
  355. }
  356. },
  357. labelLine: {
  358. show: true
  359. },
  360. data: [
  361. { value: 35, name: 'v3.2.1' },
  362. { value: 25, name: 'v3.1.5' },
  363. { value: 20, name: 'v3.0.8' },
  364. { value: 10, name: 'v2.9.3' },
  365. { value: 10, name: '其他' }
  366. ]
  367. }
  368. ]
  369. };
  370. circleChart2.setOption(option);
  371. }
  372. </script>
  373. <style lang="scss" scoped>
  374. .msg {
  375. height: 30px;
  376. background-color: #f4f5fa;
  377. line-height: 30px;
  378. font-size: 12px;
  379. }
  380. .link {
  381. color: #167af0;
  382. cursor: pointer;
  383. }
  384. .box1 {
  385. display: flex;
  386. margin-top: 30px;
  387. .card-box1,
  388. .card-box2 {
  389. display: flex;
  390. flex-wrap: wrap;
  391. justify-content: start;
  392. }
  393. .card-box1 {
  394. .info-card {
  395. width: 48%;
  396. }
  397. }
  398. .card-box2 {
  399. .info-card {
  400. width: 33%;
  401. }
  402. }
  403. }
  404. .line {
  405. margin: 60px -30px 30px;
  406. height: 1px;
  407. background-color: #E6E6E6;
  408. }
  409. </style>