赞
踩
"permission" : {
"scope.userLocation" : {
"desc" : "医生护士上门需要地址位置信息"
}
},
"requiredPrivateInfos": ["getLocation", "chooseAddress", "chooseLocation"]
<template> <view class=""> <button @click="gotoss">获取当前位置</button> <button @click="aaaaaaa">获取当前位置</button> </view> </template> <script> export default { data() { return { } }, methods: { gotoss() { let that = this wx.getLocation({ type: 'gcj02', success: function(res) { wx.openLocation({ latitude: res.latitude, longitude: res.longitude, scale: 18, success: function(res) { wx.chooseLocation({ success: function(res) { console.log(res) } }) } }) }, fail: function(err) { console.log(err) uni.showToast({ title: '获取地址失败,将导致部分功能不可用', icon: 'none' }); } }); }, aaaaaaa() { wx.getSetting({ success(res) { console.log("vres.authSetting['scope.address']:",res.authSetting['scope.address']) if (res.authSetting['scope.address']) { console.log("111") wx.chooseAddress({ success(res) { console.log(res.userName) console.log(res.postalCode) console.log(res.provinceName) console.log(res.cityName) console.log(res.countyName) console.log(res.detailInfo) console.log(res.nationalCode) console.log(res.telNumber) } }) // 用户已经同意小程序使用录音功能,后续调用 wx.startRecord 接口不会弹窗询问 } else { if (res.authSetting['scope.address'] == false) { console.log("222") wx.openSetting({ success(res) { console.log(res.authSetting) } }) } else { console.log("eee") wx.chooseAddress({ success(res) { console.log(res.userName) console.log(res.postalCode) console.log(res.provinceName) console.log(res.cityName) console.log(res.countyName) console.log(res.detailInfo) console.log(res.nationalCode) console.log(res.telNumber) } }) } } } }) }, } } </script> <style> </style>
ditu(address) { // let address = "广东省深圳市龙华区大浪街道同胜社区华荣路联建工业园厂房2号1层" uni.request({ url: 'https://restapi.amap.com/v3/geocode/geo?parameters', method: 'GET', data: { key: '',//自己在高德上的key address: address }, success: (res) => { if (res.data.status == 1) { console.log('高德res', res.data.geocodes[0]) let jd = res.data.geocodes[0].location.split(',')[0] let wd = res.data.geocodes[0].location.split(',')[1] // Map.openMap(parseFloat(wd), parseFloat(jd), address, 'gcj02') var that = this wx.openLocation({ latitude: parseFloat(wd), longitude: parseFloat(jd), name: address, address: address, }) } } }) },
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。