home.vue 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <div>
  3. <el-row :gutter="10">
  4. <el-col :span="24">
  5. <el-card class="box-card" shadow="none">
  6. <div class="htitle">活动概览</div>
  7. <div class="nums adf">
  8. <div class="nums-pre adffc">
  9. <div class="nums-pre-title adfac">
  10. <img src="" alt="">
  11. <span>活动总数</span>
  12. </div>
  13. <div class="nums-pre-sz">{{ 458 }}</div>
  14. <div class="nums-pre-text adfac">较昨日<i class="el-icon-bottom xj"></i>{{ 23 }}</div>
  15. </div>
  16. <div class="nums-pre adffc">
  17. <div class="nums-pre-title adfac">
  18. <img src="" alt="">
  19. <span>未开始活动</span>
  20. </div>
  21. <div class="nums-pre-sz">{{ 158 }}</div>
  22. <div class="nums-pre-text adfac">较昨日<i class="el-icon-bottom xj"></i>{{ 0 }}</div>
  23. </div>
  24. <div class="nums-pre adffc">
  25. <div class="nums-pre-title adfac">
  26. <img src="" alt="">
  27. <span>进行中活动</span>
  28. </div>
  29. <div class="nums-pre-sz">{{ 140 }}</div>
  30. <div class="nums-pre-text adfac">较昨日<i class="el-icon-bottom xj"></i>{{ 23 }}</div>
  31. </div>
  32. <div class="nums-pre adffc">
  33. <div class="nums-pre-title adfac">
  34. <img src="" alt="">
  35. <span>已结束活动</span>
  36. </div>
  37. <div class="nums-pre-sz">{{ 546 }}</div>
  38. <div class="nums-pre-text adfac">较昨日<i class="el-icon-top ss"></i>{{ 2 }}</div>
  39. </div>
  40. <div class="nums-pre adffc">
  41. <div class="nums-pre-title adfac">
  42. <img src="" alt="">
  43. <span>累计报名人数</span>
  44. </div>
  45. <div class="nums-pre-sz">{{ 5098 }}</div>
  46. <div class="nums-pre-text adfac">较昨日<i class="el-icon-top ss"></i>{{ 280 }}</div>
  47. </div>
  48. <div class="nums-pre adffc">
  49. <div class="nums-pre-title adfac">
  50. <img src="" alt="">
  51. <span>活动参与率</span>
  52. </div>
  53. <div class="nums-pre-sz">{{ 89 }}%</div>
  54. <div class="nums-pre-text adfac">较昨日<i class="el-icon-top ss"></i>{{ 100 }}</div>
  55. </div>
  56. <div class="nums-pre adffc">
  57. <div class="nums-pre-title adfac">
  58. <img src="" alt="">
  59. <span>累计导入爱心值总额</span>
  60. </div>
  61. <div class="nums-pre-sz">{{ 985000 }}</div>
  62. <div class="nums-pre-text adfac">较昨日<i class="el-icon-top ss"></i>{{ 8000 }}</div>
  63. </div>
  64. </div>
  65. </el-card>
  66. </el-col>
  67. </el-row>
  68. <el-row :gutter="10" style="margin-top: 10px;">
  69. <el-col :span="8">
  70. <el-card class="box-card" shadow="none">
  71. <div class="htitle">用户来源</div>
  72. <div class="chartbox">
  73. <div ref="yhlyRef" style="width: 100%;height: 100%;"></div>
  74. </div>
  75. </el-card>
  76. </el-col>
  77. <el-col :span="8">
  78. <el-card class="box-card" shadow="none">
  79. <div class="htitle">男女比例</div>
  80. <div class="chartbox">
  81. <div ref="nnblRef" style="width: 100%;height: 100%;"></div>
  82. </div>
  83. </el-card>
  84. </el-col>
  85. <el-col :span="8">
  86. <el-card class="box-card" shadow="none">
  87. <div class="htitle">活动成员年龄分布</div>
  88. </el-card>
  89. </el-col>
  90. </el-row>
  91. <el-row :gutter="10" style="margin-top: 10px;">
  92. <el-col :span="8">
  93. <el-card class="box-card" shadow="none">
  94. <div class="htitle">爱心值变化趋势</div>
  95. </el-card>
  96. </el-col>
  97. <el-col :span="8">
  98. <el-card class="box-card" shadow="none">
  99. <div class="htitle">活动参与用户排行榜</div>
  100. </el-card>
  101. </el-col>
  102. <el-col :span="8">
  103. <el-card class="box-card" shadow="none">
  104. <div class="htitle">热门活动排名</div>
  105. </el-card>
  106. </el-col>
  107. </el-row>
  108. </div>
  109. </template>
  110. <script>
  111. import * as echarts from 'echarts'
  112. export default {
  113. data () {
  114. return {
  115. }
  116. },
  117. mounted () {
  118. this.initYhlyChart()
  119. this.initNnblChart()
  120. },
  121. methods: {
  122. initYhlyChart () {
  123. let myChart = echarts.init(this.$refs.yhlyRef)
  124. let echartData = [
  125. {
  126. value: 899,
  127. name: '中国银行'
  128. },
  129. {
  130. value: 899,
  131. name: '平安银行'
  132. },
  133. {
  134. value: 1889,
  135. name: '招商银行'
  136. },
  137. {
  138. value: 1199,
  139. name: '建设银行'
  140. },
  141. {
  142. value: 599,
  143. name: '工商银行'
  144. },
  145. {
  146. value: 399,
  147. name: '浦发银行'
  148. }
  149. ]
  150. let seriesData = echartData.map((item, index) => {
  151. return {
  152. ...item,
  153. actValue: item.value,
  154. label: {
  155. show: true,
  156. position: 'outside',
  157. borderRadius: 50,
  158. padding: [10, -10, 3, -3],
  159. textStyle: {
  160. fontSize: 10
  161. },
  162. formatter: '{white|{b}}\n{three| {d}人}',
  163. rich: {
  164. test: {},
  165. white: {
  166. align: 'center',
  167. color: '#989998',
  168. fontSize: 14
  169. },
  170. three: {
  171. color: '#252525',
  172. align: 'center',
  173. padding: [6, 0],
  174. fontSize: 14,
  175. fontWeight: 600
  176. }
  177. }
  178. }
  179. }
  180. })
  181. let option = {
  182. title: {
  183. show: true,
  184. text: '总人数',
  185. itemGap: 10,
  186. x: 'center',
  187. y: '130',
  188. subtext: '3897',
  189. textStyle: {
  190. fontSize: 14,
  191. color: '#989998'
  192. },
  193. subtextStyle: {
  194. fontSize: 14,
  195. color: '#252525',
  196. fontWeight: 600
  197. }
  198. },
  199. tooltip: {
  200. trigger: 'item',
  201. formatter: '{b}<br/>{c} 人',
  202. textStyle: {
  203. fontSize: 16,
  204. color: '#252525'
  205. }
  206. },
  207. series: [
  208. {
  209. name: 'pie',
  210. type: 'pie',
  211. radius: ['30%', '70%'],
  212. hoverAnimation: false,
  213. color: ['#0370F2', '#488CF6', '#4CAFF9', '#39CAFB', '#49DECA', '#16AECA'],
  214. itemStyle: {
  215. normal: {
  216. borderColor: '#fff',
  217. borderWidth: 2
  218. }
  219. },
  220. labelLine: {
  221. length: 10,
  222. length2: 70,
  223. lineStyle: {
  224. color: '#4CAFF9'
  225. }
  226. },
  227. data: seriesData
  228. }
  229. ]
  230. }
  231. myChart.setOption(option)
  232. this.resizeEcharts(this.$refs.yhlyRef)
  233. },
  234. initNnblChart () {
  235. let myChart = echarts.init(this.$refs.nnblRef)
  236. let echartsData = [{ value: 45, name: '女性' }, { value: 55, name: '男性' }]
  237. let colorList = ['#F4657A', '#49DECA']
  238. let option = {
  239. backgroundColor: '#FFF',
  240. color: colorList,
  241. tooltip: {
  242. trigger: 'item'
  243. },
  244. series: [{
  245. name: '',
  246. type: 'pie',
  247. radius: ['30%', '70%'],
  248. center: ['50%', '50%'],
  249. roseType: 'radius',
  250. label: {
  251. show: true,
  252. position: 'outside',
  253. fontSize: 16,
  254. formatter: (params) => {
  255. return `{a|${params.name}${params.value}%}`
  256. },
  257. rich: {
  258. a: {
  259. align: 'left',
  260. fontSize: 14,
  261. color: '#252525'
  262. }
  263. }
  264. },
  265. labelLine: {
  266. length: 10,
  267. length2: 30
  268. },
  269. data: echartsData.map((item, index) => {
  270. return {
  271. ...item,
  272. label: {
  273. color: colorList[index]
  274. }
  275. }
  276. })
  277. }]
  278. }
  279. myChart.setOption(option)
  280. this.resizeEcharts(this.$refs.nnblRef)
  281. },
  282. resizeEcharts (ele) {
  283. let rate = 1920 / window.innerWidth
  284. if (ele.style) {
  285. ele.style.zoom = 1 * rate
  286. ele.style.transform = `scale(${1 / rate})`
  287. ele.style.transformOrigin = 'top left'
  288. }
  289. }
  290. }
  291. }
  292. </script>
  293. <style scoped lang="scss">
  294. .htitle {
  295. font-family: PingFang-SC, PingFang-SC;
  296. font-weight: bold;
  297. font-size: 16px;
  298. color: #252525;
  299. line-height: 16px;
  300. }
  301. .nums{
  302. margin-top: 26px;
  303. &-pre{
  304. width: calc(100% / 7);
  305. border-left: 1px solid #ECEEF5;
  306. padding-left: 16px;
  307. box-sizing: border-box;
  308. &:first-child{
  309. border: none;
  310. padding: 0;
  311. }
  312. &-title{
  313. img{
  314. width: 14px;height: 16px;
  315. }
  316. span{
  317. font-family: PingFangSC, PingFang SC;
  318. font-weight: 400;
  319. font-size: 14px;
  320. color: #6B7280;
  321. line-height: 14px;
  322. margin-left: 6px;
  323. }
  324. }
  325. &-sz{
  326. font-family: DINAlternate, DINAlternate;
  327. font-weight: bold;
  328. font-size: 28px;
  329. color: #252525;
  330. line-height: 28px;
  331. margin-top: 16px;
  332. }
  333. &-text{
  334. font-family: PingFangSC, PingFang SC;
  335. font-weight: 400;
  336. font-size: 12px;
  337. color: #6B7280;
  338. line-height: 12px;
  339. margin-top: 16px;
  340. i{
  341. margin: 0 3px 0 7px;
  342. font-size: 14px;
  343. font-weight: bolder;
  344. &.xj{color: #67C23A;}
  345. &.ss{color: #F4657A;}
  346. }
  347. }
  348. }
  349. }
  350. .chartbox{
  351. width: 100%;
  352. height: 300px;
  353. }
  354. </style>