scene-report.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. import * as echarts from '../ec-canvas/echarts'
  2. import { mergeOptions } from '../ec-canvas/defaultOption'
  3. import CensusApi from '../../../apis/census'
  4. Component({
  5. /**
  6. * 组件的属性列表
  7. */
  8. properties: {
  9. sceneNum: {
  10. type: String,
  11. observer: function (val) {
  12. if (!this.properties.date || !this.properties.sceneNum) return;
  13. CensusApi.getSceneCensus({date: this.properties.date, sceneNum: val})
  14. }
  15. },
  16. date: {
  17. type: String,
  18. observer: function (val) {
  19. if (!this.properties.date || !this.properties.sceneNum) return;
  20. CensusApi.getSceneCensus({date: val, sceneNum: this.properties.sceneNum})
  21. }
  22. },
  23. },
  24. /**
  25. * 组件的初始数据
  26. */
  27. data: {
  28. ec: {
  29. onInit: initChart
  30. },
  31. dataNumList: [
  32. {
  33. value: 20,
  34. label: '场景商品数',
  35. key: 'goods_num',
  36. bgColor: 'rgba(115,142,254,0.1)',
  37. color: '#738EFE'
  38. },
  39. {
  40. value: 20,
  41. label: '解说视频数',
  42. key: 'video_num',
  43. bgColor: 'rgba(77,174,255,0.1)',
  44. color: '#4DAEFF'
  45. },
  46. {
  47. value: 20,
  48. label: '场景点位数',
  49. bgColor: 'rgba(246,151,88,0.1)',
  50. color: '#F69758'
  51. },
  52. {
  53. value: 20,
  54. label: '平均视频观看',
  55. bgColor: 'rgba(23,210,210,0.1)',
  56. color: '#17D2D2'
  57. },
  58. {
  59. value: 20,
  60. label: '平均页面停留',
  61. bgColor: 'rgba(250,212,59,0.1)',
  62. color: '#FAD43B'
  63. },
  64. {
  65. value: 20,
  66. label: '名片交换数',
  67. bgColor: 'rgba(19,29,52,0.05)',
  68. color: '#131D34'
  69. },
  70. ]
  71. },
  72. lifetimes: {
  73. },
  74. ready () {
  75. },
  76. methods: {
  77. }
  78. })
  79. function initChart(canvas, width, height, dpr) {
  80. const chart = echarts.init(canvas, null, {
  81. width: width,
  82. height: height,
  83. devicePixelRatio: dpr // new
  84. });
  85. canvas.setChart(chart);
  86. var option = {
  87. title: {
  88. text: '场景浏览数据'
  89. },
  90. series: [
  91. {
  92. data: [[0, 1000], [3, 500], [6, 750], [9, 1400], [12, 1250], [15, 1600], [18, 1800]],
  93. type: 'line',
  94. smooth: true,
  95. name: '主页访问量',
  96. symbolSize: 0
  97. },
  98. ]
  99. };
  100. chart.setOption(mergeOptions(option));
  101. return chart;
  102. }