Commit 9dda8cc9 by 张晓玮

Merge branch 'develop' into 'master'

Develop

See merge request !2
2 parents cd869aa3 f4cb0e7c
......@@ -23,8 +23,10 @@
"pages/freqLogSearch/freqLogSearch",
"pages/freqLogDetail/freqLogDetail",
"pages/freqLogUserDetail/freqLogUserDetail",
"pages/map/findCar",
"pages/test/test"
"pages/newFindCar/findCar",
"pages/newFindSearch/findSearch",
"pages/newMonitor/monitor",
"pages/newTraReplay/traReplay"
],
"window": {
"backgroundColor": "#efeff4",
......@@ -63,5 +65,8 @@
"desc": "你的位置信息将用于定位效果展示"
}
},
"sitemapLocation": "sitemap.json"
"sitemapLocation": "sitemap.json",
"usingComponents": {
"myMap": "components/myMap/myMap"
}
}
\ No newline at end of file
This diff could not be displayed because it is too large.
Component({
/**
* 组件的属性列表
*/
options: {
multipleSlots: true
},
properties: {
markers: Array,
isLoading: Boolean,
includePoints: Array, // 当前页面是否有marker或路径的左边点
mapId: String
},
/**
* 组件的初始数据
*/
data: {
currentLo: 116.363874, // 地图中心点坐标
currentLa: 39.738269,
latitude: null, // 定位坐标
longitude: null,
isAuthLocation: false,
enableSatellite: false,
enableTraffic: false,
carInfoWindowObj: {},
isGPS: true,
scale: 16,
isCanClick: true,
inPoints: [],
polyline: []
},
ready() {
},
attached() {
},
/**
* 组件的方法列表
*/
methods: {
getMapCtx() {
if (this.mapCtx) {
return this.mapCtx
}
// 创建 map 上下文 MapContext 对象
this.mapCtx = wx.createMapContext(this.data.mapId, this)
return this.mapCtx
},
bindmarkertap(e) {
this.triggerEvent('bindmarkertap', e)
},
// 刷新
refreshClick() {
this.triggerEvent('refresh')
},
// 点击地图
mapClick(e) {
this.triggerEvent('mapCallback', e)
},
// 移动地图
moveToLocation: function (latitude, longitude ) {
this.getMapCtx().moveToLocation({
longitude: longitude,
latitude: latitude
})
},
// 图层缩放控制
layerClick(e) {
switch(Number(e.currentTarget.dataset.num)) {
case 1:
this.setData({
enableSatellite: !this.data.enableSatellite,
enableTraffic: this.data.enableTraffic
})
break
case 2:
this.setData({
enableSatellite: this.data.enableSatellite,
enableTraffic: !this.data.enableTraffic
})
break
case 3:
this.getMapCtx().getScale({
success: (res) => {
this.getMapCtx().getCenterLocation({
success: (e) => {
this.setData({
currentLo: e.longitude,
currentLa: e.latitude,
scale: res.scale >= 20 ? 20 : res.scale+1
})
}
})
}
})
break
case 4:
this.getMapCtx().getScale({
success: (res) => {
this.getMapCtx().getCenterLocation({
success: (e) => {
this.setData({
currentLo: e.longitude,
currentLa: e.latitude,
scale: res.scale <= 3 ? 3 : res.scale-1
})
}
})
}
})
break
}
},
// 定位
locateClick(e) {
let _this = this
if (!this.data.isCanClick) return
this.setData({
isCanClick: false
})
setTimeout(() => {
this.setData({
isCanClick: true
})
}, 30*1000)
if (_this.data.isAuthLocation) {
_this.getLocation()
} else {
wx.getSetting({
success: (res) => {
let authSetting = res.authSetting
if (authSetting['scope.userLocation']) {
// 已授权
_this.getLocation()
_this.setData({
isAuthLocation: true
})
} else {
if (typeof(authSetting['scope.userLocation']) !== 'undefined') {
wx.showModal({
title: '您未开启地理位置授权',
content: '点击确定去开启地理位置授权',
success: res => {
if (res.confirm) {
wx.openSetting()
}
}
})
} else {
_this.getLocation()
}
}
}
})
}
},
getLocation() {
let _this = this
wx.getLocation({
type: 'gcj02',
success (res) {
_this.setData({
longitude: res.longitude,
latitude: res.latitude
})
if (_this.data.includePoints.length > 0) { // 包含其他坐标点 不需将获取到的坐标移动到地图中心
_this.triggerEvent('locationCallback', {lat: res.latitude, lng: res.longitude})
} else {
_this.moveToLocation(res.latitude, res.longitude)
}
},
fail () {
if (_this.data.includePoints.length > 0) { // 包含其他坐标点 不需将获取到的坐标移动到地图中心
_this.triggerEvent('locationCallback', {lat: _this.data.latitude, lng: _this.data.longitude})
} else {
_this.moveToLocation(_this.data.latitude, _this.data.longitude)
}
}
})
}
},
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="map-wrap">
<!-- 地图组件 -->
<map id="{{mapId}}" class="my-map" polyline="{{polyline}}" markers="{{markers}}" longitude="{{currentLo}}" latitude="{{currentLa}}" scale="{{scale}}" enable-satellite="{{enableSatellite}}" bindmarkertap="bindmarkertap" data-num="1" include-points="{{inPoints}}" enable-traffic="{{enableTraffic}}" show-location bindtap="mapClick">
</map>
<!-- 地图控件 -->
<text class="icon icon-locate map-cmd-icon" catchtap="locateClick">
<text class="{{isCanClick ? 'hidden' : 'show-class'}}">
<text class="count-down-left">
<text class="count-down-left-ring"></text>
</text>
<text class="count-down-right">
<text class="count-down-right-ring"></text>
</text>
</text>
</text>
<text class="icon icon-refresh map-cmd-icon" catchtap="refreshClick"></text>
<view class="map-type-list">
<view class="icon icon-satel {{enableSatellite ? 'active' : ''}}" catchtap="layerClick" data-num="1"></view>
<view class="icon icon-redgreen {{enableTraffic ? 'active' : ''}}" catchtap="layerClick" data-num="2"></view>
</view>
<view class="map-size-list">
<view class="icon icon-plus" catchtap="layerClick" data-num="3"></view>
<view class="icon icon-minus" catchtap="layerClick" data-num="4"></view>
</view>
<view class="loading {{isLoading ? 'active' : ''}}" id="loading"><view class="weui-loading"></view></view>
</view>
\ No newline at end of file
This diff could not be displayed because it is too large.

3.5 KB | W: | H:

3.8 KB | W: | H:

images/car.png
images/car.png
images/car.png
images/car.png
  • 2-up
  • Swipe
  • Onion skin

3.54 KB | W: | H:

3.73 KB | W: | H:

images/oncar.png
images/oncar.png
images/oncar.png
images/oncar.png
  • 2-up
  • Swipe
  • Onion skin
......@@ -75,7 +75,7 @@
<view hidden="{{preventAlarmList.length}}" class="list-none-tip">暂无数据</view>
<scroll-view scroll-top="{{scrollTop}}" scroll-y="true" style="height:{{scrollHeight}}px;"
class="list" bindscrolltolower="bindPreventAlarmDownLoad">
<view class="main-box" wx:for="{{preventAlarmList}}" >
<view class="main-box" wx:for="{{preventAlarmList}}" wx:key="index">
<view class="weui-cell box">
<view class="weui-cell__bd">
<view>{{item.name}}:{{item.standno}}</view>
......@@ -104,7 +104,7 @@
<view hidden="{{fenceAlarmList.length}}" class="list-none-tip">暂无数据</view>
<scroll-view scroll-top="{{scrollTop}}" scroll-y="true" style="height:{{scrollHeight}}px;"
class="list" bindscrolltolower="bindfenceAlarmDownLoad">
<view class="main-box" wx:for="{{fenceAlarmList}}">
<view class="main-box" wx:for="{{fenceAlarmList}}" wx:key="index">
<view class="weui-cell box">
<view class="weui-cell__bd">
<view>{{item.name}}:{{item.standno}}</view>
......@@ -128,7 +128,7 @@
<view hidden="{{offlineList.length}}" class="list-none-tip">暂无数据</view>
<scroll-view scroll-top="{{scrollTop}}" scroll-y="true" style="height:{{scrollHeight}}px;"
class="list" bindscrolltolower="bindOfflineDownLoad">
<view class="main-box" wx:for="{{offlineList}}">
<view class="main-box" wx:for="{{offlineList}}" wx:key="index">
<view class="weui-cell box">
<view class="weui-cell__bd">
<view>{{item.name}}:{{item.standno}}</view>
......@@ -152,7 +152,7 @@
<view hidden="{{lowBatteryList.length}}" class="list-none-tip">暂无数据</view>
<scroll-view scroll-top="{{scrollTop}}" scroll-y="true" style="height:{{scrollHeight}}px;"
class="list" bindscrolltolower="bindLowBatteryDownLoad">
<view class="main-box" wx:for="{{lowBatteryList}}">
<view class="main-box" wx:for="{{lowBatteryList}}" wx:key="index">
<view class="weui-cell box">
<view class="weui-cell__bd">
<view>{{item.name}}:{{item.standno}}</view>
......
......@@ -6,7 +6,9 @@ Page({
*/
data: {
modalHidden: true,
userInfoAuth: true
userInfoAuth: true,
isSharePage: false,
sns: null
},
/**
......@@ -26,6 +28,20 @@ Page({
}else{
wx.setStorageSync('carShareInfo', null)
}
if(options.sns){ // 新e盾找车
this.setData({
sns: decodeURIComponent(options.sns)
})
} else {
this.setData({
sns: null
})
}
if (options.isSharePage) {
this.setData({
isSharePage: true
})
}
/* wx.showModal({
content: String(options.test),
......@@ -73,9 +89,16 @@ Page({
}
});
}else if(userStatus === 1){
wx.switchTab({
url: '../../pages/findCar/findCar'
});
if (!this.data.isSharePage) { // 老e盾页面分享
wx.switchTab({
url: '../../pages/findCar/findCar'
});
} else {
wx.reLaunch({
url: `../../pages/newFindCar/findCar?sns=${encodeURIComponent(this.data.sns)}&isSharePage=true`
});
}
}else if(userStatus === 0){
wx.setStorageSync('carShareInfo', null);
wx.switchTab({
......@@ -151,9 +174,15 @@ Page({
wx.setStorageSync("sessionid", res.header["Set-Cookie"]);
wx.setStorageSync("userStatus", 1);
wx.setStorageSync("userinfo", data.data);
wx.switchTab({
url: '../../pages/findCar/findCar'
});
if (!this.data.isSharePage) {
wx.switchTab({
url: '../../pages/findCar/findCar'
});
} else { // 新e盾分享页
wx.reLaunch({
url: `../../pages/newFindCar/findCar?sns=${encodeURIComponent(this.data.sns)}&isSharePage=true`
});
}
}else{
wx.showModal({
content: data.message,
......
var amapFile = require('../../utils/amap-wx.js');
Page({
data: {
key: 'a73a63f8fb5ae0c9fe7d6303624c2e8c',
show: false,
currentLo: null,
currentLa: null,
newCurrentLo: null,
newCurrentLa: null,
distance: 0,
duration: 0,
markers: null,
scale: 16,
polyline: null,
statusType: 'car',
includePoints: []
},
onLoad() {
var _this = this;
wx.getLocation({
success(res) {
_this.setData({
currentLo: res.longitude,
currentLa: res.latitude,
includePoints: [{
longitude: res.longitude,
latitude: res.latitude
}],
markers: [{
id: 0,
longitude: res.longitude,
latitude: res.latitude,
title: res.address,
iconPath: '../../src/images/navi_s.png',
width: 32,
height: 32
}]
});
}
})
},
getAddress(e) {
var _this = this;
wx.chooseLocation({
success(res) {
var markers = _this.data.markers;
markers.push({
id: 0,
longitude: res.longitude,
latitude: res.latitude,
title: res.address,
iconPath: '../../src/images/navi_e.png',
width: 32,
height: 32
});
var points = _this.data.includePoints;
points.push({
longitude: res.longitude,
latitude: res.latitude
});
_this.setData({
newCurrentLo: res.longitude,
newCurrentLa: res.latitude,
includePoints: points,
markers: markers,
show: true
});
_this.getPolyline(_this.data.statusType);
}
});
},
drawPolyline(self, color) {
return {
origin: this.data.currentLo + ',' + this.data.currentLa,
destination: this.data.newCurrentLo + ',' + this.data.newCurrentLa,
success(data) {
var points = [];
if (data.paths && data.paths[0] && data.paths[0].steps) {
var steps = data.paths[0].steps;
for (var i = 0; i < steps.length; i++) {
var poLen = steps[i].polyline.split(';');
for (var j = 0; j < poLen.length; j++) {
points.push({
longitude: parseFloat(poLen[j].split(',')[0]),
latitude: parseFloat(poLen[j].split(',')[1])
})
}
}
}
self.setData({
distance: data.paths[0].distance,
duration: parseInt(data.paths[0].duration / 60),
polyline: [{
points: points,
color: color,
width: 6,
arrowLine: true
}]
});
}
}
},
getPolyline(_type) {
var amap = new amapFile.AMapWX({ key: this.data.key });
var self = this;
switch (_type) {
case 'car':
amap.getDrivingRoute(this.drawPolyline(this, "#0091ff"));
break;
case 'walk':
amap.getWalkingRoute(this.drawPolyline(this, "#1afa29"));
break;
case 'ride':
amap.getRidingRoute(this.drawPolyline(this, "#1296db"));
break;
default:
return false;
}
},
goTo(e) {
var _type = e.currentTarget.dataset.type;
this.setData({ statusType: _type });
this.getPolyline(_type);
}
})
\ No newline at end of file
{
"tabBar": {
"list": []
}
}
\ No newline at end of file
<view class="tui-map">
<map id="map" longitude="{{currentLo}}" latitude="{{currentLa}}" scale="{{scale}}" markers="{{markers}}" polyline="{{polyline}}" include-points="{{includePoints}}" show-location style="width: 100%; height: 100%;"></map>
</view>
<view class="tui-map-search" bindtap="getAddress">
<icon size='20' type='search' class='tui-map-search-icon'></icon>
<input class="tui-map-input" placeholder="搜索" focus="{{focusStatus}}"></input>
</view>
<view class="tui-search-bottom {{show ? '' : 'tui-hide'}}">
<view class="page-group">
<view class="page-nav-list {{statusType == 'car' ? 'active' : ''}}" data-type="car" bindtap="goTo">驾车</view>
<view class="page-nav-list {{statusType == 'walk' ? 'active' : ''}}" data-type="walk" bindtap="goTo">步行</view>
<view class="page-nav-list {{statusType == 'ride' ? 'active' : ''}}" data-type="ride" bindtap="goTo">骑行</view>
</view>
<view class="tui-warn">
{{distance}}米
</view>
<view class="tui-warn">
{{duration}}分钟
</view>
</view>
.tui-map-search{
width: 100%;
height: 80rpx;
position: fixed;
top: 0;
left: 0;
z-index: 1000000;
box-sizing: border-box;
padding: 5rpx 10px;
background-color: #fff;
line-height: 70rpx;
}
.tui-map-input{
height: 70rpx;
line-height: 70rpx;
font-size: 30rpx;
margin-left: 25px;
}
.tui-map-search-icon{
position: absolute;
top: calc(50% - 10px);
left: 10px;
}
.tui-map{
width: 100%;
height: calc(100% - 80rpx);
position: fixed;
bottom: 0;
left: 0;
}
.tui-map-direction{
width: 32px;
height: 32px;
position: fixed;
right: 10px;
bottom: 80px;
z-index: 100000;
}
.page-group{
display: table;
width: 100%;
table-layout: fixed;
background-color: #fff;
}
.page-nav-list{
padding:20rpx 0 ;
font-size: 30rpx;
display: table-cell;
text-align: center;
width: 100%;
color: #222;
}
.page-nav-list.active{color:blue;}
.tui-warn{
height: 50px;
line-height: 50px;
padding-left: 10px;
color: lightseagreen;
font-size: 30rpx;
}
.tui-search-bottom{
height: 150px;
background: #fff;
width: 100%;
position: fixed;
bottom: 0;
left: 0;
z-index: 1000;
}
\ No newline at end of file
......@@ -56,7 +56,12 @@ Page({
url: `../../pages/freqLogUserDetail/freqLogUserDetail?nickname=${this.data.username}&avatarurl=${this.data.avatarUrl}&id=${wx.getStorageSync("userinfo").id}`
});
}
},
// 新E盾找车
NewEFindCar() {
wx.navigateTo({
url: '../../pages/newFindSearch/findSearch'
});
},
/**
* 生命周期函数--监听页面加载
......
......@@ -33,6 +33,10 @@
<image src="../../images/cmd-freqlog.png"/>调频记录
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</view>
<view class="weui-cell active" bindtap="NewEFindCar">
<image src="../../images/new-findCar.png"/>"新E盾"找车
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</view>
</view>
<view class="cmd-list logout" bindtap="logout" hidden="{{false}}">
退出登录
......
{
"usingComponents": {
"myMap": "../../components/myMap/myMap"
},
"navigationBarTitleText": "找车"
}
\ No newline at end of file
<view class="findCar_content">
<myMap class="my-map" id="findcarMap" mapId="findcarMap" bind:bindmarkertap="bindmarkertap" 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="{{isShowCarInfoWindow}}" class="customCallout {{isShowCarInfoWindow ? '' : 'hidden'}}">
<view class="car-info-window">
<view class="main-info">
<view class="info-title">
<view class="carInfoName">{{carInfoWindowObj.ownerName || ''}}</view>
<view class="carInfoStandno">{{carInfoWindowObj.vin}}</view>
<icon class="close_btn" type="cancel" size="23" color="#000" bindtap="closeCarWindow"></icon>
</view>
<view class="info-list">
<view class="battery {{carInfoWindowObj.battery < 20 ? 'empty' : ''}}" wx:if="{{carInfoWindowObj.source !== 1 && carInfoWindowObj.battery}}">
<view style="width: {{carInfoWindowObj.battery + '%'}}; margin-top: 2rpx;" class="fill"></view>
<icon class="icon {{carInfoWindowObj.battery < 20 ? 'icon-battery-empty' : 'icon-battery-enough'}}"></icon>
<view class="text">{{carInfoWindowObj.battery < 20 ? '不足' : carInfoWindowObj.battery}}</view>
</view>
<view class="flex_class device-info">
<icon class="icon icon-device"></icon>
<view class="inline-b">{{(carInfoWindowObj.source === 0 ? '无线设备' : carInfoWindowObj.source === 1 ? '有线设备' : '') + ':' + carInfoWindowObj.sn}}</view>
</view>
<view class="flex_class offline-info" wx:if="{{carInfoWindowObj[carInfoWindowObj['type']].offLineDuration}}">
<icon class="icon icon-offline"></icon>
<view class="inline-b">{{'离线:' + carInfoWindowObj[carInfoWindowObj['type']].offLineDuration}}</view>
</view>
<view class="flex_class time-info">
<icon class="icon icon-time"></icon>
<view class="inline-b">{{carInfoWindowObj[carInfoWindowObj['type']].dateTime}}</view>
</view>
<view class="flex_class locate-info">
<icon class="icon icon-locate-sm"></icon>
<view class="inline-b">{{carInfoWindowObj[carInfoWindowObj['type']].transferAddress}}</view>
</view>
<view class="flex_class list-info">
<icon class="icon icon-list"></icon>
<view>定位类型:</view>
<view class="radio-class" bindtap="typeChange" data-num="1">
<icon class="icon icon-info-radio {{carInfoWindowObj.type === 'gpsLocation' ? 'active' : ''}}"></icon>
<view data="1">GPS</view>
</view>
<view class="radio-class" bindtap="typeChange" data-num="2">
<icon class="icon icon-info-radio {{carInfoWindowObj.type === 'gpsLocation' ? '' : 'active'}}"></icon>
<view data="2">基站</view>
</view>
</view>
</view>
</view>
<view class="cmd-list">
<view bindtap="{{isOpenWechatMap ? 'carInfoTrace' : ''}}">车辆追踪</view>
<view bindtap="traReplay">轨迹回放</view>
<view bindtap="monitor">实时监控</view>
<view bindtap="share" wx:if="{{!isSharePage}}">分享找车</view>
<!-- <view bindtap="carInfoMore">更多</view> -->
</view>
</view>
</view>
<!-- 更多 -->
<!-- <view id="sidebar" class="sidebar {{isShowSidebar ? '' : 'hidden'}}" catchtap="clickSideBar">
<view class="sidebar-nav" catchtap="clickSideBarNav">
<view class="weui-cells">
<view class="weui-cell weui-cell_access {{loginUserId ? '' : 'disabled'}}" bindtap="monitor">
<view class="weui-cell__bd">
<icon class="icon icon-more-monitor"></icon><text class="more-monitor">实时监控</text>
</view>
<image src="../../images/arrow-right.png" class="arrow-right"></image>
</view>
<view class="weui-cell weui-cell_access disabled">
<view class="weui-cell__bd">
<icon class="icon icon-more-freq"></icon><text class="more-freq">设备调频</text>
</view>
<image src="../../images/arrow-right.png" class="arrow-right"></image>
</view>
<view class="weui-cell weui-cell_access disabled">
<view class="weui-cell__bd">
<icon class="icon icon-more-fence"></icon><text class="more-fence">电子围栏</text>
</view>
<image src="../../images/arrow-right.png" class="arrow-right"></image>
</view>
<view class="weui-cell weui-cell_access {{loginUserId ? '' : 'disabled'}}" bindtap="share">
<view class="weui-cell__bd">
<icon class="icon icon-more-share"></icon><text class="more-share">分享找车</text>
</view>
<image src="../../images/arrow-right.png" class="arrow-right"></image>
</view>
</view>
</view>
</view> -->
<!-- 被分享者进入提醒 -->
<!-- <view class="share-tip {{isSharePage ? 'active' : ''}}">
<view><icon class="icon-small" type="info_circle" size="23"></icon>提示:此分享功能请在有效时间内使用,详情联系分享者</view>
</view> -->
<!-- 分享 -->
<view class="share-cover {{ShowShareModel ? 'active' : ''}}" bindtap="clickShareModel">
<icon class="icon icon-share"></icon>
<view class="tip">“点击右上角转发分享”</view>
</view>
</view>
\ No newline at end of file
.flex-wrp{
display: flex;
}
.icon-findcar {
width: 132rpx;
height: 132rpx;
background-position: 0rpx 0rpx;
position: fixed;
z-index: 20;
bottom: 40rpx;
left: 50%;
transform: translate(-50%, 0);
}
.icon-findcar:active {
width: 132rpx;
height: 132rpx;
background-position: -132rpx 0rpx;
}
.customCallout {
position: fixed;
top: 0;
left: 0;
width: 100%;
animation: topShow .3s;
z-index: 400;
opacity: 1;
}
.hidden {
top: -100%;
background: none;
animation: topHide .5s;
/* opacity: 0; */
}
.car-info-window {
width: 100%;
background-color: #fff;
border-radius: 8rpx;
border: 2rpx solid #ececec;
color: #666;
word-break: break-all;
user-select: text;
}
.car-info-window view{
font-size: 28rpx;
}
.car-info-window .main-info {
padding: 20rpx;
}
.car-info-window .info-list {
position: relative;
padding-top: 20rpx;
}
.car-info-window .info-list .inline-b{
display: inline-block;
white-space: normal;
width: 100%;
}
.car-info-window .info-list .flex_class {
display: flex;
align-items: flex-start;
}
.car-info-window .info-list .list-info{
align-items: center;
}
.car-info-window .info-list .device-info .icon-device{
width: 42rpx;
height: 42rpx;
background-position: -482rpx -84rpx;
}
.car-info-window .info-list .battery .icon-battery-empty{
width: 76rpx;
height: 40rpx;
position: absolute;
top: 2rpx;
left: 0;
background-position: -182rpx -423rpx;
}
.car-info-window .info-list .battery .icon-battery-enough{
width: 76rpx;
height: 40rpx;
position: absolute;
top: 2rpx;
left: 0;
background-position: -108rpx -423rpx;
}
.car-info-window .info-list .battery .text{
top: 4rpx;
}
.car-info-window .info-list .offline-info .icon-offline{
width: 42rpx;
height: 42rpx;
background-position: -482rpx 0rpx;
}
.car-info-window .info-list .time-info .icon-time{
width: 42rpx;
height: 42rpx;
background-position: -482rpx -42rpx;
}
.car-info-window .info-list .locate-info .icon-locate-sm{
width: 42rpx;
height: 42rpx;
background-position: -482rpx -168rpx;
}
.car-info-window .info-list .list-info .icon-list{
width: 42rpx;
height: 42rpx;
background-position: -436rpx -250rpx;
}
.car-info-window .info-list .list-info .icon-info-radio{
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
background-position: -482rpx -270rpx;
}
.car-info-window .info-list .list-info .active{
width: 32rpx;
height: 32rpx;
margin-right: 10rpx;
background-position: -482rpx -300rpx;
}
.car-info-window .info-list .list-info .radio-class {
margin-right: 20rpx;
display: flex;
align-items: center;
}
.car-info-window .info-title {
font-weight: normal;
border-bottom: 2rpx solid #ececec;
padding-bottom: 20rpx;
font-size: 32rpx;
color: #333;
}
.car-info-window .info-title .close_btn{
float: right;
margin-right: 30rpx;
}
.car-info-window .info-title view {
margin-right: 20rpx;
display: inline-block;
}
.car-info-window .icon {
vertical-align: middle;
margin-right: 10rpx;
display: inline-block;
}
.car-info-window .cmd-list {
display: flex;
border-top: 2rpx solid #ececec;
}
.car-info-window .cmd-list view {
flex: 1;
text-align: center;
padding: 10rpx 0;
border-right: 2rpx solid #ececec;
}
.car-info-window .cmd-list view:last-child {
border-right: none;
}
.car-info-window .battery {
position: absolute;
top: 20rpx;
right: 0rpx;
width: 74rpx;
height: 38rpx;
word-break: break-all;
}
.car-info-window .battery > view {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
.car-info-window .battery .fill {
background-color: #d4f1dc;
}
.car-info-window .battery .text {
color: #37c060;
font-size: 12px;
text-align: center;
}
.car-info-window .battery.empty .fill {
background-color: #f0d0d0;
}
.car-info-window .battery.empty .text {
color: #df2222;
}
.icon-wrap{
position: fixed;
}
.icon-wrap cover-image{
display: inline-block;
width: 100%;
height: 100%;
}
.icon-wrap cover-image.active{
display: none;
}
.icon-wrap.hover cover-image{
display: none;
}
.icon-wrap.hover cover-image.active{
display: inline-block;
}
.findcar-icon-wrap{
left: 50%;
bottom: 20rpx;
margin-left: -66rpx;
width: 132rpx;
height: 132rpx;
}
.locate-icon-wrap{
left: 30rpx;
bottom: 40rpx;
width: 98rpx;
height: 98rpx;
}
.refresh-icon-wrap{
left: 30rpx;
bottom: 160rpx;
width: 98rpx;
height: 98rpx;
}
.sidebar {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
animation: sidebarShow 1s;
z-index: 400;
opacity: 1;
}
.sidebar.hidden {
left: -100%;
background: none;
animation: sidebarHide 1s;
opacity: 0;
}
.sidebar .sidebar-nav {
width: 70%;
height: 100%;
background-color: #fff;
padding: 0;
display: flex;
flex-direction: column;
}
.sidebar .sidebar-nav .weui-cells {
margin-top: 0;
}
.sidebar .sidebar-nav .weui-cells .icon {
vertical-align: middle;
margin-right: 20rpx;
}
.sidebar .sidebar-nav .weui-cell.disabled {
opacity: 0.4;
}
.icon-more-monitor{
width: 30rpx;
height: 30rpx;
background-position: -482rpx -330rpx;
}
.icon-more-freq{
width: 30rpx;
height: 30rpx;
background-position: -482rpx -240rpx;
}
.icon-more-fence{
width: 30rpx;
height: 30rpx;
background-position: -482rpx -210rpx;
}
.icon-more-share{
width: 30rpx;
height: 30rpx;
background-position: -482rpx -360rpx;
}
.arrow-right{
display: inline-block;
width: 16rpx;
height: 25rpx;
margin-right: 10rpx;
}
.share-tip {
position: fixed;
top: 0px;
left: 50%;
margin-left: -280rpx;
width: 520rpx;
padding: 10rpx 20rpx;
background-color: rgba(0, 0, 0, 0.5);
z-index: 300;
color: #f3f3f3;
display: none;
}
.share-tip.active {
display: block;
}
.share-tip .icon-small {
margin-right: 10rpx;
}
.share-cover {
position: fixed;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
z-index: 600;
display: none;
}
.share-cover.active {
display: block;
}
.share-cover > .icon-share {
position: absolute;
top: 20rpx;
right: 150rpx;
}
.share-cover > .tip {
margin-top: 120rpx;
text-align: center;
color: #fff;
font-size: 36rpx;
}
.icon-share {
width: 68rpx;
height: 80rpx;
background-position: -384rpx -98rpx;
}
@keyframes topShow {
from {
transform: translate(0, -100%); }
to {
transform: translate(0, 0);
}
}
@keyframes topHide {
from {
top: 0;
}
to {
top: -100%;
}
}
@keyframes sidebarHide
{
from {
left: 0;
}
to {
left: -100%;
}
}
@keyframes sidebarShow
{
0% {
left: -100%;
background: none;
}
25% {
left: 0;
background: none;
}
100%{
background: rgba(0,0,0,0.5);
}
}
\ No newline at end of file
const WXRequest = require('../../utils/wxrequest.js');
Page({
data: {
inputVal: '',
searchTypes: [{
label: '申请单号',
value: '4'
},{
label: '车架号',
value: '2'
},{
label: '设备号',
value: '1'
}
// {
// label: '姓名',
// value: '3'
// }
],
placeholders: [
'请输入完整的申请单号',
'请输入完整的车架号',
'请输入设备SN',
'请输入客户姓名'
],
searchTypesIndex: 0,
list: [],
scrollTop: 0,
scrollHeight: 300,
page: 1,
maxPage: 0,
ing: false,
initSearch: false,
},
onLoad(option) {
var that = this;
wx.getSystemInfo({
success: function(res) {
that.setData({
scrollHeight: res.windowHeight-50
})
}
});
},
clearInput: function () {
this.setData({
inputVal: ""
});
},
inputTyping: function (e) {
this.setData({
inputVal: e.detail.value
});
},
searchConfirm(e){
this.setData({
ing: false,
page: 1,
scrollTop: 0
});
this.loadData();
},
loadData(isInit){
var that = this;
if(!isInit && !that.validate()) return;
that.setData({
ing: true
});
let params = {
termType: that.data.searchTypes[that.data.searchTypesIndex].value,
term: that.data.inputVal,
pageSize: 10,
pageNumber: that.data.page
}
WXRequest.get('trialdrive/api/vehicle/search',params, true).then((res)=>{
if(!that.data.ing) return;
const _list = res.data && res.data.list;
const maxPage = res.data && res.data.totalPages;
if(_list){
_list.forEach((item)=>{
const deviceObj = {}
let encrySns = [] // 加密设备号
item.devices&&item.devices.forEach((deviceItem)=>{
deviceItem.wireType = deviceItem.wireType === 0 ? '无线设备' : deviceItem.wireType === 1 ? '有线设备' : ''
if(!deviceObj[deviceItem.wireType]){
deviceObj[deviceItem.wireType] = [];
}
deviceObj[deviceItem.wireType].push(deviceItem.sn);
encrySns.push(deviceItem.deviceCode)
item.encrySns = encrySns.join(',')
});
item.deviceList = [];
for(let type in deviceObj){
item.deviceList.push({
type: type,
sns: deviceObj[type]
});
}
});
that.setData({
list: that.data.page===1?_list:that.data.list.concat(_list),
ing: false,
maxPage,
initSearch: true
});
} else {
that.setData({
list: [],
ing: false,
maxPage
});
}
})
},
searchTypeChange(e){
this.setData({
searchTypesIndex: e.detail.value
});
if(!this.data.inputVal) return;
this.setData({
ing: false,
page: 1,
scrollTop: 0
});
this.loadData()
},
bindDownLoad(){
if(this.data.ing) return;
const nextPage = this.data.page+1;
if(nextPage>this.data.maxPage) return;
this.setData({
page: nextPage
});
this.loadData();
},
bindScroll(){
},
validate(){
const type = this.data.searchTypes[this.data.searchTypesIndex].value;
const inputVal = this.data.inputVal;
if(type === '3'){//姓名
if(inputVal.length<2){
wx.showToast({
title: '请输入正确的姓名,至少2个字',
icon: 'none'
});
return false;
}
}else if(inputVal.length<6){
wx.showToast({
title: '请输入至少6位数',
icon: 'none'
});
return false;
}
return true;
},
redirectDetail(e){
const dataset = e.currentTarget.dataset;
wx.navigateTo({
url: `../../pages/newFindCar/findCar?sns=${encodeURIComponent(dataset.sns)}`,
})
}
})
\ No newline at end of file
{}
\ No newline at end of file
<view class="serach-box">
<view class="weui-search-bar__form">
<view class="weui-search-bar__box search-wrap">
<icon class="weui-icon-search_in-box" type="search" size="14"></icon>
<input
type="text"
class="weui-search-bar__input"
placeholder="{{placeholders[searchTypesIndex]}}"
value="{{inputVal}}"
focus="{{inputShowed}}"
bindinput="inputTyping"
bindconfirm="searchConfirm"/>
<view class="weui-icon-clear" wx:if="{{inputVal.length > 0}}" bindtap="clearInput">
<icon type="clear" size="14"></icon>
</view>
<picker
class="search-picker"
bindchange="searchTypeChange"
value="{{searchTypesIndex}}"
range="{{searchTypes}}"
range-key="label">
<text>{{searchTypes[searchTypesIndex].label}}</text>
<view class="select-dropdown-icon"></view>
</picker>
</view>
</view>
</view>
<view class="result-list" hidden="{{!list.length}}">
<scroll-view
scroll-top="{{scrollTop}}"
scroll-y="true"
style="height:{{scrollHeight}}px;"
bindscrolltolower="bindDownLoad"
bindscroll="bindScroll">
<view class="weui-cell"
wx:for="{{list}}"
wx:key="index"
bindtap="redirectDetail"
data-sns="{{item.encrySns}}">
<view class="weui-cell__bd">
<view class="title"><text class="name">{{item.ownerName || ''}}</text> {{item.vin}}</view>
<view class="sub-title"><text class="label">申请单号:</text> {{item.orderNo||''}}</view>
<view wx:for="{{item.deviceList}}" wx:key="index" class="sub-list">
<text class="label">{{item.type}}:</text>
<view class="sub-item">
<view wx:for="{{item.sns}}" wx:key="index">{{item}}</view>
</view>
</view>
</view>
</view>
<view class="end-tip" hidden="{{page!=maxPage}}">
没有更多数据了~
</view>
</scroll-view>
</view>
<view class="none" hidden="{{!initSearch || list.length}}">
<image src="../../images/none.png"/>
<view>没有搜索到匹配的车辆数据</view>
</view>
.serach-box{
padding: 20rpx;
background-color: #fff;
}
.search-wrap{
position: relative;
padding-right: 240rpx;
}
.search-wrap input{
}
.search-picker{
position: absolute;
top: 0;
right: 0;
font-size: 28rpx;
}
.search-picker text{
position: absolute;
display: inline-block;
width: 140rpx;
right: 40rpx;
height: 56rpx;
line-height: 56rpx;
padding-left: 20rpx;
border-left: 2rpx solid #eee;
}
.select-dropdown-icon{
content: '';
display: inline-block;
border: 10rpx solid transparent;
border-top-color: #c9c9c9;
position: absolute;
right: 20rpx;
top: 20rpx;
}
.search-wrap .weui-icon-clear{
right: 200rpx;
z-index: 100;
}
.result-list{
background-color: #fff;
color: #666;
font-size: 28rpx;
}
.result-list .title{
color: #000;
}
.result-list .name{
margin-right: 20rpx;
}
.result-list .label{
margin-right: 20rpx;
float: left;
}
.sub-list{
overflow: hidden;
}
.sub-item{
float: left;
}
.sub-title{
overflow: hidden;
}
.result-list .weui-cell:first-child{
border-top: 2rpx solid #d9d9d9;
}
.result-list .weui-cell:last-child{
border-bottom: 2rpx solid #d9d9d9;
}
.none{
padding: 200rpx 0;
text-align: center;
color: #999;
}
.none image{
width: 400rpx;
height: 400rpx;
margin-bottom: 20rpx;
}
.end-tip{
text-align: center;
}
\ No newline at end of file
const WXRequest = require('../../utils/wxrequest.js');
let timeoutId
Page({
/**
* 页面的初始数据
*/
data: {
sns: '',
points: [],
carMarkers: [],
firstPosLng: null, // 首次获取的位置坐标
firstPosLat: null, // 首次获取的位置坐标
listData: [],
isShowList: true,
carLocationObj: {},
scrollIntoViewIndex: '_1',
includePoints: []
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
sns: decodeURIComponent(options.sn)
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.myMap = this.selectComponent('#monitorMap')
this.getPosition()
},
// 刷新
refresh() {
this.setData({
carMarkers: [],
listData: []
})
this.myMap.getMapCtx().removeMarkers({
markerIds: [1, 2]
})
this.myMap.setData({
polyline: []
})
this.getPosition()
timeoutId && clearTimeout(timeoutId)
},
// 获取定位
locationCallback(e) {
let data = JSON.parse(JSON.stringify(this.data.includePoints))
let isHad = data.length && data.find((item) => item.latitude === e.detail.lat && item.longitude === e.detail.lng)
if (!isHad) {
data.push({
latitude: e.detail.lat,
longitude: e.detail.lng
})
}
this.myMap.getMapCtx().includePoints({
points: data,
padding: [60, 60, 60, 60],
success: (res) => {
}
})
},
// 获取车的实时定位
getPosition() {
let listData = this.data.listData
let points = this.data.points
WXRequest.get('trialdrive/api/vehicle/location', {
sns: this.data.sns
}, true, true).then(e => {
let includePoints = this.data.includePoints
if (e.code == 200 && e.data.length > 0) {
// 逆地址解析
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,
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)
listData.push({
transferAddress: transferAddress,
time: e.data[0].gpsLocation.dateTime
})
if (listData.length > 3) listData.shift() // 最多展示最新三条数据
this.setData({
listData: listData,
scrollIntoViewIndex: '_' + listData.length
})
let isHad = includePoints.length && includePoints.find((item) => item.latitude === e.data[0].gpsLocation.elat && item.longitude === e.data[0].gpsLocation.elng)
if (!isHad) {
includePoints.push({
latitude: e.data[0].gpsLocation.elat,
longitude: e.data[0].gpsLocation.elng
})
}
this.setData({
includePoints: includePoints
})
if (this.data.carMarkers.length <= 0) {
let marker = [{
id: 1,
width: 15,
height: 25,
latitude: e.data[0].gpsLocation.elat,
longitude: e.data[0].gpsLocation.elng,
iconPath: '../../images/car.png'
}]
this.myMap.getMapCtx().addMarkers({
markers: marker,
success: () => {
points.push({
latitude: Number(e.data[0].gpsLocation.elat),
longitude: Number(e.data[0].gpsLocation.elng),
})
this.setData({
carMarkers: marker,
points: points,
firstPosLat: Number(e.data[0].gpsLocation.elat),
firstPosLng: Number(e.data[0].gpsLocation.elng)
})
this.moveToLocation(Number(e.data[0].gpsLocation.elat), Number(e.data[0].gpsLocation.elng))
}
})
} else {
if (this.data.firstPosLat !== (Number(e.data[0].gpsLocation.elat)) || this.data.firstPosLng !== (Number(e.data[0].gpsLocation.elng))) {
let marker = [{
id: 2,
width: 15,
height: 25,
latitude: Number(this.data.firstPosLat),
longitude: Number(this.data.firstPosLng),
iconPath: '../../images/begin.png'
}]
this.myMap.getMapCtx().addMarkers({
markers: marker,
success: () => {
let arr = [{
latitude: Number(e.data[0].gpsLocation.elat),
longitude: Number(e.data[0].gpsLocation.elng)
}]
this.myMap.getMapCtx().translateMarker({
markerId: 1,
destination: {
longitude: Number(e.data[0].gpsLocation.elng),
latitude: Number(e.data[0].gpsLocation.elat),
},
duration: 500,
animationEnd: () => {
this.moveToLocation(Number(e.data[0].gpsLocation.elat), Number(e.data[0].gpsLocation.elng))
this.setData({
points: points.concat(arr),
})
this.myMap.setData({
polyline: [{
points: points.concat(arr),
color: '#0b94db',
width: 6,
arrowLine: true
}]
})
}
})
}
})
} else {
this.moveToLocation(Number(e.data[0].gpsLocation.elat), Number(e.data[0].gpsLocation.elng))
}
}
timeoutId = setTimeout(() => {
this.getPosition()
}, 10*1000)
}
}
})
}
})
},
listIconBatch() {
this.setData({
isShowList: !this.data.isShowList
})
},
moveToLocation: function (latitude, longitude ) {
this.myMap.getMapCtx().moveToLocation({
longitude: Number(longitude),
latitude: Number(latitude)
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
timeoutId && clearTimeout(timeoutId)
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
timeoutId && clearTimeout(timeoutId)
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
// onShareAppMessage: function () {
// }
})
\ No newline at end of file
{
"usingComponents": {
"myMap": "../../components/myMap/myMap"
},
"navigationBarTitleText": "实时监控"
}
\ No newline at end of file
<view class="monitor_content">
<myMap class="my-map" id="monitorMap" mapId="monitorMap" includePoints="{{includePoints}}" markers="{{markers}}" bind:refresh="refresh" bind:mapCallback="mapCallback" bind:locationCallback="locationCallback"></myMap>
<view class="toggle-bottom {{isShowList ? '' : 'hidden'}}" id="toggleBottom">
<icon class="toggle-btn active icon {{isShowList ? 'icon-toggle-down' : 'icon-toggle-up'}}" bindtap="listIconBatch"></icon>
<scroll-view class="toggle-list" scroll-y="true" scroll-into-view="{{scrollIntoViewIndex}}">
<view id="{{'_' + (index + 1)}}" class="list-item" wx:for="{{listData}}" wx:key="index">
<view class="title">{{(index + 1) + '.' + item.transferAddress}}</view>
<view class="time">{{item.time}}</view>
</view>
</scroll-view>
</view>
</view>
.toggle-bottom {
position: fixed;
width: 100%;
left: 0rpx;
bottom: 0rpx;
animation: bottomShow .3s;
z-index: 1000;
}
.toggle-bottom .toggle-btn {
position: absolute;
top: -70rpx;
left: 50%;
transform: translate(-50%, 0);
visibility: hidden;
}
.toggle-bottom .toggle-btn.active {
visibility: visible;
}
.toggle-bottom .toggle-list {
background-color: #fff;
padding-left: 20rpx;
max-height: 346rpx;
overflow-y: scroll;
}
.toggle-bottom .toggle-list .list-item {
padding: 10rpx 20rpx 10rpx 20rpx;
border-bottom: 2rpx solid #ececec;
}
.toggle-bottom .toggle-list .list-item:last-child {
border-bottom: none;
}
.toggle-bottom .toggle-list .title {
color: #000;
font-size: 32rpx;
}
.toggle-bottom .toggle-list .time {
color: #666;
}
.toggle-bottom.hidden {
transform: translate(0, 100%);
animation: bottomHide .3s;
}
.icon-toggle-up {
width: 60rpx;
height: 62rpx;
background-position: -165rpx -350rpx;
}
.icon-toggle-down {
width: 61rpx;
height: 62rpx;
background-position: -105rpx -350rpx;
}
@keyframes bottomShow {
from {
transform: translate(0, 100%);
}
to {
transform: translate(0, 0);
}
}
@keyframes bottomHide {
from {
transform: translate(0, 0);
}
to {
transform: translate(0, 100%);
}
}
const WXRequest = require('../../utils/wxrequest.js');
const moment = require('../../utils/moment.min.js');
Page({
/**
* 页面的初始数据
*/
data: {
speedItems: [
{
label: '慢',
value: 0
},
{
label: '正常',
value: 1
},
{
label: '快',
value: 2
},
{
label: '很快',
value: 3
}
],
speedItemsIndex: 0,
isReplayIng: false,
markers: [],
isShowModel: false,
clickItem: null,
selectTime: '',
sn: null,
type: null,
durationArr: [20000, 15000, 10000, 5000],
optTime: moment().format('YYYY-MM-DD'),
allowClick: true
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
sn: decodeURIComponent(options.sn),
locationType: options.locationType == 'gpsLocation' ? 0 : 1
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.myMap = this.selectComponent('#traReplayMap')
},
// 刷新
refresh() {
if (this.myMap.data.polyline.length <= 0) return
this.setData({
clickItem: null,
selectTime: '',
includePoints: [],
speedItemsIndex: 0,
isReplayIng: false,
markers: []
})
this.myMap.setData({polyline: []})
this.myMap.getMapCtx().removeMarkers({
markerIds: [2]
})
},
// 获取定位
locationCallback(e) {
let data = JSON.parse(JSON.stringify(this.data.includePoints))
let isHad = data.length && data.find((item) => item.latitude === e.detail.lat && item.longitude === e.detail.lng)
if (!isHad) {
data.push({
latitude: e.detail.lat,
longitude: e.detail.lng
})
}
this.myMap.getMapCtx().includePoints({
points: data,
padding: [60, 60, 60, 60],
success: (res) => {
}
})
},
showModel() {
this.setData({
isShowModel: true
})
},
// 自定义时间段选择
dateChange(e) {
this.setData({
clickItem: null,
selectTime: e.detail.value
})
},
// 选择时间取消
cancel() {
this.setData({
isShowModel: false
})
},
// 选择时间确认
confirm() {
if (!this.data.clickItem && !this.data.selectTime) {
wx.showModal({
content: '请选择一个时间段',
showCancel: false
});
return false
} else {
this.setData({
isShowModel: false,
includePoints: [],
speedItemsIndex: 0,
isReplayIng: false,
markers: []
})
this.myMap.getMapCtx().removeMarkers({
markerIds: [2],
complete: () => {
this.getData()
}
})
}
},
// 选择固定时间段
timeClick(e) {
this.setData({
clickItem: e.currentTarget.dataset.time,
selectTime: ''
})
},
getData() {
let _sTime, _eTime
if(this.data.selectTime){
_sTime = this.data.selectTime+' 00:00:00';
_eTime = this.data.selectTime+' 23:59:59';
}else{
_eTime = moment().format('YYYY-MM-DD HH:mm:ss');
_sTime = moment().subtract('day', Number(this.data.clickItem)).format('YYYY-MM-DD HH:mm:ss');
}
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 arr = []
var polyline = []
if (res.code == 200) {
res.data.forEach(item => {
arr.push({
latitude: Number(item.elat),
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) {
polyline.push({
points: arr,
color: '#0b94db',
width: 6,
arrowLine: true
})
this.myMap.getMapCtx().includePoints({
points: arr,
padding: [40, 40, 40, 40]
})
this.setData({
includePoints: arr
})
this.myMap.setData({polyline: polyline})
} else {
wx.showModal({
content: '暂无数据',
showCancel: false
})
}
}
})
},
// 距离计算总和
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) {
this.setData({
speedItemsIndex: Number(e.detail.value)
})
this.beginTrack()
},
// 播放
play() {
this.beginTrack()
},
addmerker() {
let marker = [{
id: 105,
width: 15,
height: 25,
latitude: this.myMap.data.polyline[0].points[0].latitude,
longitude: this.myMap.data.polyline[0].points[0].longitude,
iconPath: '../../images/car.png'
}]
this.setData({
isReplayIng: true,
markers: marker
})
},
move() {
if (this.myMap.getMapCtx().moveAlong) {
this.myMap.getMapCtx().moveAlong({
markerId: 105,
path: this.myMap.data.polyline[0].points,
duration: this.data.durationArr[this.data.speedItemsIndex],
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.myMap.data.polyline.length) {
await this.addmerker()
await this.move()
}
},
// 暂停
pause() {
},
// 重新播放
replayRefresh() {
this.setData({
allowClick: false
})
this.beginTrack()
setTimeout(() => {
this.setData({
allowClick: true
})
}, 500)
},
// 点击地图回调
mapCallback(e) {
if (this.myMap.data.polyline.length <= 0) return
let transferAddress
// 删除上一个marker
this.myMap.getMapCtx().removeMarkers({
markerIds: [2]
})
// 逆地址解析
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,
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)
this.myMap.getMapCtx().addMarkers({
markers: [{
id: 2,
latitude: e.detail && e.detail.detail && e.detail.detail.latitude,
longitude: e.detail && e.detail.detail && e.detail.detail.longitude,
width: 20,
height: 30,
callout: {
content: transferAddress,
borderRadius: 10,
padding: 10,
display: 'ALWAYS'
}
}],
})
}
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
// onShareAppMessage: function () {
// }
})
\ No newline at end of file
{
"usingComponents": {
"myMap": "../../components/myMap/myMap"
},
"navigationBarTitleText": "轨迹回放"
}
\ No newline at end of file
<view class="traReplay_content">
<view class="tabbar">
<view class="tabbar-item" bindtap="showModel">轨迹时间</view>
<picker
class="tabbar-item"
bindchange="speedTypeChange"
value="{{speedItemsIndex}}"
range="{{speedItems}}"
range-key="label">
<text>回放速度 {{speedItems[speedItemsIndex].label}}</text>
<view class="select-dropdown-icon"></view>
</picker>
</view>
<myMap class="my-map" id="traReplayMap" mapId="traReplayMap" includePoints="{{includePoints}}" markers="{{markers}}" bind:refresh="refresh" bind:mapCallback="mapCallback" bind:locationCallback="locationCallback"></myMap>
<!-- 回放控制按钮 -->
<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="{{allowClick ? 'replayRefresh' : ''}}"></view>
</view>
<!-- 轨迹时间弹窗 -->
<view class="model_class" wx:if="{{isShowModel}}" slot="sidebar">
<view class="mode_box">
<view class="tilte_class">选择轨迹回放时间</view>
<view class="weui-flex time-choose" >
<view class="weui-flex__item {{clickItem === '1' ? 'weui-btn_plain-primary' : ''}}" bindtap="timeClick" data-time="1">
<text class="weui-btn weui-btn_mini weui-btn_plain-default">24小时</text>
</view>
<view class="weui-flex__item {{clickItem === '3' ? 'weui-btn_plain-primary' : ''}}" bindtap="timeClick" data-time="3">
<text class="weui-btn weui-btn_mini weui-btn_plain-default" >3天</text>
</view>
<view class="weui-flex__item {{clickItem === '7' ? 'weui-btn_plain-primary' : ''}}" bindtap="timeClick" data-time="7">
<text class="weui-btn weui-btn_mini weui-btn_plain-default " >7天</text>
</view>
</view>
<view class="weui-flex time-pick" >
<view class="label-class">自定义时间</view>
<picker
mode="date"
end="{{optTime}}"
class="tabbar-item"
bindchange="dateChange">
<button size="mini" class="date-class">{{selectTime}}</button>
</picker>
</view>
<view class="modelFooter">
<text bindtap="cancel">取消</text>
<text bindtap="confirm" class="saveBtn">确定</text>
</view>
</view>
</view>
</view>
.tabbar {
font-size: 0rpx;
display: flex;
border-top: 2rpx solid #eee;
border-bottom: 2rpx solid #eee;
position: relative;
z-index: 1000;
background: #fff;
}
.tabbar-item {
flex: 1;
font-size: 28rpx;
text-align: center;
border-right: 2rpx solid #eee;
padding: 20rpx 0;
}
.select-dropdown-icon{
content: '';
display: inline-block;
width: 10rpx;
height: 10rpx;
border: 2rpx solid #999;
border-top: none;
border-right: none;
transform: rotate(-45deg);
margin-left: 12rpx;
position: relative;
top: -4rpx;
}
.tabbar-item.active {
color: #37c060;
font-weight: bold;
}
.tabbar-item:last-child {
border-right: none;
}
.btn-control {
position: fixed;
bottom: 40rpx;
left: 50%;
margin-left: -150rpx;
z-index: 300;
}
.play-btn, .pause-btn, .refresh-btn{
display: none;
}
.play-btn.active, .pause-btn.active, .refresh-btn.active{
display: inline-block;
}
.icon-replay-play{
width: 122rpx;
height: 122rpx;
background-position: 0rpx -133rpx;
}
.icon-replay-pause{
width: 122rpx;
height: 122rpx;
background-position: -264rpx 0rpx;
}
.icon-replay-refresh.active{
width: 122rpx;
height: 122rpx;
background-position: -121rpx -133rpx;
}
.refresh-btn{
margin-left: 60rpx;
}
.model_class {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 400;
opacity: 1;
display: flex;
align-items: center;
justify-content: center;
}
.mode_box{
width: 70%;
border-radius: 10rpx;
background: #fff;
padding: 30rpx;
}
.tilte_class{
font-size: 36rpx;
color: #000;
}
.time-choose {
margin: 20rpx 0;
color: #333;
display: flex;
align-items: center;
}
.time-pick{
margin: 30rpx 10rpx 0 10rpx;
display: flex;
}
.time-pick .label-class{
color: #666;
margin-right: 15rpx;
}
.time-pick .tabbar-item{
padding: 0;
text-align: left;
}
.time-pick .tabbar-item .date-class{
width: 100%;
height: 50rpx;
line-height: 50rpx;
}
.time-choose .weui-flex__item {
padding: 0 6rpx;
text-align: center;
border-radius: 10rpx;
margin: 0 10rpx;
border: 2rpx solid #999;
}
.time-choose .weui-btn_plain-primary {
border: 2rpx solid #1aad19;
color: #1aad19;
}
.modelFooter{
padding: 30rpx 20rpx;
text-align: right;
}
.modelFooter .saveBtn{
margin-left: 50rpx;
color: #1aad19;
}
{
"description": "项目配置文件。",
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"coverView": true,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"useMultiFrameRuntime": false,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
"description": "项目配置文件,详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
"setting": {
"urlCheck": false,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"coverView": true,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"useMultiFrameRuntime": true,
"useApiHook": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"enhance": true,
"preloadBackgroundData": false,
"uglifyFileName": false,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"disableUseStrict": false,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true,
"useStaticServer": true,
"minifyWXML": true
},
"useIsolateContext": true,
"useCompilerModule": true,
"userConfirmedUseCompilerModuleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true
},
"compileType": "miniprogram",
"libVersion": "1.9.91",
"appid": "wxdae8cf8710b62fee",
"projectname": "wx",
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
"compileType": "miniprogram",
"libVersion": "2.23.4",
"appid": "wxdae8cf8710b62fee",
"projectname": "wx",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"miniprogram": {
"list": [
{
"name": "pages/wxPublicPage/wxPublicPage",
"pathName": "pages/wxPublicPage/wxPublicPage",
"query": "",
"scene": 1043,
"referrerInfo": {}
}
]
}
},
"game": {
"currentL": -1,
"list": []
"packOptions": {
"ignore": [],
"include": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "pages/wxPublicPage/wxPublicPage",
"pathName": "pages/wxPublicPage/wxPublicPage",
"query": "",
"scene": 1043,
"referrerInfo": {}
}
]
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 4
}
}
}
\ No newline at end of file
//const domain = 'https://e-shield.didihu.com.cn/otmini/'; //正式环境
const domain = 'https://devwx.glsx.com.cn/otmini/'; //开发环境
const domain = 'https://e-shield.didihu.com.cn/otmini/'; //正式环境
// const domain = 'https://devwx.glsx.com.cn/otmini/'; //开发环境
/*
新e盾找车
*/
// 开发:https://eshield.dev.glsx.com.cn/
// 测试:https://eshield.test.glsx.com.cn/
// 生产:https://eshield.didihu.com.cn/
const newDomain = 'https://eshield.didihu.com.cn/'
function redirectToLogin(){console.log('redirectToLogin')
wx.redirectTo({
......@@ -82,15 +89,17 @@ module.exports = {
});
})
},
get(url, data){
get(url, data, isNewFindCar, notShowLoading){
return new Promise(function(resolve, reject){
wx.showLoading();
if (!notShowLoading) { // 实时监控不显示加载中
wx.showLoading();
}
//wx.setStorageSync('sessionid', 'JSESSIONID=node03r5y0xa3w4fh1jdk4e2q4oz860.node0;Path=/otmini')
const params = {
header: {
'cookie': wx.getStorageSync("sessionid")
},
url: `${domain}${url}`,
url: isNewFindCar ? `${newDomain}${url}` : `${domain}${url}`,
success: function(res) {
wx.hideLoading();
if(res.statusCode === 200){
......@@ -100,7 +109,13 @@ module.exports = {
content: data.message,
showCancel: false
});
}
}
if ('code' in data && data.code !== 200) { // 新e盾接口
wx.showModal({
content: data.message,
showCancel: false
});
}
resolve(data);
}else if(res.statusCode === 401){
redirectToLogin();
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!