Commit cccecf2b by zhangxw

定位优化

1 parent dbf59be9
...@@ -24,7 +24,8 @@ Component({ ...@@ -24,7 +24,8 @@ Component({
enableTraffic: false, enableTraffic: false,
carInfoWindowObj: {}, carInfoWindowObj: {},
isGPS: true, isGPS: true,
scale: 16 scale: 16,
isCanClick: true
}, },
ready() { ready() {
}, },
...@@ -81,7 +82,6 @@ Component({ ...@@ -81,7 +82,6 @@ Component({
success: (res) => { success: (res) => {
this.getMapCtx().getCenterLocation({ this.getMapCtx().getCenterLocation({
success: (e) => { success: (e) => {
console.log(e)
this.setData({ this.setData({
currentLo: e.longitude, currentLo: e.longitude,
currentLa: e.latitude, currentLa: e.latitude,
...@@ -97,7 +97,6 @@ Component({ ...@@ -97,7 +97,6 @@ Component({
success: (res) => { success: (res) => {
this.getMapCtx().getCenterLocation({ this.getMapCtx().getCenterLocation({
success: (e) => { success: (e) => {
console.log(e)
this.setData({ this.setData({
currentLo: e.longitude, currentLo: e.longitude,
currentLa: e.latitude, currentLa: e.latitude,
...@@ -111,14 +110,19 @@ Component({ ...@@ -111,14 +110,19 @@ Component({
} }
}, },
// 定位 // 定位
locateClick() { locateClick(e) {
let _this = this let _this = this
if (!this.data.isCanClick) return
this.setData({
isCanClick: false
})
setTimeout(() => {
this.setData({
isCanClick: true
})
}, 30*1000)
if (_this.data.isAuthLocation) { if (_this.data.isAuthLocation) {
if (_this.data.includePoints.length > 0) { // 包含其他坐标点 不需将获取到的坐标移动到地图中心 _this.getLocation()
_this.triggerEvent('locationCallback', {lat: _this.data.latitude, lng: _this.data.longitude})
} else {
_this.moveToLocation(_this.data.latitude, _this.data.longitude)
}
} else { } else {
wx.getSetting({ wx.getSetting({
success: (res) => { success: (res) => {
...@@ -162,6 +166,13 @@ Component({ ...@@ -162,6 +166,13 @@ Component({
} else { } else {
_this.moveToLocation(res.latitude, res.longitude) _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)
}
} }
}) })
} }
......
...@@ -3,7 +3,16 @@ ...@@ -3,7 +3,16 @@
<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 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> </map>
<!-- 地图控件 --> <!-- 地图控件 -->
<text class="icon icon-locate map-cmd-icon" catchtap="locateClick"></text> <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> <text class="icon icon-refresh map-cmd-icon" catchtap="refreshClick"></text>
<view class="map-type-list"> <view class="map-type-list">
<view class="icon icon-satel {{enableSatellite ? 'active' : ''}}" catchtap="layerClick" data-num="1"></view> <view class="icon icon-satel {{enableSatellite ? 'active' : ''}}" catchtap="layerClick" data-num="1"></view>
......
...@@ -22,10 +22,83 @@ ...@@ -22,10 +22,83 @@
bottom: 40rpx; bottom: 40rpx;
left: 40rpx; left: 40rpx;
} }
.icon-locate:active { /* .icon-locate:active {
width: 98rpx; width: 98rpx;
height: 98rpx; height: 98rpx;
background-position: -384rpx 4rpx; background-position: -384rpx 4rpx;
} */
.hidden{
display: none;
}
.show-class{
display: inline-block;
width: 94rpx;
height: 94rpx;
border-radius: 50%;
overflow: hidden;
}
.count-down-left, .count-down-right {
width: 47rpx;
height: 94rpx;
position: absolute;
overflow: hidden;
}
.count-down-left, .count-down-left-ring {
left: 2rpx;
}
.count-down-left-ring, .count-down-right-ring {
width: 200%;
height: 94rpx;
position: absolute;
border-width: 47rpx;
border-style: solid;
border-radius: 50%;
border-left-color: rgba(0, 0, 0, 0);
border-top-color: rgba(0, 0, 0, 0);
border-right-color: rgba(0, 0, 0, 0.4);
border-bottom-color: rgba(0, 0, 0, 0.4);
/* 这里必须采用border-box,把border限制在内部区域,否则会超出边界 */
box-sizing: border-box;
}
.count-down-right, .count-down-right-ring {
right: 3rpx;
}
.count-down-left-ring {
transform: rotate(-45deg);
animation: anim-count-down-left-ring 30s linear infinite;
display: block;
}
.count-down-right-ring {
transform: rotate(135deg);
animation: anim-count-down-right-ring 30s linear infinite;
display: block;
}
@keyframes anim-count-down-left-ring {
from,50% {
transform: rotate(-225deg);
}
/*50%, to {*/
to {
transform: rotate(-45deg);
}
}
@keyframes anim-count-down-right-ring {
/*from, 50% {*/
from {
transform: rotate(-45deg);
}
50%,to {
transform: rotate(135deg);
}
}
.count-down-ring::after {
content: attr(data-content);
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
font-weight: bold;
} }
.icon-refresh { .icon-refresh {
width: 98rpx; width: 98rpx;
......
...@@ -88,7 +88,7 @@ Page({ ...@@ -88,7 +88,7 @@ Page({
} }
} }
}); });
}else if(userStatus === 0){ }else if(userStatus === 1){
if (!this.data.isSharePage) { // 老e盾页面分享 if (!this.data.isSharePage) { // 老e盾页面分享
wx.switchTab({ wx.switchTab({
url: '../../pages/findCar/findCar' url: '../../pages/findCar/findCar'
......
...@@ -20,7 +20,8 @@ Page({ ...@@ -20,7 +20,8 @@ Page({
isSharePage: false, // 是否被分享者进入 isSharePage: false, // 是否被分享者进入
ShowShareModel: false, ShowShareModel: false,
includePoints: [], includePoints: [],
markerIds: [] markerIds: [],
isUpdate: true
}, },
/** /**
...@@ -37,8 +38,10 @@ Page({ ...@@ -37,8 +38,10 @@ Page({
} }
}, },
onShow(options){ onShow(options){
this.myMap = this.selectComponent('#myMap') if (this.data.isUpdate) {
this.getData() this.myMap = this.selectComponent('#myMap')
this.getData()
}
}, },
// 刷新 // 刷新
refresh() { refresh() {
...@@ -52,7 +55,6 @@ Page({ ...@@ -52,7 +55,6 @@ Page({
this.myMap.getMapCtx().removeMarkers({ this.myMap.getMapCtx().removeMarkers({
markerIds: this.data.markerIds, markerIds: this.data.markerIds,
success: () => { success: () => {
console.log(this.data.markerIds)
this.getData() this.getData()
} }
}) })
...@@ -447,7 +449,9 @@ Page({ ...@@ -447,7 +449,9 @@ Page({
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { onUnload: function () {
this.setData({
isUpdate: true
})
}, },
/** /**
...@@ -509,7 +513,9 @@ Page({ ...@@ -509,7 +513,9 @@ Page({
// 转发失败 // 转发失败
} }
} }
this.setData({
isUpdate: false
})
if(that.data.sns){ if(that.data.sns){
opts.path = `${opts.path}?sns=${encodeURIComponent(this.data.sns)}&isSharePage=true`; opts.path = `${opts.path}?sns=${encodeURIComponent(this.data.sns)}&isSharePage=true`;
} }
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
</view> </view>
<view class="info-list"> <view class="info-list">
<view class="battery {{carInfoWindowObj.battery < 20 ? 'empty' : ''}}" wx:if="{{carInfoWindowObj.source !== 1 && carInfoWindowObj.battery}}"> <view class="battery {{carInfoWindowObj.battery < 20 ? 'empty' : ''}}" wx:if="{{carInfoWindowObj.source !== 1 && carInfoWindowObj.battery}}">
<view style="width: {{carInfoWindowObj.battery + '%'}}" class="fill"></view> <view style="width: {{carInfoWindowObj.battery + '%'}}; margin-top: 2rpx;" class="fill"></view>
<icon class="icon {{carInfoWindowObj.battery < 20 ? 'icon-battery-empty' : 'icon-battery-enough'}}"></icon> <icon class="icon {{carInfoWindowObj.battery < 20 ? 'icon-battery-empty' : 'icon-battery-enough'}}"></icon>
<view class="text">{{carInfoWindowObj.battery < 20 ? '不足' : carInfoWindowObj.battery}}</view> <view class="text">{{carInfoWindowObj.battery < 20 ? '不足' : carInfoWindowObj.battery}}</view>
</view> </view>
......
...@@ -326,7 +326,7 @@ ...@@ -326,7 +326,7 @@
.share-cover > .icon-share { .share-cover > .icon-share {
position: absolute; position: absolute;
top: 20rpx; top: 20rpx;
right: 140rpx; right: 150rpx;
} }
.share-cover > .tip { .share-cover > .tip {
margin-top: 120rpx; margin-top: 120rpx;
......
...@@ -58,7 +58,7 @@ ...@@ -58,7 +58,7 @@
background-position: -165rpx -350rpx; background-position: -165rpx -350rpx;
} }
.icon-toggle-down { .icon-toggle-down {
width: 60rpx; width: 61rpx;
height: 62rpx; height: 62rpx;
background-position: -105rpx -350rpx; background-position: -105rpx -350rpx;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!