微信小程序如何进行精准的定位授权操作?

更新于
2026-09-29 13:38:50
1阅读来源:SEO教程
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计163个文字,预计阅读时间需要1分钟。

微信小程序如何进行精准的定位授权操作?

javascriptwx.getLocation({ type: 'wgs84', success: function(res) { var latitude=res.latitude; var longitude=res.longitude; wx.login({}); }, fail: function(res) { // 未开启定位权限,拉起授权 if (res.errMsg==='getLocation:fail auth deny') { // 引导用户开启定位权限 } }});

location.js

wx.getLocation({ type: 'wgs84', success: function (res) { var latitude = res.latitude; var longitude = res.longitude; wx.login({ }); }, fail: function (res) { //未开启定位权限,拉起授权 if (res.errMsg == 'getLocation:fail auth deny') { //重新拉起授权 wx.openSetting({ success: function (res) { if (res.authSetting['scope.userLocation'] == false) { wx.showModal({ title: '提示', content: '您未开启定位权限,将导致无法使用本软件', showCancel: false }); } else { wx.showModal({ title: '提示', content: '您已开启定位权限,请重新点击登录', showCancel: false }); } } }); } } })

微信小程序如何进行精准的定位授权操作?

本文共计163个文字,预计阅读时间需要1分钟。

微信小程序如何进行精准的定位授权操作?

javascriptwx.getLocation({ type: 'wgs84', success: function(res) { var latitude=res.latitude; var longitude=res.longitude; wx.login({}); }, fail: function(res) { // 未开启定位权限,拉起授权 if (res.errMsg==='getLocation:fail auth deny') { // 引导用户开启定位权限 } }});

location.js

wx.getLocation({ type: 'wgs84', success: function (res) { var latitude = res.latitude; var longitude = res.longitude; wx.login({ }); }, fail: function (res) { //未开启定位权限,拉起授权 if (res.errMsg == 'getLocation:fail auth deny') { //重新拉起授权 wx.openSetting({ success: function (res) { if (res.authSetting['scope.userLocation'] == false) { wx.showModal({ title: '提示', content: '您未开启定位权限,将导致无法使用本软件', showCancel: false }); } else { wx.showModal({ title: '提示', content: '您已开启定位权限,请重新点击登录', showCancel: false }); } } }); } } })

微信小程序如何进行精准的定位授权操作?