调整定位权限丢失小程序无法运行问题-修改定位方法为模糊定位
This commit is contained in:
7
app.json
7
app.json
@@ -34,9 +34,12 @@
|
||||
"backgroundColor": "#252330"
|
||||
},
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"requiredPrivateInfos": [
|
||||
"getFuzzyLocation"
|
||||
],
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "需要获取您的地理位置,请确认授权,否则地图功能将无法使用"
|
||||
"scope.userFuzzyLocation": {
|
||||
"desc": "为更好体验,需要获取您的地理位置,请确认授权"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,6 +275,7 @@ Page({
|
||||
this.setData({
|
||||
isShowAuth: false
|
||||
})
|
||||
this.onCancel()
|
||||
}
|
||||
},
|
||||
|
||||
@@ -311,7 +312,7 @@ Page({
|
||||
includePoints: list,
|
||||
})
|
||||
let that = this;
|
||||
wx.getLocation({
|
||||
wx.getFuzzyLocation({
|
||||
type: 'gcj02',
|
||||
success: function(res) {
|
||||
that.setData({
|
||||
@@ -325,6 +326,7 @@ Page({
|
||||
});
|
||||
},
|
||||
fail: function(res) {
|
||||
console.log(res)
|
||||
that.setData({
|
||||
latitude: 31.2336800000,
|
||||
longitude: 121.4715700000,
|
||||
@@ -334,11 +336,6 @@ Page({
|
||||
longitude: that.data.longitude,
|
||||
zoom: 1
|
||||
});
|
||||
if (res.errMsg == 'getLocation:fail auth deny' || res.errMsg == 'getLocation:fail:auth denied') {
|
||||
// that.setData({
|
||||
// isShowAuth: true
|
||||
// })
|
||||
}
|
||||
},
|
||||
})
|
||||
},
|
||||
@@ -491,7 +488,7 @@ Page({
|
||||
// 由原来的回到开始改为定位
|
||||
goFrist() {
|
||||
let that = this;
|
||||
wx.getLocation({
|
||||
wx.getFuzzyLocation({
|
||||
type: 'gcj02',
|
||||
success: function(res) {
|
||||
that.setData({
|
||||
@@ -504,17 +501,17 @@ Page({
|
||||
zoom: 1
|
||||
});
|
||||
let list = [{
|
||||
longitude: this.data.longitude,
|
||||
latitude: this.data.latitude
|
||||
longitude: that.data.longitude,
|
||||
latitude: that.data.latitude
|
||||
}];
|
||||
// this.data.includePoints
|
||||
this.setData({
|
||||
that.setData({
|
||||
includePoints: list
|
||||
})
|
||||
},
|
||||
fail: function(res) {
|
||||
console.log(res.errMsg)
|
||||
if (res.errMsg == 'getLocation:fail auth deny' || res.errMsg == 'getLocation:fail:auth denied') {
|
||||
if (res.errMsg == 'getFuzzyLocation:fail auth deny' || res.errMsg == 'getFuzzyLocation:fail:auth denied' || res.errMsg == 'getFuzzyLocation:fail no permission') {
|
||||
that.setData({
|
||||
isShowAuth: true
|
||||
})
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// pages/sportsGroundList/index.js
|
||||
const app = getApp();
|
||||
let latitude = 0; // 纬度
|
||||
let longitude = 0; // 经度
|
||||
let latitude = 31.2336800000; // 纬度
|
||||
let longitude = 121.4715700000; // 经度
|
||||
let page = 1;
|
||||
Page({
|
||||
|
||||
@@ -24,7 +24,7 @@ Page({
|
||||
this.setData({
|
||||
state: options.state
|
||||
})
|
||||
this.getData();
|
||||
this.getLocationDistance();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -106,6 +106,21 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
getLocationDistance(){
|
||||
let that = this;
|
||||
wx.getFuzzyLocation({
|
||||
type: 'gcj02',
|
||||
success: function(res) {
|
||||
latitude = res.latitude;
|
||||
longitude = res.longitude;
|
||||
that.getData()
|
||||
},
|
||||
fail: function(res) {
|
||||
that.getData()
|
||||
},
|
||||
})
|
||||
},
|
||||
|
||||
// 获取数据
|
||||
getData(e) {
|
||||
wx.showLoading({
|
||||
|
||||
Reference in New Issue
Block a user