diff --git a/pages.json b/pages.json index 6535019..73be877 100644 --- a/pages.json +++ b/pages.json @@ -42,6 +42,17 @@ } } }, + { + "path": "pages/index/searchAddress", + "style": { + "navigationBarTitleText": "搜索地址", + "enablePullDownRefresh": true, + "navigationStyle": "custom", + "app-plus": { + "titleNView": false + } + } + }, { "path": "pages/videoCircle/index", "style": { diff --git a/pages/index/index.vue b/pages/index/index.vue index de01f05..83617df 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -4,7 +4,7 @@ 盛安到家 + @tap="goCity"> {{ city }} @@ -424,24 +424,25 @@ }) // 116.481488,39.990464 // 125.424295,43.878294 + // that.getAddress(); var dizhi={ - key:'32c22db939160ba44394eb187f7897ae', - location:'116.481488,39.990464', - radius:'3000', - extensions:'base', - // poitype:'商务写字楼', - // roadlevel:'0' + key:'a90dccd8b55793bb939c38c7a4be3e15', + location:'125.424295,43.878294', + radius:'1000', + extensions:'all', + output:'JSON' + } uni.request({ url: 'https://restapi.amap.com/v3/geocode/regeo', data:dizhi, method:'GET', - success(re) { - if (re.status =='1') { - console.log("获取城市名称成功", re) - that.city = re ? re : '未知' + success(rea) { + console.log("获取城市名称成功", rea) + if (rea.statusCode ==200) { + that.city = rea.data.regeocode.addressComponent.township; + uni.setStorageSync('citySou',rea.data.regeocode.addressComponent.city) } else { - that.city ='请重试' console.log("获取信息失败,请重试!") } } @@ -556,6 +557,11 @@ // } }, methods: { + goCity(){ + uni.navigateTo({ + url:'/pages/index/searchAddress' + }) + }, searchBtn(){//搜索按钮 uni.navigateTo({ url:'/pages/my/fuwuGengduo?searchValue='+this.searchValue