<shopMap :markerList="markerList" @runStart="runStart" @runStop="runStop" :status="runStart_status">
export default {
data() {
return {
runStart_status: 1,
markerList: {
runTotal: '0.23',
runTime: '00:00:00',
location: [],
runStatus: 1
},
total_timer: null, //时间计时器
hour: 0,
minute: 0,
second: 0
}
}
methods: {
runStart() {
var that = this
that.total_timer = setInterval(() => {
that.second = that.second + 1;
if (that.second >= 60) {
that.second = 0;
that.minute = that.minute + 1;
}
if (that.minute >= 60) {
that.minute = 0;
that.hour = that.hour + 1;
}
that.markerList.runTime =
that.Zero(that.hour) +
":" +
that.Zero(that.minute) +
":" +
that.Zero(that.second);
}, 1000)
that.markerList.runStatus = 2
},
Zero(n) {
return n < 10 ? "0" + n : "" + n;
},
runStop() {
clearInterval(this.timer)
clearInterval(this.total_timer)
this.hour = 0;
this.minute = 0;
this.second = 0;
this.markerList.runTime = "00:00:00";
console.log('list-------------------', this.markerList.location)
this.markerList.runStatus = 1
},
}
}