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

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) { 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') { if (res.errMsg == 'getLocation:fail auth deny' || res.errMsg == 'getLocation:fail:auth denied') {
that.setData({ // that.setData({
isShowAuth: true // isShowAuth: true
}) // })
} }
}, },
}) })
@@ -480,15 +488,44 @@ Page({
}) })
}, },
// 回到开始 // 由原来的回到开始改为定位
goFrist() { goFrist() {
let list = [{ let that = this;
longitude: this.data.longitude, wx.getLocation({
latitude: this.data.latitude type: 'gcj02',
}]; success: function(res) {
// this.data.includePoints 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({ this.setData({
includePoints: list isShowAuth: false
}) })
} }
}) })

View File

@@ -112,4 +112,4 @@
</view> </view>
</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({ this.setData({
state: options.state state: options.state
}) })
this.getLocation(); this.getData();
}, },
/** /**
@@ -144,35 +144,6 @@ Page({
isShowNewplot: true 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>
</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}}"> <view class='newplot' wx:if="{{isShowNewplot && venues.length == 0}}">
<image src='../../images/noContent.png'></image> <image src='../../images/noContent.png'></image>
<text>暂无运动场馆 ~</text> <text>暂无运动场馆 ~</text>
</view> </view>

View File

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