定位提示

main
lion 2 months ago
parent df170f5c34
commit 913becb570

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

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

@ -28,11 +28,11 @@
<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">
<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 class="maps-cover">
<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">
<cover-view class="maps-cover-lock">
@ -42,16 +42,16 @@
</cover-view>
</block>
</cover-view>
<cover-view class="maps-cover-label" v-if="showLabel">
<!-- <cover-image class="maps-labelbg" :src="'/static/home-cur.png'"></cover-image> -->
{{item.title}}
<cover-view class="maps-cover-label" v-if="showLabel">
<!-- <cover-image class="maps-labelbg" :src="'/static/home-cur.png'"></cover-image> -->
{{item.title}}
</cover-view>
</cover-view>
</cover-view>
</block>
</cover-view>
<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-view>
<cover-view class="maps-info-pointer" v-if="showPointer && pointer">
@ -63,7 +63,7 @@
</cover-view>
<cover-view>距你{{pointer.distance?pointer.distance:'-'}}</cover-view>
<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'">
{{con.value}}
</block>
@ -82,6 +82,9 @@
</cover-view>
</cover-view>
</cover-view>
<cover-view class="maps-info-tip" v-if="showLocationTip" @click="retryLocationAuth">
使用完整功能需要获取您的定位点击授权
</cover-view>
</map>
</view>
@ -158,8 +161,9 @@
showArea: false,
tips: '',
showLoad: false,
showNear: true,
showLabel:false
showNear: true,
showLabel:false,
showLocationTip: false
}
},
@ -170,32 +174,27 @@
return shareInfo
},
onReady() {
uni.authorize({
scope: 'scope.userLocation',
success: (res) => {
this.getUserLocation()
}
})
this.initLocationAuth()
this.mapContext = uni.createMapContext('myMap', this);
//
let _this = this
//
let _this = this
if (this.mapTimer) {
clearInterval(this.mapTimer)
} else {
this.mapTimer = setInterval(function() {
_this.mapContext.getScale({
success: function(res) {
if(res.scale>12){
_this.showLabel = true
}else{
_this.showLabel = false
}
},
fail: function(error) {
console.log('获取地图缩放级别失败:', error);
}
});
} else {
this.mapTimer = setInterval(function() {
_this.mapContext.getScale({
success: function(res) {
if(res.scale>12){
_this.showLabel = true
}else{
_this.showLabel = false
}
},
fail: function(error) {
console.log('获取地图缩放级别失败:', error);
}
});
}, 1000)
}
@ -241,19 +240,49 @@
onHide() {
this.showTips = false
this.showPointer = false
this.pointer = null
if(!this.mapTimer){
this.mapTimer = null
clearInterval(this.mapTimer)
}
this.pointer = null
if(!this.mapTimer){
this.mapTimer = null
clearInterval(this.mapTimer)
}
},
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() {
uni.getLocation({
type: 'gcj02',
success: (res) => {
this.showLocationTip = false
uni.removeStorageSync('vuex_latlng')
this.lng = res.longitude
this.lat = res.latitude
@ -265,6 +294,47 @@
},
fail: (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;
}
}
&-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 {
display: flex;
align-items: center;
z-index: 9999;
z-index: 9999;
flex-wrap: wrap;
position: relative;
position: relative;
flex-flow: column;
&-wrap {
position: relative;
@ -715,12 +799,12 @@
// width: 270rpx;
// height: 65rpx;
// }
// }
font-size: 22rpx;
color: #960909;
width: 200rpx;
text-align: center;
width: 200rpx;
text-align: center;
white-space: normal;
// cover-view {
// padding: 10rpx;
@ -789,16 +873,16 @@
}
}
}
}
.areaPicker{
.u-drawer{
>view{
.u-picker-body{
height:750rpx;
}
}
}
}
.areaPicker{
.u-drawer{
>view{
.u-picker-body{
height:750rpx;
}
}
}
}
}

Loading…
Cancel
Save