From 2d128b3c7d74118ad137ada9a80fd7fc1e01e4b6 Mon Sep 17 00:00:00 2001 From: "Mr.jiang" <714156421@qq.com> Date: Tue, 13 Aug 2024 15:56:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/index.vue | 152 ++++++++++++++------------- pages/therapist/therapist.vue | 69 +++++++----- pages/therapist/therapistDingdan.vue | 10 +- 3 files changed, 129 insertions(+), 102 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index fd7add7..38a3b41 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -409,7 +409,8 @@ parType:'', contentVideo:'', Key2:'ad684a15ebbb6f5d12c407a3d593c949', - latadd:'' + latadd:'', + cityname:'' } }, onShareAppMessage(res) { //发送给朋友 @@ -464,28 +465,39 @@ } } }) - 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) - that.getHomeNearbyList(); - that.selectCity(that.longitude,that.latitude) - }, - fail: function(e) { - that.cuowu=e - that.getHomeNearbyList(); - console.log("获取信息失败,请重试!",e) - // #ifdef APP-PLUS - that.checkPermission(); - // #endif - } - }) + var add=uni.getStorageSync('cityAdderss'); + if(add!=''){ + that.city=add.name; + that.cityname=add.cityname; + var location=add.location.split(",") + that.longitude = location[0] + that.latitude = location[1] + console.log("onLoad=========>",add) + }else{ + 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) + that.getHomeNearbyList(); + that.selectCity(that.longitude,that.latitude) + }, + fail: function(e) { + that.cuowu=e + that.getHomeNearbyList(); + console.log("获取信息失败,请重试!",e) + // #ifdef APP-PLUS + that.checkPermission(); + // #endif + } + }) + } + that.getVideo() }, onShow() { @@ -496,23 +508,21 @@ var add=uni.getStorageSync('cityAdderss'); if(add!=''){ that.city=add.name; + that.cityname=add.cityname; var location=add.location.split(",") that.longitude = location[0] that.latitude = location[1] - console.log("location=========>",location) + console.log("onShow=========>",add) } that.getTpMy(); - that.getTpCount(); - // this.checkNewUser(); + // that.getTpCount(); // #ifdef MP-WEIXIN //订阅 if (that.showModal) { that.openMsg() } // #endif - // this.city = uni.getStorageSync('city')//测试用的 测试结束关闭 that.getIsVip() - // that.getKTCityList(); that.getHomeArtificerList(); that.getHomeNearbyList(); }else{ @@ -528,7 +538,45 @@ } }, methods: { - + selectCity(longitude, latitude) { + var that=this; + var longitude = that.longitude; + var latitude = that.latitude; + let amapKey = that.Key2; // 替换为你的高德地图API Key + let url = `https://restapi.amap.com/v3/geocode/regeo?key=${amapKey}&location=${longitude},${latitude}&radius=1000`; + uni.request({ + url: url, + success: (response) => { + if(response.data && response.data.regeocode) { + let address = response.data.regeocode.formatted_address; + let province = response.data.regeocode.addressComponent.province; + let city = response.data.regeocode.addressComponent.city; + let district = response.data.regeocode.addressComponent.district; + let township = response.data.regeocode.addressComponent.township; + let streetNumber = response.data.regeocode.addressComponent.streetNumber.street; + let number = response.data.regeocode.addressComponent.streetNumber.number; + that.city = address.replace(province,'').replace(city,'').replace(district,'').replace(streetNumber,'').replace(number,'').replace(township,'') + that.cityname=add.city; + var add=uni.getStorageSync('cityAdderss'); + if(add!=''){ + that.city=add.name; + that.cityname=add.cityname; + var location=add.location.split(",") + that.longitude = location[0] + that.latitude = location[1] + console.log("location=========>",location) + } + that.page = 1; + // that.getTpCount(); + } else { + console.log('逆地理编码失败', response.data); + } + }, + fail: (error) => { + console.log('网络请求失败', error); + } + }); + }, guanbi(){ this.playShow=false; const videoContext = uni.createVideoContext('myVideo', this); @@ -609,47 +657,7 @@ url:'/pages/index/searchAddress?text='+'index' }) }, - selectCity(longitude, latitude) { - var that=this; - var longitude = that.longitude; - var latitude = that.latitude; - let amapKey = that.Key2; // 替换为你的高德地图API Key - let url = `https://restapi.amap.com/v3/geocode/regeo?key=${amapKey}&location=${longitude},${latitude}&radius=1000`; - uni.request({ - url: url, - success: (response) => { - if(response.data && response.data.regeocode) { - let address = response.data.regeocode.formatted_address; - let province = response.data.regeocode.addressComponent.province; - let city = response.data.regeocode.addressComponent.city; - let district = response.data.regeocode.addressComponent.district; - let township = response.data.regeocode.addressComponent.township; - let streetNumber = response.data.regeocode.addressComponent.streetNumber.street; - let number = response.data.regeocode.addressComponent.streetNumber.number; - that.city = address.replace(province,'').replace(city,'').replace(district,'').replace(streetNumber,'').replace(number,'').replace(township,'') - that.page = 1; - that.getTpCount(); - } else { - console.log('逆地理编码失败', response.data); - } - }, - fail: (error) => { - console.log('网络请求失败', error); - } - }); - // that.$Request.get('/app/Login/selectCity?lat=' + latitude + '&lng=' + longitude).then(res => { - // if (res.code == 0) { - // console.log("我的地址",res) - // let chinaAddressParts = res.data.address.match(/^(?[^省]+省|[^自]+自治区|[^市]+市|[^县]+县|[^区]+区|[^town]+town|[^镇]+镇)?(?[^市]+市|[^县]+县|[^区]+区|[^town]+town|[^镇]+镇)?(?[^区]+区|[^县]+县|[^乡]+乡|[^街道]+街道)?(?.+)$/); - - // that.city=chinaAddressParts.groups.street - // that.page = 1 - - // that.getKTCityList(); - - // } - // }); - }, + searchBtn(){//搜索按钮 uni.navigateTo({ url:'/pages/my/fuwuGengduo?searchValue='+this.searchValue @@ -1011,7 +1019,7 @@ var data={ isStart: 1, status: 1, - // city: this.city, + // city:this.cityname, longitude:this.longitude, latitude:this.latitude, page: 1, @@ -1046,7 +1054,7 @@ var data={ isStart: 1, status: 1, - // city: this.city, + // city:this.cityname, longitude:this.longitude, latitude:this.latitude, page: 1, diff --git a/pages/therapist/therapist.vue b/pages/therapist/therapist.vue index 1d13777..a4f2e28 100644 --- a/pages/therapist/therapist.vue +++ b/pages/therapist/therapist.vue @@ -72,16 +72,17 @@ - - - {{item.consortiaName}} - {{ item.distance }} + + + {{item.consortiaName}} + + @@ -168,16 +169,17 @@ - - - {{getOrderByCurrentMarkerIndex().consortiaName}} - {{ getOrderByCurrentMarkerIndex().distance }} + + + {{getOrderByCurrentMarkerIndex().consortiaName}} + +