diff --git a/pages/index/index.vue b/pages/index/index.vue index 8ebde58..bdd334c 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -322,36 +322,9 @@ }, onLoad() { let that = this - uni.getLocation({ - type: 'gcj02', - geocode: true, //设置该参数为true可直接获取经纬度及城市信息 - highAccuracyExpireTime: 500, - success: function(res) { - console.log(res, '地理位置-----------------------》') - that.latitude = res.latitude - that.longitude = res.longitude - - uni.setStorageSync('latitude', res.latitude) - uni.setStorageSync('longitude', res.longitude) - if (that.amap) { - that.amap.setCenter(new AMap.LngLat(res.latitude, res.longitude)); - } - if (that.infoWindow) { - that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude)); - } - // that.getTypeList(); - }, - fail: function(e) { - console.log('获取地址失败1', e) - // #ifdef APP-PLUS - that.checkPermission(); - // #endif - } - }) - that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市' that.getBannerList() that.getHomeArtificerList() - that.getKTCityList(); + // that.getKTCityList(); that.remen() }, onShow() { @@ -360,27 +333,24 @@ that.city = uni.getStorageSync('city') ? uni.getStorageSync('city') : '请选择城市' that.token = uni.getStorageSync('token'); that.getKTCityList(); - // if (uni.getStorageSync('token')) { - if (that.latitude && that.longitude) { - // that.getlist() - } else { + if (uni.getStorageSync('token')) { uni.getLocation({ type: 'gcj02', - highAccuracyExpireTime: 500, geocode: true, //设置该参数为true可直接获取经纬度及城市信息 + // geocode: true, //设置该参数为true可直接获取经纬度及城市信息 success: function(res) { - console.log(res, '地理位置') + console.log('地理位置',res) + that.city=res.address.city that.latitude = res.latitude that.longitude = res.longitude - // that.getTypeList(); - // that.getlist() + that.getBannerList() + that.getHomeArtificerList() }, fail: function() { console.log('获取地址失败2') } }) } - // } // that.myId = uni.getStorageSync('userId') }, methods: { @@ -565,8 +535,8 @@ isStart: 1, status: 1, city: this.city, - longitude:'125.281198', - latitude:'43.883036', + longitude:this.longitude, + latitude:this.latitude, page: 1, limit: 3 } diff --git a/pages/therapist/therapistList.vue b/pages/therapist/therapistList.vue index 65f7454..66e8501 100644 --- a/pages/therapist/therapistList.vue +++ b/pages/therapist/therapistList.vue @@ -536,20 +536,21 @@ geocode: true, //设置该参数为true可直接获取经纬度及城市信息 highAccuracyExpireTime: 500, success: function(res) { - console.log(res, '地理位置') + console.log( '地理位置',res) + that.latitude = res.latitude that.longitude = res.longitude uni.setStorageSync('latitude', res.latitude) uni.setStorageSync('longitude', res.longitude) - // if (that.cmap) { - // that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude)); - // } - // if (that.infoWindow) { - // that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude)); - // } - // if(that.amap){ + if (that.cmap) { + that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude)); + } + if (that.infoWindow) { + that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude)); + } + if(that.amap){ - // } + } that.page = 1 that.getlist() }, @@ -589,6 +590,33 @@ that.getTpCount(); that.getTpMy(); if (uni.getStorageSync('token')) { + uni.getLocation({ + type: 'gcj02', + geocode: true, //设置该参数为true可直接获取经纬度及城市信息 + highAccuracyExpireTime: 500, + success: function(res) { + console.log( '地理位置',res) + + that.latitude = res.latitude + that.longitude = res.longitude + uni.setStorageSync('latitude', res.latitude) + uni.setStorageSync('longitude', res.longitude) + if (that.cmap) { + that.cmap.setCenter(new TMap.LatLng(res.latitude, res.longitude)); + } + if (that.infoWindow) { + that.infoWindow.setPosition(new TMap.LatLng(res.latitude, res.longitude)); + } + if(that.amap){ + + } + that.page = 1 + that.getlist() + }, + fail: function(e) { + console.log('获取地址失败', e) + } + }) that.getIsVip() } that.myId = uni.getStorageSync('userId')