index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <Card :title="title" :icon="icon" class="resident">
  3. <div class="display-flex">
  4. <div class="gauge margin-r-30">
  5. <div ref="dom" class="hfw-gauge"></div>
  6. </div>
  7. <div class="num display-flex flex-1">
  8. <div v-for="item in residentData" :key="item.title" class="resident-item flex-1">
  9. <div class="content">
  10. <div class="title">{{ item.title }}</div>
  11. <div class="value">{{ item.value }}</div>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. <div class="operate display-flex">
  17. <div v-for="item in operateData" :key="item.title" class="operate-item flex-1">
  18. <div class="icon margin-t-30">
  19. <img :src="item.icon" alt="" class="img">
  20. </div>
  21. <div class="content">
  22. <div class="title">{{ item.title }}</div>
  23. <div class="value">{{ item.value }}</div>
  24. </div>
  25. </div>
  26. </div>
  27. </Card>
  28. </template>
  29. <script>
  30. import * as echarts from 'echarts'
  31. import Card from '@/views/components/card'
  32. import icon from './images/icon-title.png'
  33. import iconReport from './images/icon-report.png'
  34. import iconQrcode from './images/icon-qrcode.png'
  35. import iconPay from './images/icon-pay.png'
  36. export default {
  37. name: 'Resident',
  38. components: {
  39. Card
  40. },
  41. data () {
  42. return {
  43. title: '用户信息',
  44. icon: icon,
  45. residentData: [
  46. {
  47. title: '公众号关注数',
  48. value: 1000
  49. },
  50. {
  51. title: '绘服务绑定数',
  52. value: 1000
  53. },
  54. {
  55. title: '日活跃数(近1月)',
  56. value: 1000
  57. }
  58. ],
  59. operateData: [
  60. {
  61. title: '绘服务缴费次数',
  62. value: 1000,
  63. icon: iconPay
  64. },
  65. {
  66. title: '绘服务扫码次数',
  67. value: 1000,
  68. icon: iconQrcode
  69. },
  70. {
  71. title: '绘服务报事次数',
  72. value: 1000,
  73. icon: iconReport
  74. }
  75. ],
  76. colorArr: ['#182744', '#82D1F6', '#02338C']
  77. }
  78. },
  79. mounted () {
  80. this.initChart()
  81. },
  82. methods: {
  83. initChart () {
  84. const myChart = echarts.init(this.$refs.dom)
  85. const option = {
  86. name: '仪表盘',
  87. grid: {
  88. top: '0px',
  89. bottom: '5px',
  90. left: '0px',
  91. right: '0px'
  92. },
  93. title: {
  94. show: true,
  95. text: [`{titleBg|关注率}`],
  96. left: 'center',
  97. bottom: '0',
  98. textStyle: {
  99. rich: {
  100. titleBg: {
  101. backgroundColor: '#14223C',
  102. borderRadius: 4,
  103. height: 26,
  104. width: 70,
  105. color: '#00CAFF',
  106. fontSize: 16
  107. }
  108. }
  109. }
  110. },
  111. series: [
  112. {
  113. type: 'gauge',
  114. radius: '100%',
  115. name: '绘服务',
  116. axisLine: {
  117. show: true,
  118. lineStyle: {
  119. width: 15,
  120. color: [
  121. [
  122. 0,
  123. new echarts.graphic.LinearGradient(0, 1, 0, 0, [
  124. {
  125. offset: 0,
  126. color: this.colorArr[1]
  127. },
  128. {
  129. offset: 1,
  130. color: this.colorArr[2]
  131. }
  132. ])
  133. ],
  134. [
  135. 1, this.colorArr[0]
  136. ]
  137. ]
  138. }
  139. },
  140. splitLine: {
  141. show: false
  142. },
  143. axisTick: {
  144. show: false
  145. },
  146. axisLabel: {
  147. show: false
  148. },
  149. pointer: {
  150. show: false
  151. },
  152. title: {
  153. offsetCenter: [0, '25%'],
  154. fontSize: 14,
  155. fontFamily: 'Microsoft YaHei',
  156. fontWeight: '400',
  157. color: '#5774A2'
  158. },
  159. detail: {
  160. formatter: '{value}%',
  161. offsetCenter: [0, '-10%'],
  162. fontSize: 22,
  163. fontFamily: 'DS-Digital',
  164. fontWeight: 'bold',
  165. color: '#00D2ED'
  166. },
  167. data: [{ value: 75, name: '绘服务' }]
  168. }
  169. ]
  170. }
  171. myChart.setOption(option)
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="scss">
  177. @import '@/assets/css/function.scss';
  178. @import '@/assets/css/screen.scss';
  179. .resident{
  180. .gauge{
  181. width: halfW(220);
  182. padding-top: halfH(30);
  183. .hfw-gauge{
  184. width: halfW(193);
  185. height: halfH(193);
  186. }
  187. }
  188. .num{
  189. flex-direction: column;
  190. text-align: center;
  191. line-height: halfH(35);
  192. padding-left: halfW(30);
  193. .title{
  194. font-size: halfH(14);
  195. color: #82D1F6;
  196. text-align: left;
  197. }
  198. .value{
  199. font-size: halfH(20);
  200. color: #FFFFFF;
  201. margin-left: halfW(50);
  202. }
  203. }
  204. .operate{
  205. height: halfH(215);
  206. text-align: center;
  207. border-radius: 5px;
  208. background-color: rgba(17, 28, 48, 1);
  209. border: 1px solid rgba(0, 123, 211, 0.2);
  210. padding: halfH(20) 0;
  211. line-height: halfH(40);
  212. margin-top: halfH(60);
  213. .operate-item{
  214. border-right: 1px solid rgba(0, 123, 211, 0.2);
  215. }
  216. .operate-item:last-child{
  217. border-right: none;
  218. }
  219. .img{
  220. width: halfW(48);
  221. height: halfH(48);
  222. }
  223. .content{
  224. margin-top: halfH(25);
  225. }
  226. .title{
  227. font-size: halfH(20);
  228. color: #82D1F6;
  229. }
  230. .value{
  231. font-size: halfH(20);
  232. color: #FFFFFF;
  233. }
  234. }
  235. }
  236. </style>