Commit 0f5bfa87 by zhangxw

轨迹回放优化 bug修改

1 parent e709ae9a
...@@ -91,6 +91,7 @@ Page({ ...@@ -91,6 +91,7 @@ Page({
transferAddress: transferAddress, transferAddress: transferAddress,
time: e.data[0].gpsLocation.dateTime time: e.data[0].gpsLocation.dateTime
}) })
if (listData.length > 3) listData.shift() // 最多展示最新三条数据
this.setData({ this.setData({
listData: listData, listData: listData,
scrollIntoViewIndex: '_' + listData.length scrollIntoViewIndex: '_' + listData.length
......
...@@ -34,7 +34,8 @@ Page({ ...@@ -34,7 +34,8 @@ Page({
sn: null, sn: null,
type: null, type: null,
durationArr: [20000, 15000, 10000, 5000], durationArr: [20000, 15000, 10000, 5000],
optTime: moment().format('YYYY-MM-DD') optTime: moment().format('YYYY-MM-DD'),
allowClick: true
}, },
/** /**
...@@ -154,12 +155,9 @@ Page({ ...@@ -154,12 +155,9 @@ Page({
} }
let params = {sn: this.data.sn, startTime: _sTime, endTime: _eTime, locationType: this.data.locationType} let params = {sn: this.data.sn, startTime: _sTime, endTime: _eTime, locationType: this.data.locationType}
WXRequest.get('devicemonitor/api/track/playback', params, true).then(res => { WXRequest.get('devicemonitor/api/track/playback', params, true).then(res => {
// let params = {sn: '45111120466', sTime: _sTime, eTime: _eTime}
// WXRequest.get('Track/getTrackHistory', params).then(res => {
let arr = [] let arr = []
var polyline = [] var polyline = []
if (res.code == 200) { if (res.code == 200) {
// if (res.returnCode == 0) {
res.data.forEach(item => { res.data.forEach(item => {
arr.push({ arr.push({
latitude: Number(item.elat), latitude: Number(item.elat),
...@@ -237,41 +235,62 @@ Page({ ...@@ -237,41 +235,62 @@ Page({
play() { play() {
this.beginTrack() this.beginTrack()
}, },
beginTrack() { addmerker() {
if (this.data.polyline.length) { let marker = [{
let marker = [{ id: 105,
id: 105, width: 15,
width: 15, height: 25,
height: 25, latitude: this.data.polyline[0].points[0].latitude,
latitude: this.data.polyline[0].points[0].latitude, longitude: this.data.polyline[0].points[0].longitude,
longitude: this.data.polyline[0].points[0].longitude, iconPath: '../../images/car.png'
iconPath: '../../images/car.png' }]
}] this.setData({
this.setData({ isReplayIng: true,
isReplayIng: true, markers: marker
markers: marker })
}) },
move() {
if (this.myMap.getMapCtx().moveAlong) {
this.myMap.getMapCtx().moveAlong({ this.myMap.getMapCtx().moveAlong({
markerId: 105, markerId: 105,
path: this.data.polyline[0].points, path: this.data.polyline[0].points,
duration: this.data.durationArr[this.data.speedItemsIndex], duration: this.data.durationArr[this.data.speedItemsIndex],
fail: () => { fail: (res) => { // 真机上容易执行失败
this.beginTrack() if (res.errMsg === 'moveMapMarkerAlong:fail') {
} this.move()
} else if (res.errMsg === 'moveMapMarkerAlong:fail cancel') {
return
}
},
})
} else {
wx.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
showCancel: false
}) })
} }
}, },
async beginTrack() {
if (this.data.polyline.length) {
this.addmerker()
await this.move()
}
},
// 暂停 // 暂停
pause() { pause() {
}, },
// 重新播放 // 重新播放
replayRefresh() { replayRefresh() {
if (this.data.polyline.length) { this.setData({
allowClick: false
})
this.beginTrack()
setTimeout(() => {
this.setData({ this.setData({
isReplayIng: true allowClick: true
}) })
this.beginTrack() }, 500)
}
}, },
// 点击地图回调 // 点击地图回调
mapCallback(e) { mapCallback(e) {
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<view class="btn-control" slot="bottomBox"> <view class="btn-control" slot="bottomBox">
<view class="icon icon-replay-play play-btn {{isReplayIng? '' : 'active'}}" bindtap="play"></view> <view class="icon icon-replay-play play-btn {{isReplayIng? '' : 'active'}}" bindtap="play"></view>
<!-- <view class="icon icon-replay-pause pause-btn {{isReplayIng? 'active' : ''}}" bindtap="pause"></view> --> <!-- <view class="icon icon-replay-pause pause-btn {{isReplayIng? 'active' : ''}}" bindtap="pause"></view> -->
<view class="icon icon-replay-refresh refresh-btn active" bindtap="replayRefresh"></view> <view class="icon icon-replay-refresh refresh-btn active" bindtap="{{allowClick ? 'replayRefresh' : ''}}"></view>
</view> </view>
<!-- 轨迹时间弹窗 --> <!-- 轨迹时间弹窗 -->
<view class="model_class" wx:if="{{isShowModel}}" slot="sidebar"> <view class="model_class" wx:if="{{isShowModel}}" slot="sidebar">
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!