index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <template>
  2. <el-col :span="24" class="populationStatistics modular" style="padding:10px 20px 0;" v-loading="loading">
  3. <el-col class="title" style="margin-left:0;">今日人流量统计</el-col>
  4. <el-col class="subtitle"
  5. >今日人流量统计:<strong>{{
  6. populationStatisticsList.num
  7. }}</strong><span> 人/次</span></el-col
  8. >
  9. <echartsZXT
  10. v-if="status"
  11. :resData="populationStatisticsList.data"
  12. style="width: 100%; height: 100%;"
  13. alt="折线图"
  14. />
  15. </el-col>
  16. </template>
  17. <script>
  18. import axios from 'axios'
  19. import echartsZXT from "@/components2/populationStatistics/echartsZXT.vue";
  20. export default {
  21. name: "populationStatistics",
  22. components: {
  23. echartsZXT,
  24. },
  25. data() {
  26. return {
  27. populationStatisticsList: {
  28. //今日流量
  29. num: undefined,
  30. data: [
  31. [],[]
  32. ],
  33. },
  34. status:false,
  35. loading:true
  36. };
  37. },
  38. watch: {},
  39. created(){
  40. this.init()
  41. this.timing()
  42. },
  43. mounted() {
  44. },
  45. methods: {
  46. async init(){
  47. await axios({
  48. method: 'get',
  49. url: 'https://smartpark.caih.com/ykt/api/thirdparty/v1/openInterface/yunUserRequest',
  50. timeout: 10000,
  51. }).then(res =>{
  52. let total = 0
  53. if(res.data){
  54. this.populationStatisticsList.data.num = 0
  55. this.populationStatisticsList.data[0] = []
  56. this.populationStatisticsList.data[1] = []
  57. for(let i = 0; i<res.data.length; i++){
  58. this.populationStatisticsList.data[0].push(res.data[i].access_time)
  59. this.populationStatisticsList.data[1].push(res.data[i].card_number)
  60. total += res.data[i].card_number
  61. }
  62. this.populationStatisticsList.num = total
  63. setTimeout(()=>{
  64. this.status = true
  65. this.loading = false
  66. },20)
  67. }
  68. }).catch(err =>{
  69. })
  70. },
  71. timing(){
  72. setInterval(() =>{
  73. this.init()
  74. },1000 * 60 * 5)
  75. }
  76. },
  77. };
  78. </script>
  79. <style lang="scss" scoped>
  80. .subtitle {
  81. position: absolute;
  82. top: 10px;
  83. right: 20px;
  84. font-size: 16px;
  85. text-align: right;
  86. strong {
  87. font-size: 20px;
  88. font-family: "DINAlternate-Bold";
  89. font-weight: 700;
  90. }
  91. }
  92. </style>