index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <Card :title="title" :subTitle="subTitle" :icon="icon" class="online-pay">
  3. <div class="total display-flex">
  4. <div class="img">
  5. <img src="./images/icon-total.png" alt="" class="icon">
  6. </div>
  7. <div>
  8. 总缴费(近12个月):¥234554
  9. </div>
  10. </div>
  11. <div ref="onlinePayBar" class="online-pay-bar"></div>
  12. </Card>
  13. </template>
  14. <script>
  15. import * as echarts from 'echarts'
  16. // import { getBigNumberWithUint } from '@/libs/tools.js'
  17. import Card from '@/views/components/card'
  18. import icon from './images/icon-title.png'
  19. export default {
  20. name: 'OnlinePay',
  21. components: {
  22. Card
  23. },
  24. data () {
  25. return {
  26. title: '线上缴费统计',
  27. subTitle: '近12个月',
  28. icon: icon
  29. }
  30. },
  31. mounted () {
  32. this.initChart()
  33. },
  34. methods: {
  35. /**
  36. * 获取一个和max最接近的能被5整除的无零头整数
  37. */
  38. getMax (max) {
  39. if (max <= 10) return 10
  40. let pow = max.toString().length - 2
  41. pow = Math.pow(10, pow)
  42. max = Math.ceil(max / pow / 10) * 10 * pow
  43. return max
  44. },
  45. initChart () {
  46. const myChart = echarts.init(this.$refs.onlinePayBar)
  47. const xAxisData = ['十二月', '一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月']
  48. const seriesData = [5, 20, 36, 10, 10, 20, 40, 25, 30, 45, 50, 60]
  49. // let max = 0
  50. // max = seriesData.reduce((max, num) => {
  51. // return Math.max(Number(max), Number(num))
  52. // })
  53. // max = this.getMax(max)
  54. const option = {
  55. tooltip: {},
  56. legend: {
  57. right: '0',
  58. top: '20px',
  59. textStyle: {
  60. color: '#fff'
  61. }
  62. },
  63. grid: {
  64. top: '80px',
  65. bottom: '0px',
  66. left: '0px',
  67. right: '0px',
  68. containLabel: true
  69. },
  70. xAxis: {
  71. axisLabel: {
  72. color: '#fff',
  73. margin: 15,
  74. fontSize: 14,
  75. formatter: function (val, idx) {
  76. let value = xAxisData[idx]
  77. return value
  78. }
  79. },
  80. axisLine: {
  81. show: true,
  82. lineStyle: {
  83. color: '#666',
  84. opacity: 1,
  85. cap: 'round'
  86. }
  87. },
  88. boundaryGap: false,
  89. axisTick: {
  90. alignWithLabel: true,
  91. length: 7,
  92. lineStyle: {
  93. width: 3,
  94. color: '#fff',
  95. opacity: 0.5
  96. }
  97. },
  98. splitLine: {
  99. show: true,
  100. lineStyle: {
  101. color: '#fff',
  102. opacity: 0.3,
  103. cap: 'round',
  104. type: [5, 10]
  105. }
  106. },
  107. max: function (value) { // x轴左侧留白
  108. return value.max + 0.3
  109. },
  110. min: function (value) { // x轴左侧留白
  111. return -0.3
  112. },
  113. data: xAxisData
  114. },
  115. yAxis: [
  116. {
  117. axisLabel: {
  118. color: '#fff',
  119. margin: 25,
  120. fontSize: 14
  121. },
  122. axisLine: {
  123. show: false,
  124. lineStyle: {
  125. color: '#fff'
  126. }
  127. },
  128. axisTick: {
  129. length: 14,
  130. lineStyle: {
  131. width: 2,
  132. fontSize: 16
  133. }
  134. },
  135. splitLine: {
  136. show: true,
  137. lineStyle: {
  138. color: '#fff',
  139. opacity: 0.3,
  140. cap: 'round',
  141. type: 'dashed',
  142. dashOffset: 5
  143. }
  144. }
  145. },
  146. {
  147. type: 'value',
  148. position: 'right',
  149. axisLabel: {
  150. show: false
  151. },
  152. axisTick: {
  153. show: true,
  154. length: 14,
  155. lineStyle: {
  156. width: 2,
  157. fontSize: 16
  158. }
  159. },
  160. axisLine: {
  161. show: false
  162. }
  163. }
  164. ],
  165. series: [{
  166. name: '线上流水',
  167. type: 'bar',
  168. barWidth: '20%',
  169. labelLine: {
  170. show: false
  171. },
  172. itemStyle: {
  173. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  174. { offset: 0, color: '#0F67F8' },
  175. { offset: 0.5, color: '#98D7F1' },
  176. { offset: 1, color: '#77ECED' }
  177. ]),
  178. barBorderRadius: [10, 10, 0, 0]
  179. },
  180. data: seriesData
  181. }]
  182. }
  183. myChart.setOption(option)
  184. }
  185. }
  186. }
  187. </script>
  188. <style lang="scss">
  189. @import '@/assets/css/function.scss';
  190. .online-pay-bar {
  191. width: 100%;
  192. height: halfH(363);
  193. }
  194. .online-pay {
  195. .total{
  196. height: halfH(24);
  197. line-height: halfH(24);
  198. padding: halfH(18) halfW(18);
  199. color: #fff;
  200. float: left;
  201. font-size: halfW(14);
  202. border-radius: 5px;
  203. background-color: rgba(17, 28, 48, 1);
  204. text-align: center;
  205. border: 1px solid rgba(0, 123, 211, 0.2);
  206. }
  207. .img{
  208. width: halfW(40);
  209. height: halfH(40);
  210. margin-right: halfW(27);
  211. margin-top: halfH(-7);
  212. padding: halfH(8) halfW(8);
  213. box-sizing: border-box;
  214. background: #12223C;
  215. border-radius: 50%;
  216. .icon{
  217. width: 100%;
  218. height: 100%;
  219. }
  220. }
  221. }
  222. </style>