上线版本 真机关于获取地址之后保存到本地 再去获取没有找到
发布于 5 年前 作者 min85 1924 次浏览 来自 问答

上线版本  真机关于获取地址之后保存到本地  再去获取没有找到 但是在测试环境中可以找到,

//,这是获取时的代码

wx.getLocation({

type: ‘gcj02’, //返回可以用于wx.openLocation的经纬度

success: function(res) {

console.log(‘获取地理位置!’);

console.log(res);

// _this.setData({

//   ‘SerchModule.address’: res.address.slice(0, res.address.indexOf(‘省’)+1),

// })

qqmapsdk.reverseGeocoder({

location: {

latitude: res.latitude,

longitude: res.longitude

},

success: function(res) {

console.log(res);

_this.setData({

‘SerchModule.address’: res.result.ad_info.district || res.result.ad_info.city

})

wx.setStorageSync(‘MyPosition’, res);

},

fail: res => {

//接口调用失败,提示用户打开定位功能

this.wetoast.toast({

title: ‘获取定位失败,请打开定位,重新进入!’

});

wx.getSetting({

success(res) {

if (!res.authSetting[‘scope.userLocation’]) {

wx.authorize({

scope: ‘scope.userLocation’,

success(res) {

console.log(res);

// 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问

// wx.startRecord()

}

})

}

}

})

}

})

}

})// 这是找本地保存的数据的代码

MyPosition: wx.getStorageSync(‘MyPosition’),

3 回复

哎呦我去,易洋千玺的优秀的粉丝好多呀~~ 我还以为来微博了呢

有没有代码片段链接提供?有可能是自己代码写错了

回到顶部