定位提示

main
lion 4 months ago
parent df170f5c34
commit 913becb570

@ -1,6 +1,6 @@
const mode = 'production'; //devLocal本地测试、devOnline线上测试、production生产环境 const mode = 'production'; //devLocal本地测试、devOnline线上测试、production生产环境
let ROOTPATH = 'https://h5.jscnsaas.cn'; let ROOTPATH = 'https://h5.jscnsaas.cn';
// let ROOTPATH = 'http://h5.ali251.langye.net'; // let ROOTPATH = 'https://vr.langye.net';
switch (mode) { switch (mode) {
case 'devLocal': case 'devLocal':
ROOTPATH = ROOTPATH ROOTPATH = ROOTPATH

@ -376,7 +376,7 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin-top: -80rpx; margin-top: -80rpx;
background:linear-gradient(to bottom,transparent,#f6f3ef) ; background:linear-gradient(to bottom,transparent,#f6f3ef) ;
padding-bottom:40rpx; padding-bottom:40rpx;
&-item { &-item {
font-size: 0; font-size: 0;

@ -28,11 +28,11 @@
<map id="myMap" min-scale="6" max-scale="16" :longitude="lng" show-location :enable-scroll="!showLoad" <map id="myMap" min-scale="6" max-scale="16" :longitude="lng" show-location :enable-scroll="!showLoad"
@regionchange="pushMarkers" :scale="scale" :latitude="lat" :markers="markers" @callouttap="showDetail"> @regionchange="pushMarkers" :scale="scale" :latitude="lat" :markers="markers" @callouttap="showDetail">
<cover-view slot="callout" class="maps-covers"> <cover-view slot="callout" class="maps-covers">
<block v-for="(item,index) in markers"> <block v-for="(item,index) in markers" :key="item.id">
<cover-view :marker-id="item.id" :key='index'> <cover-view :marker-id="item.id" :key='index'>
<cover-view class="maps-cover"> <cover-view class="maps-cover">
<cover-view class="maps-cover-wrap"> <cover-view class="maps-cover-wrap">
<cover-image class="maps-cover-img" :src='item.truePath'></cover-image> <cover-image class="maps-cover-img" :src='item.truePath'></cover-image>
<block v-if="item.has_answer===0"> <block v-if="item.has_answer===0">
<cover-view class="maps-cover-lock"> <cover-view class="maps-cover-lock">
@ -42,16 +42,16 @@
</cover-view> </cover-view>
</block> </block>
</cover-view> </cover-view>
<cover-view class="maps-cover-label" v-if="showLabel"> <cover-view class="maps-cover-label" v-if="showLabel">
<!-- <cover-image class="maps-labelbg" :src="'/static/home-cur.png'"></cover-image> --> <!-- <cover-image class="maps-labelbg" :src="'/static/home-cur.png'"></cover-image> -->
{{item.title}} {{item.title}}
</cover-view> </cover-view>
</cover-view> </cover-view>
</cover-view> </cover-view>
</block> </block>
</cover-view> </cover-view>
<cover-view class="maps-info" v-if="showNear"> <cover-view class="maps-info" v-if="showNear">
<cover-view class="maps-info-near" @click="getNears"> <cover-view class="maps-info-near" @click="getNears" v-if="!showLocationTip">
<cover-image src="../../static/home-near.png" mode=""></cover-image> <cover-image src="../../static/home-near.png" mode=""></cover-image>
</cover-view> </cover-view>
<cover-view class="maps-info-pointer" v-if="showPointer && pointer"> <cover-view class="maps-info-pointer" v-if="showPointer && pointer">
@ -63,7 +63,7 @@
</cover-view> </cover-view>
<cover-view>距你{{pointer.distance?pointer.distance:'-'}}</cover-view> <cover-view>距你{{pointer.distance?pointer.distance:'-'}}</cover-view>
<cover-view v-if="pointer.config.length>0"> <cover-view v-if="pointer.config.length>0">
<block v-for="con in pointer.config"> <block v-for="(con, cIdx) in pointer.config" :key="con.key || cIdx">
<block v-if="con.key==='address'"> <block v-if="con.key==='address'">
{{con.value}} {{con.value}}
</block> </block>
@ -82,6 +82,9 @@
</cover-view> </cover-view>
</cover-view> </cover-view>
</cover-view> </cover-view>
<cover-view class="maps-info-tip" v-if="showLocationTip" @click="retryLocationAuth">
使用完整功能需要获取您的定位点击授权
</cover-view>
</map> </map>
</view> </view>
@ -158,8 +161,9 @@
showArea: false, showArea: false,
tips: '', tips: '',
showLoad: false, showLoad: false,
showNear: true, showNear: true,
showLabel:false showLabel:false,
showLocationTip: false
} }
}, },
@ -170,32 +174,27 @@
return shareInfo return shareInfo
}, },
onReady() { onReady() {
uni.authorize({ this.initLocationAuth()
scope: 'scope.userLocation',
success: (res) => {
this.getUserLocation()
}
})
this.mapContext = uni.createMapContext('myMap', this); this.mapContext = uni.createMapContext('myMap', this);
// //
let _this = this let _this = this
if (this.mapTimer) { if (this.mapTimer) {
clearInterval(this.mapTimer) clearInterval(this.mapTimer)
} else { } else {
this.mapTimer = setInterval(function() { this.mapTimer = setInterval(function() {
_this.mapContext.getScale({ _this.mapContext.getScale({
success: function(res) { success: function(res) {
if(res.scale>12){ if(res.scale>12){
_this.showLabel = true _this.showLabel = true
}else{ }else{
_this.showLabel = false _this.showLabel = false
} }
}, },
fail: function(error) { fail: function(error) {
console.log('获取地图缩放级别失败:', error); console.log('获取地图缩放级别失败:', error);
} }
}); });
}, 1000) }, 1000)
} }
@ -241,19 +240,49 @@
onHide() { onHide() {
this.showTips = false this.showTips = false
this.showPointer = false this.showPointer = false
this.pointer = null this.pointer = null
if(!this.mapTimer){ if(!this.mapTimer){
this.mapTimer = null this.mapTimer = null
clearInterval(this.mapTimer) clearInterval(this.mapTimer)
} }
}, },
methods: { methods: {
initLocationAuth() {
uni.getSetting({
success: (res) => {
const setting = res.authSetting || {}
const loc = setting['scope.userLocation']
if (loc === true) {
this.showLocationTip = false
this.getUserLocation()
} else if (loc === false) {
this.showLocationTip = true
} else {
// undefined: first time, try authorize
uni.authorize({
scope: 'scope.userLocation',
success: () => {
this.showLocationTip = false
this.getUserLocation()
},
fail: () => {
this.showLocationTip = true
}
})
}
},
fail: () => {
this.showLocationTip = true
}
})
},
// //
getUserLocation() { getUserLocation() {
uni.getLocation({ uni.getLocation({
type: 'gcj02', type: 'gcj02',
success: (res) => { success: (res) => {
this.showLocationTip = false
uni.removeStorageSync('vuex_latlng') uni.removeStorageSync('vuex_latlng')
this.lng = res.longitude this.lng = res.longitude
this.lat = res.latitude this.lat = res.latitude
@ -265,6 +294,47 @@
}, },
fail: (err) => { fail: (err) => {
console.log("err", err) console.log("err", err)
this.showLocationTip = true
}
})
},
retryLocationAuth() {
// authorize
uni.getSetting({
success: (res) => {
const setting = res.authSetting || {}
const loc = setting['scope.userLocation']
if (loc === true) {
this.showLocationTip = false
this.getUserLocation()
} else if (loc === false) {
uni.openSetting({
success: (rs) => {
if (rs.authSetting && rs.authSetting['scope.userLocation']) {
this.showLocationTip = false
this.getUserLocation()
}
}
})
} else {
uni.authorize({
scope: 'scope.userLocation',
success: () => {
this.showLocationTip = false
this.getUserLocation()
},
fail: () => {
uni.openSetting({
success: (rs) => {
if (rs.authSetting && rs.authSetting['scope.userLocation']) {
this.showLocationTip = false
this.getUserLocation()
}
}
})
}
})
}
} }
}) })
}, },
@ -668,15 +738,29 @@
display: inline-block; display: inline-block;
} }
} }
&-tip {
position: absolute;
left: 50%;
bottom: 160rpx;
transform: translate(-50%,-50%);
width: 80%;
z-index: 99;
text-align: center;
background: rgba(0,0,0,0.6);
color: #fff;
padding: 10rpx 30rpx;
border-radius: 40rpx;
}
} }
&-cover { &-cover {
display: flex; display: flex;
align-items: center; align-items: center;
z-index: 9999; z-index: 9999;
flex-wrap: wrap; flex-wrap: wrap;
position: relative; position: relative;
flex-flow: column; flex-flow: column;
&-wrap { &-wrap {
position: relative; position: relative;
@ -715,12 +799,12 @@
// width: 270rpx; // width: 270rpx;
// height: 65rpx; // height: 65rpx;
// } // }
font-size: 22rpx; font-size: 22rpx;
color: #960909; color: #960909;
width: 200rpx; width: 200rpx;
text-align: center; text-align: center;
white-space: normal; white-space: normal;
// cover-view { // cover-view {
// padding: 10rpx; // padding: 10rpx;
@ -789,16 +873,16 @@
} }
} }
} }
} }
.areaPicker{ .areaPicker{
.u-drawer{ .u-drawer{
>view{ >view{
.u-picker-body{ .u-picker-body{
height:750rpx; height:750rpx;
} }
} }
} }
} }
} }

Loading…
Cancel
Save