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