You need to sign in or sign up before continuing.
Commit dbf59be9 by zhangxw

新e盾

1 parent cd869aa3
......@@ -24,7 +24,11 @@
"pages/freqLogDetail/freqLogDetail",
"pages/freqLogUserDetail/freqLogUserDetail",
"pages/map/findCar",
"pages/test/test"
"pages/newFindCar/findCar",
"pages/newCarTrace/carTrace",
"pages/newFindSearch/findSearch",
"pages/newMonitor/monitor",
"pages/newTraReplay/traReplay"
],
"window": {
"backgroundColor": "#efeff4",
......@@ -63,5 +67,8 @@
"desc": "你的位置信息将用于定位效果展示"
}
},
"sitemapLocation": "sitemap.json"
"sitemapLocation": "sitemap.json",
"usingComponents": {
"myMap": "components/myMap/myMap"
}
}
\ No newline at end of file
Component({
/**
* 组件的属性列表
*/
options: {
multipleSlots: true
},
properties: {
polyline: Array,
isLoading: Boolean,
includePoints: Array // 当前页面是否有marker或路径的左边点
},
/**
* 组件的初始数据
*/
data: {
currentLo: 116.363874, // 地图中心点坐标
currentLa: 39.738269,
latitude: null, // 定位坐标
longitude: null,
isAuthLocation: false,
enableSatellite: false,
enableTraffic: false,
carInfoWindowObj: {},
isGPS: true,
scale: 16
},
ready() {
},
attached() {
},
/**
* 组件的方法列表
*/
methods: {
getMapCtx() {
if (this.mapCtx) {
return this.mapCtx
}
// 创建 map 上下文 MapContext 对象
this.mapCtx = wx.createMapContext('Mymap', this)
return this.mapCtx
},
bindmarkertap(e) {
this.triggerEvent('getCarInfoWindowObj', 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) => {
console.log(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) => {
console.log(e)
this.setData({
currentLo: e.longitude,
currentLa: e.latitude,
scale: res.scale <= 3 ? 3 : res.scale-1
})
}
})
}
})
break
}
},
// 定位
locateClick() {
let _this = this
if (_this.data.isAuthLocation) {
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)
}
} 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)
}
}
})
}
},
})
\ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file
<view class="map-wrap">
<!-- 地图组件 -->
<map id="Mymap" class="my-map" polyline="{{polyline}}" longitude="{{currentLo}}" latitude="{{currentLa}}" scale="{{scale}}" enable-satellite="{{enableSatellite}}" bindmarkertap="bindmarkertap" data-num="1" enable-traffic="{{enableTraffic}}" show-location bindtap="mapClick">
</map>
<!-- 地图控件 -->
<text class="icon icon-locate map-cmd-icon" catchtap="locateClick"></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),
......@@ -72,10 +88,17 @@ Page({
}
}
});
}else if(userStatus === 1){
wx.switchTab({
url: '../../pages/findCar/findCar'
});
}else if(userStatus === 0){
if (!this.data.isSharePage) { // 老e盾页面分享
wx.switchTab({
url: '../../pages/findCar/findCar'
});
} else {
wx.reLaunch({
url: `../../pages/newFindCar/findCar?sns=${this.data.sns}&isSharePage=true`
});
}
}else if(userStatus === 0){
wx.setStorageSync('carShareInfo', null);
wx.switchTab({
......
......@@ -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}}">
退出登录
......
Page({
/**
* 页面的初始数据
*/
data: {
url: '',
init: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
wx.getLocation({
success: function(res) {
wx.openLocation({
latitude: Number(options.lat),
longitude: Number(options.lng)
});
},
fail(res){
console.log(res)
}
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
if(this.data.init){
wx.navigateBack()
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
this.setData({
init: true
});
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
{
"navigationBarTitleText": "导航"
}
\ No newline at end of file
<!-- 打开地图 -->
{
"usingComponents": {
"myMap": "../../components/myMap/myMap"
}
}
\ No newline at end of file
<view class="content_page">
<myMap class="my-map" id="myMap" bind:getCarInfoWindowObj="getCarInfoWindowObj" bind:refresh="refresh" 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 + '%'}}" 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="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
This diff could not be displayed because it is too large.
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: 120px;
}
.search-wrap input{
}
.search-picker{
position: absolute;
top: 0;
right: 0;
font-size: 28rpx;
}
.search-picker text{
position: absolute;
width: 60px;
right: 20px;
height: 56rpx;
line-height: 56rpx;
padding-left: 10px;
border-left: 1px solid #eee;
}
.select-dropdown-icon{
content: '';
display: inline-block;
border: 5px solid transparent;
border-top-color: #c9c9c9;
position: absolute;
right: 10px;
top: 10px;
}
.search-wrap .weui-icon-clear{
right: 90px;
z-index: 100;
}
.result-list{
background-color: #fff;
color: #666;
font-size: 14px;
}
.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: 1px solid #d9d9d9;
}
.result-list .weui-cell:last-child{
border-bottom: 1px 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: '',
polyline: [],
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('#myMap')
this.getPosition()
},
// 刷新
refresh() {
this.setData({
carMarkers: [],
polyLine: [],
listData: []
})
this.myMap.getMapCtx().removeMarkers({
markerIds: [1, 2]
})
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).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 => {
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
})
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(e.data[0].gpsLocation.elat, e.data[0].gpsLocation.elng)
this.setData({
points: points.concat(arr),
polyline: [{
points: points.concat(arr),
color: '#0b94db',
width: 6,
arrowLine: true
}]
})
}
})
}
})
}
}
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": {}
}
\ No newline at end of file
<view>
<myMap class="my-map" id="myMap" polyline="{{polyline}}" 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>
This diff could not be displayed because it is too large.
const util = require('../../utils/util.js');
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,
polyline: [],
markers: [],
duration: 20000, // 回放速度
isShowModel: false,
clickItem: null,
selectTime: '',
sn: null,
type: null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
sn: decodeURIComponent(options.sn),
locationType: options.locationType == 'gpsLocation' ? 0 : 1
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
// 刷新
refresh() {
if (this.data.polyline.length <= 0) return
this.setData({
duration: 20000,
clickItem: null,
selectTime: '',
isReplayIng: false,
polyline: [],
includePoints: []
})
this.myMap.getMapCtx().removeMarkers({
markerIds: [1, 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
})
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)
})
});
if (res.data.length) {
polyline.push({
points: arr,
color: '#0b94db',
width: 6,
arrowLine: true
})
this.myMap = this.selectComponent('#myMap')
this.myMap.getMapCtx().includePoints({
points: arr,
padding: [40, 40, 40, 40]
})
this.setData({
polyline: polyline,
includePoints: arr
})
} else {
wx.showModal({
content: '暂无数据',
showCancel: false
})
}
}
})
},
// 切换回放速度
speedTypeChange(e) {
let arr = [20000, 15000, 10000, 5000]
this.setData({
speedItemsIndex: Number(e.detail.value),
duration: arr[Number(e.detail.value)]
})
this.beginTrack()
},
// 播放
play() {
if (this.data.polyline.length) {
this.myMap.getMapCtx().removeMarkers({
markerIds: [1]
})
let marker = [{
id: 1,
width: 15,
height: 25,
latitude: this.data.polyline[0].points[0].latitude,
longitude: this.data.polyline[0].points[0].longitude,
iconPath: '../../images/car.png'
}]
this.myMap.getMapCtx().addMarkers({
markers: marker,
success: () => {
this.beginTrack()
}
})
}
},
beginTrack() {
this.setData({
isReplayIng: true
})
this.myMap.getMapCtx().moveAlong({
markerId: 1,
path: this.data.polyline[0].points,
duration: this.data.duration,
success: (res) => {
this.setData({
isReplayIng: false
})
},
fail: () => {
this.beginTrack()
}
})
},
// 暂停
pause() {
},
// 重新播放
replayRefresh() {
if (this.data.polyline.length) {
this.setData({
isReplayIng: true
})
this.beginTrack()
}
},
// 点击地图回调
mapCallback(e) {
if (this.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 => {
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"
}
}
\ No newline at end of file
<view class="content_page">
<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="myMap" polyline="{{polyline}}" 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="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"
value="{{speedItemsIndex}}"
range="{{speedItems}}"
range-key="label">
<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>
This diff could not be displayed because it is too large.
{
"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": "项目配置文件。",
"setting": {
"urlCheck": false,
"es6": true,
"enhance": true,
"postcss": true,
"preloadBackgroundData": false,
"minified": true,
"newFeature": true,
"coverView": true,
"nodeModules": false,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"uglifyFileName": false,
"checkInvalidKey": true,
"checkSiteMap": true,
"uploadWithSourceMap": true,
"compileHotReLoad": false,
"lazyloadPlaceholderEnable": false,
"useMultiFrameRuntime": true,
"useApiHook": true,
"useApiHostProcess": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useIsolateContext": false,
"userConfirmedBundleSwitch": false,
"packNpmManually": false,
"packNpmRelationList": [],
"minifyWXSS": true,
"disableUseStrict": false,
"minifyWXML": true,
"showES6CompileOption": false,
"useCompilerPlugins": false,
"ignoreUploadUnusedFiles": 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": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "pages/wxPublicPage/wxPublicPage",
"pathName": "pages/wxPublicPage/wxPublicPage",
"query": "",
"scene": 1043,
"referrerInfo": {}
"compileType": "miniprogram",
"libVersion": "1.9.91",
"appid": "wxdae8cf8710b62fee",
"projectname": "wx",
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"plugin": {
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"list": [
{
"id": 0,
"name": "pages/wxPublicPage/wxPublicPage",
"pathName": "pages/wxPublicPage/wxPublicPage",
"query": "",
"scene": 1043,
"referrerInfo": {}
}
]
}
]
}
}
}
\ No newline at end of file
//const domain = 'https://e-shield.didihu.com.cn/otmini/'; //正式环境
// const domain = 'https://e-shield.didihu.com.cn/otmini/'; //正式环境
const domain = 'https://devwx.glsx.com.cn/otmini/'; //开发环境
/*
新e盾找车
*/
// 开发:http://eshield.dev.glsx.com.cn/
// 测试:http://eshield.test.glsx.com.cn/
// 生产:https://eshield.didihu.com.cn/
const newDomain = 'http://eshield.dev.glsx.com.cn/'
function redirectToLogin(){console.log('redirectToLogin')
wx.redirectTo({
......@@ -82,7 +89,7 @@ module.exports = {
});
})
},
get(url, data){
get(url, data, isNewFindCar){
return new Promise(function(resolve, reject){
wx.showLoading();
//wx.setStorageSync('sessionid', 'JSESSIONID=node03r5y0xa3w4fh1jdk4e2q4oz860.node0;Path=/otmini')
......@@ -90,7 +97,7 @@ module.exports = {
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 +107,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!