onLoad: function (options) { var that = this; wx.getSetting({ success: (res) => { if (res.authSetting['scope.userLocation'] != undefined && res.authSetting['scope.userLocation'] != true) {//非初始化进入该页面,且未授权 wx.showModal({ title: '是否授权当前位置', content: '需要获取您的地理位置,请确认授权,否则无法获取您所需数据', success: function (res) { if (res.cancel) { wx.showToast({ title: '授权失败', icon: 'success', duration: 1000 }) } else if (res.confirm) { wx.openSetting({ success: function (dataAu) { console.log(dataAu + "同意授权"); if (dataAu.authSetting["scope.userLocation"] == true) { wx.showToast({ title: '授权成功', icon: 'success', duration: 1000 }) //再次授权,调用getLocationt的API that.getaddress(); } else { wx.showToast({ title: '授权失败', icon: 'success', duration: 1000 }) } } }) } } }) } else if (res.authSetting['scope.userLocation'] == undefined) {//初始化进入 that.getaddress(); } else { //授权后默认加载 that.getaddress(); } } })},getaddress() { var that = this; //实例化腾讯地图API核心类 qqmapsdk = new QQMapWX({ key: 'ssdasdasd' }); //1、获取当前的地理位置、速度 wx.getLocation({ type: 'wgs84', success: function (res) { console.log("latitude:" + res.latitude + "---longitude:" + res.longitude + "---speed:" + res.speed + "---accuracy:" + res.accuracy); //2、根据坐标获取当前位置名称,显示在顶部:腾讯地图逆地址解析 var sessionID = wx.getStorageSync('sessionId') ? wx.getStorageSync('sessionId') : ''; that.setData({ lat: res.latitude, lng: res.longitude }); var mymes = { lat: res.latitude, lng: res.longitude }; wx.request({ url: 'https:/API/wxgetdata/TranslateLocation', data: mymes, //dataType: 'json', header: { 'sessionID': sessionID }, success(result) { console.log(result); var mes = result.data; var jsondata = mes.data; console.log(jsondata); that.setData({ lat: jsondata.lat, lng: jsondata.lng, curlocation: jsondata.address }); that.getData(); } }); }, fail: function () { wx.showToast({ title: '授权失败', icon: 'success', duration: 1000 }) } })}, |
以上是部分核心代码,不知道是什么原因真机测试没问题但是就是线上都没有授权弹窗提示,页面为空白页,以下为实例图:

是不是没设置小程序服务器域名和业务域名
开一下调试模式,看一看有没有报错信息