|
@@ -49,27 +49,25 @@ Page({
|
|
|
})
|
|
|
}else {
|
|
|
// 2. 用户未授权的情况下, 打开授权界面, 引导用户授权.
|
|
|
- wx.openSetting({
|
|
|
+ wx.authorize({
|
|
|
+ scope: "scope.userLocation",
|
|
|
success(res) {
|
|
|
- // 2.1 如果二次授权允许了 userLocation 权限, 就再次执行获取位置的接口
|
|
|
- if (res.authSetting["scope.userLocation"]) {
|
|
|
- wx.getLocation({
|
|
|
- success(res){
|
|
|
- // 2.2 获取用户位置成功后,将会返回 latitude, longitude 两个字段,代表用户的经纬度位置
|
|
|
- // 2.3 将获取到的 经纬度传值给 getAddress 解析出 具体的地址
|
|
|
- that.setData({
|
|
|
- latitude: res.latitude,
|
|
|
- longitude: res.longitude,
|
|
|
- })
|
|
|
- that.loadStoreListData()
|
|
|
- },
|
|
|
- fail() {
|
|
|
- wx.navigateBack({
|
|
|
- delta: -1,
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
+ wx.getLocation({
|
|
|
+ success(res){
|
|
|
+ // 2.2 获取用户位置成功后,将会返回 latitude, longitude 两个字段,代表用户的经纬度位置
|
|
|
+ // 2.3 将获取到的 经纬度传值给 getAddress 解析出 具体的地址
|
|
|
+ that.setData({
|
|
|
+ latitude: res.latitude,
|
|
|
+ longitude: res.longitude,
|
|
|
+ })
|
|
|
+ that.loadStoreListData()
|
|
|
+ },
|
|
|
+ fail() {
|
|
|
+ wx.navigateBack({
|
|
|
+ delta: -1,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -212,7 +210,7 @@ Page({
|
|
|
this.data.storeList = this.data.storeList.concat(list)
|
|
|
|
|
|
this.setData({
|
|
|
- storeList: list
|
|
|
+ storeList: this.data.storeList
|
|
|
})
|
|
|
},
|
|
|
callPhone(e) {
|