|
@@ -121,14 +121,24 @@
|
|
|
this.cityname = location.cityname;
|
|
|
this.cityCode = location.cityCode;
|
|
|
this.location=location
|
|
|
-
|
|
|
that.queryHomeDetail();
|
|
|
-
|
|
|
-
|
|
|
} else {
|
|
|
- uni.showToast({
|
|
|
+ /* uni.showToast({
|
|
|
title: '请选择城市'
|
|
|
- })
|
|
|
+ }) */
|
|
|
+ uni.getLocation({
|
|
|
+ type: 'gcj02',
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res)
|
|
|
+ that.lng=res.longitude
|
|
|
+ that.lat=res.latitude
|
|
|
+ that.getAdress();
|
|
|
+
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
},
|
|
@@ -200,7 +210,40 @@
|
|
|
console.log(e);
|
|
|
this.time = e.target.value
|
|
|
},
|
|
|
-
|
|
|
+ getAdress(){
|
|
|
+ var location=this.lng+','+this.lat
|
|
|
+ uni.request({
|
|
|
+ url: 'https://restapi.amap.com/v3/place/around', //仅为示例,并非真实接口地址。
|
|
|
+ data: {
|
|
|
+ key: '064b6a4a8ade55656edcde2f528876de',
|
|
|
+ location: location,
|
|
|
+ types:"190000",
|
|
|
+ extensions:"all",
|
|
|
+ radius:100
|
|
|
+ },
|
|
|
+ dataType: "json",
|
|
|
+ success: (res) => {
|
|
|
+ console.log(res);
|
|
|
+ this.cityname=res.data.pois[0].cityname;
|
|
|
+ var cityCode=res.data.pois[0].adcode
|
|
|
+ cityCode=cityCode.slice(0, -2)
|
|
|
+ cityCode=cityCode+'00'
|
|
|
+ this.cityCode=cityCode
|
|
|
+ var obj={
|
|
|
+ cityname:this.cityname,
|
|
|
+ lng:this.lng,
|
|
|
+ lat:this.lat,
|
|
|
+ cityCode:cityCode
|
|
|
+ }
|
|
|
+ uni.setStorage({
|
|
|
+ key: 'location',
|
|
|
+ data: obj,
|
|
|
+ success: function () {}
|
|
|
+ });
|
|
|
+ this.queryHomeDetail();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
|
|
|
}
|