diff --git a/src/views/location/Index.vue b/src/views/location/Index.vue index 6c72dfcf..27606909 100644 --- a/src/views/location/Index.vue +++ b/src/views/location/Index.vue @@ -685,30 +685,32 @@ export default { this.trackingSubscribers.forEach(s => { if (s.trackRecords && s.trackRecords.length > 0) { for (let i = 0; i < s.trackRecords.length; i++) { - if ((s.trackRecords[i - 1].subscriberLongitude === s.trackRecords[i].subscriberLongitude) && (s.trackRecords[i - 1].subscriberLatitude === s.trackRecords[i].subscriberLatitude)) { - // 如果连续两条地址重复,则将时间累加,并将上一条删除,键值-1继续循环 - if (s.trackRecords[i - 2]) { - const stayTime = unitConvert(s.trackRecords[i - 2].time - s.trackRecords[i].time, unitTypes.time, 's') - if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { - stayTime[0] = Number(stayTime[0]).toFixed(0) + if (i > 0) { + if ((s.trackRecords[i - 1].subscriberLongitude === s.trackRecords[i].subscriberLongitude) && (s.trackRecords[i - 1].subscriberLatitude === s.trackRecords[i].subscriberLatitude)) { + // 如果连续两条地址重复,则将时间累加,并将上一条删除,键值-1继续循环 + if (i > 1 && s.trackRecords[i - 2]) { + const stayTime = unitConvert(s.trackRecords[i - 2].time - s.trackRecords[i].time, unitTypes.time, 's') + if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { + stayTime[0] = Number(stayTime[0]).toFixed(0) + } + s.trackRecords[i].stayTime = stayTime.join(' ') + } else { + // 数据只有2条,或者第1条和第2条地点重复,删除1,合并时间 + const stayTime = unitConvert(s.trackRecords[i - 1].time - s.trackRecords[i].time, unitTypes.time, 's') + if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { + stayTime[0] = Number(stayTime[0]).toFixed(0) + } + s.trackRecords[i].stayTime = stayTime.join(' ') } - s.trackRecords[i].stayTime = stayTime.join(' ') + s.trackRecords.splice(i - 1, 1) + i = i - 1 } else { - // 数据只有2条,或者第1条和第2条地点重复,删除1,合并时间 const stayTime = unitConvert(s.trackRecords[i - 1].time - s.trackRecords[i].time, unitTypes.time, 's') if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { stayTime[0] = Number(stayTime[0]).toFixed(0) } s.trackRecords[i].stayTime = stayTime.join(' ') } - s.trackRecords.splice(i - 1, 1) - i = i - 1 - } else { - const stayTime = unitConvert(s.trackRecords[i - 1].time - s.trackRecords[i].time, unitTypes.time, 's') - if (Number(stayTime[0]) === Number(Number(stayTime[0]).toFixed(0))) { - stayTime[0] = Number(stayTime[0]).toFixed(0) - } - s.trackRecords[i].stayTime = stayTime.join(' ') } } } @@ -730,7 +732,6 @@ export default { if (this.currentShowSubscriber.trackRecords && this.currentShowSubscriber.trackRecords.length > 0) { // 六边形 const trackingPolygonSourceData = this.hexagonDataConverter(this.currentShowSubscriber.trackRecords, 'traceTracking') - console.info(this.currentShowSubscriber) this.trackingPolygonSourceData = _.cloneDeep(trackingPolygonSourceData) this.mapChart.addSource('trackingHexGrid', { type: 'geojson',