<template>
  <div>

    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column label="车辆识别号" width="180">
        <template slot-scope="scope">
          {{ scope.row.vin }}
        </template>
      </el-table-column>
      <el-table-column label="时间戳" width="180">
        <template slot-scope="scope" >
          {{ parseTime(scope.row.timestamp, '{y}-{m}-{d}:{h}:{i}:{s}') }}
        </template>
      </el-table-column>
      <el-table-column label="经度" width="180">
        <template slot-scope="scope">
          {{ scope.row.longitude }}
        </template>
      </el-table-column>
      <el-table-column label="纬度" width="180">
        <template slot-scope="scope">
          {{ scope.row.latitude }}
        </template>
      </el-table-column>
      <el-table-column label="速度" width="180">
        <template slot-scope="scope">
          {{ scope.row.speed }}
        </template>
      </el-table-column>
      <el-table-column label="里程" width="180">
        <template slot-scope="scope">
          {{ scope.row.mileage }}
        </template>
      </el-table-column>
      <el-table-column label="电压" width="180">
        <template slot-scope="scope">
          {{ scope.row.voltage }}
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>

import {listVehicle} from "@/api/customerBusiness/realtime";
import {parseTime} from "../../../utils/muyu";

export default {
  name: "Realtime",
  data() {
    return {
      marker: null,
      lineArr: [
        [116.478935,39.997761],
        // ... （省略部分数据以保持简洁）
        [116.484648,39.999861]
      ],
      map: null,
      polyline: null,
      passedPolyline: null,
      tableData: [],
      car: {},
      timer:"",
      vin:"",
    };
  },
  created() {
    this.vin = this.$route.params.vin;
    console.log(this.vin)
    this.start();
  },
  methods: {
    parseTime,
    start(){
      this.timer = setInterval(() => {
          listVehicle(this.vin).then(response => {
            this.tableData=[];
            console.log(response.data)
           this.car=response.data
            this.tableData.push(this.car)
          });
      },1000)
    },

  },


};

</script>
