From d93f732a18023401d24adad6cb23b16d121ca322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=B4=AA=E6=B4=AA?= <2498601771@qq.com> Date: Wed, 6 Mar 2024 15:13:15 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=8C=E5=96=84=E8=BD=A8=E8=BF=B9?= =?UTF-8?q?=E8=BF=BD=E8=B8=AA=E9=A1=B5=E5=8F=B3=E4=BE=A7=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=BA=BF=E6=98=BE=E7=A4=BA=E7=AC=AC1=E6=9D=A1=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E4=BB=A5=E5=8F=8A=E5=90=88=E5=B9=B6=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/location/Index.vue | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/views/location/Index.vue b/src/views/location/Index.vue index 5beb48cb..6c72dfcf 100644 --- a/src/views/location/Index.vue +++ b/src/views/location/Index.vue @@ -685,28 +685,30 @@ export default { this.trackingSubscribers.forEach(s => { if (s.trackRecords && s.trackRecords.length > 0) { for (let i = 0; i < s.trackRecords.length; i++) { - // 最新的位置点不计算停留时间 - if (i === 0) { - s.trackRecords[i].stayTime = '-' - } else { - 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) - } - s.trackRecords[i].stayTime = stayTime.join(' ') - s.trackRecords.splice(i - 1, 1) - i = i - 1 + 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) } + 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.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(' ') } } }