"permission" : {
            "scope.userFuzzyLocation": {
                "desc": "你的位置信息将用于小程序位置接口的效果展示"
            }
        },
        "requiredPrivateInfos": [
            "getFuzzyLocation"
        ]

 

 

//获取定位
                wx.authorize({
                    scope: 'scope.userFuzzyLocation',
                    success:(res)=> {
                        wx.getFuzzyLocation({
                            type: 'gcj02',
                            success: res => {
                                console.log(res);
                                uni.request({
                                    url: 'https://restapi.amap.com/v3/geocode/regeo',
                                    data: {
                                        location: res.longitude + ',' + res.latitude, 
                                        key: 'a6d71000008a50000000000000756deb50'
                                    },
                                    complete: (res) => {
                                        let str = res.data.regeocode.addressComponent.city
                                    }
                                })
                            },
                        })
                    },
                })

 

 posted on 2022-10-11 15:57  laremehpe  阅读(1226)  评论(0编辑  收藏  举报