瀏覽代碼

[授权地理位置][修改]:[授权地理位置的提示]

tags/江西版6.1.0
meo 6 年之前
父節點
當前提交
561a4eb6ac
共有 3 個檔案被更改,包括 100 行新增7 行删除
  1. +0
    -5
      app.js
  2. +51
    -1
      pages/index/index.js
  3. +49
    -1
      pages/passCar/passCar.js

+ 0
- 5
app.js 查看文件

@@ -51,11 +51,6 @@ App({
}, },
fail: error => { fail: error => {
console.log(error); console.log(error);
wx.showModal({
title:'提示',
content: error.errMsg,
showCancel:false
})
} }
}); });
}, },


+ 51
- 1
pages/index/index.js 查看文件

@@ -66,7 +66,57 @@ Page({
}) })
wx.setStorageSync('options', JSON.stringify(options)) wx.setStorageSync('options', JSON.stringify(options))
wx.setStorageSync('imgurl', imgurl) wx.setStorageSync('imgurl', imgurl)
app.getLocation();
wx.getSetting({
success: (res) => {
console.log(res)
if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {//非初始化进入该页面,且未授权
wx.showModal({
title: '是否授权当前位置',
content: '需要获取您的地理位置,请确认授权,否则无法获取您所需数据',
success: function (res) {
debugger;
if (res.cancel) {
wx.showToast({
title: '授权失败',
icon: 'success',
duration: 1000
})
} else if (res.confirm) {
wx.openSetting({
success: function (dataAu) {
if (dataAu.authSetting["scope.userLocation"] == true) {
wx.showToast({
title: '授权成功',
icon: 'success',
duration: 1000
})
//再次授权,调用getLocationt的API
app.getLocation();
} else {
wx.showToast({
title: '授权失败',
icon: 'success',
duration: 1000
})
}
}
})
}
}
})
} else if (res.authSetting['scope.userLocation'] == undefined) {
//初始化进入
app.getLocation();
}
else {
//授权后默认加载
app.getLocation();
}
}
})


if (options.couponChannelId || options.orderId || options.id) { if (options.couponChannelId || options.orderId || options.id) {
that.userLogin(options); that.userLogin(options);
} else { } else {


+ 49
- 1
pages/passCar/passCar.js 查看文件

@@ -161,7 +161,55 @@ Page({
scene: scene scene: scene
}); });
if (app.globalData.token) { } else { if (app.globalData.token) { } else {
app.getLocation();
// app.getLocation();
wx.getSetting({
success: (res) => {
console.log(res)
if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {//非初始化进入该页面,且未授权
wx.showModal({
title: '是否授权当前位置',
content: '需要获取您的地理位置,请确认授权,否则无法获取您所需数据',
success: function (res) {
debugger;
if (res.cancel) {
wx.showToast({
title: '授权失败',
icon: 'success',
duration: 1000
})
} else if (res.confirm) {
wx.openSetting({
success: function (dataAu) {
if (dataAu.authSetting["scope.userLocation"] == true) {
wx.showToast({
title: '授权成功',
icon: 'success',
duration: 1000
})
//再次授权,调用getLocationt的API
app.getLocation();
} else {
wx.showToast({
title: '授权失败',
icon: 'success',
duration: 1000
})
}
}
})
}
}
})
} else if (res.authSetting['scope.userLocation'] == undefined) {
//初始化进入
app.getLocation();
}
else {
//授权后默认加载
app.getLocation();
}
}
})
that.userLogin() that.userLogin()
} }
}, },


Loading…
取消
儲存