调整定位权限丢失小程序无法运行问题

This commit is contained in:
2023-04-22 16:03:14 +08:00
parent ddd62ca041
commit 4aec6bf9ee
5 changed files with 59 additions and 63 deletions

View File

@@ -325,11 +325,19 @@ Page({
});
},
fail: function(res) {
console.log(res);
that.setData({
latitude: 31.2336800000,
longitude: 121.4715700000,
})
that.getData({
latitude: that.data.latitude,
longitude: that.data.longitude,
zoom: 1
});
if (res.errMsg == 'getLocation:fail auth deny' || res.errMsg == 'getLocation:fail:auth denied') {
that.setData({
isShowAuth: true
})
// that.setData({
// isShowAuth: true
// })
}
},
})
@@ -480,15 +488,44 @@ Page({
})
},
// 回到开始
// 由原来的回到开始改为定位
goFrist() {
let list = [{
longitude: this.data.longitude,
latitude: this.data.latitude
}];
// this.data.includePoints
let that = this;
wx.getLocation({
type: 'gcj02',
success: function(res) {
that.setData({
latitude: res.latitude,
longitude: res.longitude,
})
that.getData({
latitude: res.latitude,
longitude: res.longitude,
zoom: 1
});
let list = [{
longitude: this.data.longitude,
latitude: this.data.latitude
}];
// this.data.includePoints
this.setData({
includePoints: list
})
},
fail: function(res) {
console.log(res.errMsg)
if (res.errMsg == 'getLocation:fail auth deny' || res.errMsg == 'getLocation:fail:auth denied') {
that.setData({
isShowAuth: true
})
}
},
})
},
onCancel(e){
console.log(e)
this.setData({
includePoints: list
isShowAuth: false
})
}
})

View File

@@ -112,4 +112,4 @@
</view>
</view>
<confirm-dialog title="{{'提示'}}" message="{{'需要获取使用地理位置权限'}}" bindopensetting="setAuthSuccess" wx:if="{{isShowAuth}}" isAuth="{{true}}" show-cancel="{{false}}"></confirm-dialog>
<confirm-dialog title="{{'提示'}}" message="{{'需要获取使用地理位置权限'}}" bindopensetting="setAuthSuccess" wx:if="{{isShowAuth}}" isAuth="{{true}}" show-cancel="{{true}}" bind:cancelselect="onCancel"></confirm-dialog>

View File

@@ -24,7 +24,7 @@ Page({
this.setData({
state: options.state
})
this.getLocation();
this.getData();
},
/**
@@ -144,35 +144,6 @@ Page({
isShowNewplot: true
})
})
},
}
// 活动当前坐标
getLocation() {
let that = this;
wx.getLocation({
type: 'gcj02',
success: function(res) {
latitude = res.latitude;
longitude = res.longitude;
that.getData()
},
fail: function(res) {
if (res.errMsg == 'getLocation:fail auth deny' || res.errMsg == 'getLocation:fail:auth denied') {
that.setData({
isShowAuth: true
})
}
},
})
},
// 获取授权
setAuthSuccess(e) {
if (e.detail.authSetting['scope.userLocation']) {
this.getLocation();
this.setData({
isShowAuth: false
})
}
},
})
})

View File

@@ -34,9 +34,7 @@
</view>
</view>
<confirm-dialog title="{{'提示'}}" message="{{'需要获取使用地理位置权限'}}" bindopensetting="setAuthSuccess" wx:if="{{isShowAuth}}" isAuth="{{true}}" show-cancel="{{false}}"></confirm-dialog>
<view class='newplot' wx:if="{{isShowNewplot && venues.length == 0}}">
<image src='../../images/noContent.png'></image>
<text>暂无运动场馆 ~</text>
</view>
</view>

View File

@@ -1,7 +1,8 @@
{
"description": "项目配置文件。",
"packOptions": {
"ignore": []
"ignore": [],
"include": []
},
"setting": {
"urlCheck": false,
@@ -42,22 +43,11 @@
"libVersion": "2.17.0",
"appid": "wx73eb8a9ed10a029d",
"projectname": "%E6%99%BA%E6%85%A7%E4%BA%91%E9%A6%86",
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"list": []
},
"conversation": {
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"list": []
}
"condition": {},
"editorSetting": {
"tabIndent": "insertSpaces",
"tabSize": 2
}
}