Commit 0f5bfa87 by zhangxw

轨迹回放优化 bug修改

1 parent e709ae9a
......@@ -91,6 +91,7 @@ Page({
transferAddress: transferAddress,
time: e.data[0].gpsLocation.dateTime
})
if (listData.length > 3) listData.shift() // 最多展示最新三条数据
this.setData({
listData: listData,
scrollIntoViewIndex: '_' + listData.length
......
......@@ -34,7 +34,8 @@ Page({
sn: null,
type: null,
durationArr: [20000, 15000, 10000, 5000],
optTime: moment().format('YYYY-MM-DD')
optTime: moment().format('YYYY-MM-DD'),
allowClick: true
},
/**
......@@ -154,12 +155,9 @@ Page({
}
let params = {sn: this.data.sn, startTime: _sTime, endTime: _eTime, locationType: this.data.locationType}
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 = []
var polyline = []
if (res.code == 200) {
// if (res.returnCode == 0) {
res.data.forEach(item => {
arr.push({
latitude: Number(item.elat),
......@@ -237,8 +235,7 @@ Page({
play() {
this.beginTrack()
},
beginTrack() {
if (this.data.polyline.length) {
addmerker() {
let marker = [{
id: 105,
width: 15,
......@@ -251,27 +248,49 @@ Page({
isReplayIng: true,
markers: marker
})
},
move() {
if (this.myMap.getMapCtx().moveAlong) {
this.myMap.getMapCtx().moveAlong({
markerId: 105,
path: this.data.polyline[0].points,
duration: this.data.durationArr[this.data.speedItemsIndex],
fail: () => {
this.beginTrack()
fail: (res) => { // 真机上容易执行失败
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() {
},
// 重新播放
replayRefresh() {
if (this.data.polyline.length) {
this.setData({
isReplayIng: true
allowClick: false
})
this.beginTrack()
}
setTimeout(() => {
this.setData({
allowClick: true
})
}, 500)
},
// 点击地图回调
mapCallback(e) {
......
......@@ -16,7 +16,7 @@
<view class="btn-control" slot="bottomBox">
<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-refresh refresh-btn active" bindtap="replayRefresh"></view>
<view class="icon icon-replay-refresh refresh-btn active" bindtap="{{allowClick ? 'replayRefresh' : ''}}"></view>
</view>
<!-- 轨迹时间弹窗 -->
<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!