Commit 9f91db55 by zhangxw

优化修改

1 parent 280269bb
This diff could not be displayed because it is too large.
.map-wrap{ .map-wrap{
position: fixed;
top: 0;
left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
......
{ {
"usingComponents": { "usingComponents": {
"myMap": "../../components/myMap/myMap" "myMap": "../../components/myMap/myMap"
} },
"navigationBarTitleText": "找车"
} }
\ No newline at end of file \ No newline at end of file
<view class="content_page"> <view class="content_page">
<myMap class="my-map" id="myMap" bind:getCarInfoWindowObj="getCarInfoWindowObj" bind:refresh="refresh" includePoints="{{includePoints}}" bind:locationCallback="locationCallback"></myMap> <myMap class="my-map" id="myMap" bind:getCarInfoWindowObj="getCarInfoWindowObj" bind:refresh="refresh" markers="{{markers}}" includePoints="{{includePoints}}" bind:locationCallback="locationCallback"></myMap>
<!-- 找车按钮 --> <!-- 找车按钮 -->
<view wx:if="{{!isSharePage}}" class="icon icon-findcar map-cmd-icon" bindtap="findCarClick"></view> <view wx:if="{{!isSharePage}}" class="icon icon-findcar map-cmd-icon" bindtap="findCarClick"></view>
<!-- 信息窗体内容 --> <!-- 信息窗体内容 -->
......
This diff could not be displayed because it is too large.
...@@ -11,10 +11,12 @@ Page({ ...@@ -11,10 +11,12 @@ Page({
},{ },{
label: '设备号', label: '设备号',
value: '1' value: '1'
},{ }
label: '姓名', // {
value: '3' // label: '姓名',
}], // value: '3'
// }
],
placeholders: [ placeholders: [
'请输入完整的申请单号', '请输入完整的申请单号',
'请输入完整的车架号', '请输入完整的车架号',
...@@ -143,14 +145,14 @@ Page({ ...@@ -143,14 +145,14 @@ Page({
if(inputVal.length<2){ if(inputVal.length<2){
wx.showToast({ wx.showToast({
title: '请输入正确的姓名,至少2个字', title: '请输入正确的姓名,至少2个字',
icon: none icon: 'none'
}); });
return false; return false;
} }
}else if(inputVal.length<6){ }else if(inputVal.length<6){
wx.showToast({ wx.showToast({
title: '请输入至少6位数', title: '请输入至少6位数',
icon: none icon: 'none'
}); });
return false; return false;
} }
......
...@@ -85,6 +85,7 @@ Page({ ...@@ -85,6 +85,7 @@ Page({
wx.request({ wx.request({
url: `https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`+ e.data[0].gpsLocation.elat + ',' + e.data[0].gpsLocation.elng, url: `https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`+ e.data[0].gpsLocation.elat + ',' + e.data[0].gpsLocation.elng,
success: res => { success: res => {
if (res.statusCode === 200) {
let transferAddress = res.data && res.data.result.address_component.province === res.data.result.address_component.city ? (res.data.result.address_component.city + '' + res.data.result.formatted_addresses.rough) : (res.data.result.address_component.province + '' + res.data.result.address_component.city + '' + res.data.result.formatted_addresses.rough) let transferAddress = res.data && res.data.result.address_component.province === res.data.result.address_component.city ? (res.data.result.address_component.city + '' + res.data.result.formatted_addresses.rough) : (res.data.result.address_component.province + '' + res.data.result.address_component.city + '' + res.data.result.formatted_addresses.rough)
listData.push({ listData.push({
transferAddress: transferAddress, transferAddress: transferAddress,
...@@ -154,7 +155,7 @@ Page({ ...@@ -154,7 +155,7 @@ Page({
}, },
duration: 500, duration: 500,
animationEnd: () => { animationEnd: () => {
this.moveToLocation(e.data[0].gpsLocation.elat, e.data[0].gpsLocation.elng) this.moveToLocation(Number(e.data[0].gpsLocation.elat), Number(e.data[0].gpsLocation.elng))
this.setData({ this.setData({
points: points.concat(arr), points: points.concat(arr),
polyline: [{ polyline: [{
...@@ -176,6 +177,7 @@ Page({ ...@@ -176,6 +177,7 @@ Page({
this.getPosition() this.getPosition()
}, 10*1000) }, 10*1000)
} }
}
}) })
} }
}) })
......
{ {
"usingComponents": {} "usingComponents": {
"myMap": "../../components/myMap/myMap"
},
"navigationBarTitleText": "实时监控"
} }
\ No newline at end of file \ No newline at end of file
This diff could not be displayed because it is too large.
...@@ -29,12 +29,12 @@ Page({ ...@@ -29,12 +29,12 @@ Page({
isReplayIng: false, isReplayIng: false,
polyline: [], polyline: [],
markers: [], markers: [],
duration: 20000, // 回放速度
isShowModel: false, isShowModel: false,
clickItem: null, clickItem: null,
selectTime: '', selectTime: '',
sn: null, sn: null,
type: null type: null,
durationArr: [20000, 15000, 10000, 5000]
}, },
/** /**
...@@ -64,7 +64,6 @@ Page({ ...@@ -64,7 +64,6 @@ Page({
refresh() { refresh() {
if (this.data.polyline.length <= 0) return if (this.data.polyline.length <= 0) return
this.setData({ this.setData({
duration: 20000,
clickItem: null, clickItem: null,
selectTime: '', selectTime: '',
polyline: [], polyline: [],
...@@ -155,15 +154,25 @@ Page({ ...@@ -155,15 +154,25 @@ 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),
longitude: Number(item.elng) longitude: Number(item.elng)
}) })
}); });
let obj = {}
let removalArr = arr.reduce((curr, next) => {
/*判断对象中是否已经有该属性 没有的话 push 到 curr数组*/
obj[next.latitude + next.longitude] ? '' : obj[next.latitude + next.longitude] = curr.push(next);
return curr;
}, []);
this.distance(removalArr)
if (res.data.length) { if (res.data.length) {
polyline.push({ polyline.push({
points: arr, points: arr,
...@@ -189,12 +198,39 @@ Page({ ...@@ -189,12 +198,39 @@ Page({
} }
}) })
}, },
// 距离计算总和
distance(arr) {
var s, all = 0
arr.forEach((item, index) => {
if (arr[index + 1]) {
var La1 = arr[index].latitude * Math.PI / 180.0;
var La2 = arr[index + 1].latitude * Math.PI / 180.0;
var La3 = La1 - La2;
var Lb3 = arr[index].longitude * Math.PI / 180.0 - arr[index + 1].longitude * Math.PI / 180.0;
s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(La3 / 2), 2) + Math.cos(La1) * Math.cos(La2) * Math.pow(Math.sin(Lb3 / 2), 2)));
s = s * 6378.137;//地球半径
s = Math.round(s * 10000) / 10000;
all = all + s
}
})
if (all > 10 && all < 100) {
this.setData({
durationArr: [15*1000, 10*1000, 6*1000, 3*1000]
})
} else if (all <= 10) {
this.setData({
durationArr: [8*1000, 6*1000, 4*1000, 2*1000]
})
} else {
this.setData({
durationArr: [20*1000, 15*1000, 10*1000, 5*1000]
})
}
},
// 切换回放速度 // 切换回放速度
speedTypeChange(e) { speedTypeChange(e) {
let arr = [20000, 15000, 10000, 5000]
this.setData({ this.setData({
speedItemsIndex: Number(e.detail.value), speedItemsIndex: Number(e.detail.value)
duration: arr[Number(e.detail.value)]
}) })
this.beginTrack() this.beginTrack()
}, },
...@@ -219,7 +255,7 @@ Page({ ...@@ -219,7 +255,7 @@ Page({
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.duration, duration: this.data.durationArr[this.data.speedItemsIndex],
fail: () => { fail: () => {
this.beginTrack() this.beginTrack()
} }
...@@ -250,6 +286,7 @@ Page({ ...@@ -250,6 +286,7 @@ Page({
wx.request({ wx.request({
url: `https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`+ e.detail.detail.latitude + ',' + e.detail.detail.longitude, url: `https://apis.map.qq.com/ws/geocoder/v1/?key=46XBZ-RVUCD-FI34X-H66JJ-HZ5FS-3YFID&location=`+ e.detail.detail.latitude + ',' + e.detail.detail.longitude,
success: res => { success: res => {
if (res.statusCode === 200) {
transferAddress = res.data && res.data.result.address_component.province === res.data.result.address_component.city ? (res.data.result.address_component.city + '\n' + res.data.result.formatted_addresses.rough) : (res.data.result.address_component.province + '' + res.data.result.address_component.city + '\n' + res.data.result.formatted_addresses.rough) transferAddress = res.data && res.data.result.address_component.province === res.data.result.address_component.city ? (res.data.result.address_component.city + '\n' + res.data.result.formatted_addresses.rough) : (res.data.result.address_component.province + '' + res.data.result.address_component.city + '\n' + res.data.result.formatted_addresses.rough)
this.myMap.getMapCtx().addMarkers({ this.myMap.getMapCtx().addMarkers({
markers: [{ markers: [{
...@@ -267,6 +304,7 @@ Page({ ...@@ -267,6 +304,7 @@ Page({
}], }],
}) })
} }
}
}) })
}, },
/** /**
......
{ {
"usingComponents": { "usingComponents": {
"myMap": "../../components/myMap/myMap" "myMap": "../../components/myMap/myMap"
} },
"navigationBarTitleText": "轨迹回放"
} }
\ No newline at end of file \ No newline at end of file
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!