diff --git a/components/xuan-switch/xuan-switch-ditu.vue b/components/xuan-switch/xuan-switch-ditu.vue index 1855c26..eb7efe5 100644 --- a/components/xuan-switch/xuan-switch-ditu.vue +++ b/components/xuan-switch/xuan-switch-ditu.vue @@ -96,6 +96,7 @@ export default { }); this.isSwitch = this.defaultSwitch; this.changeAnimation(); + console.log("开关--------------",this.isSwitch) }, methods: { changeSwitch(isSwitch) { diff --git a/pages/index/index.vue b/pages/index/index.vue index 273e62a..3078d57 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -404,7 +404,8 @@ type:'center', parType:'', contentVideo:'', - type:'center' + Key2:'ad684a15ebbb6f5d12c407a3d593c949', + latadd:'' } }, onShareAppMessage(res) { //发送给朋友 @@ -460,70 +461,16 @@ } }) uni.getLocation({ - type: 'wgs84', + 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) - - // #ifdef APP-PLUS - that.city = res.address.city - // that.selectCity(that.longitude, that.latitude); - uni.setStorageSync('city', res.address.city) - // that.page = 1 - // that.getorderlist('') - that.getKTCityList(); - // #endif that.selectCity(that.longitude,that.latitude) - // var dizhi={ - // key:'4f23770b6e53b96e7d0661a7ccfb9c21', - // location:that.longitude+','+res.latitude, - // radius:'1000', - // extensions:'all', - // output:'JSON' - // } - // uni.request({ - // url: 'https://restapi.amap.com/v3/geocode/regeo', - // data:dizhi, - // method:'GET', - // 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 { - // console.log("获取信息失败,请重试!") - // } - // } - // }); - // #ifdef H5 - - // that.city = that.latitude+','+that.longitude - // that.selectCity(that.longitude, that.latitude); - // #endif - - // #ifdef MP-WEIXIN - uni.request({ - url: 'https://apis.map.qq.com/ws/geocoder/v1/?location=' + that.latitude + - ',' + that.longitude + '&key=' + that.txAppKey, - success(re) { - if (re.statusCode === 200) { - let citydata = re.data.result.address_component.city - // console.log("获取城市名称成功", citydata)/ - that.city = citydata ? citydata : '未知' - uni.setStorageSync('city', citydata) - that.getKTCityList(); - // that.page = 1 - // that.getorderlist('') - } else { - console.log("获取信息失败,请重试!") - } - } - }); - // #endif }, fail: function(e) { this.cuowu=e @@ -540,6 +487,14 @@ that.XCXIsSelect = this.$queue.getData("XCXIsSelect"); let userId = uni.getStorageSync('userId') if (userId) { + var add=uni.getStorageSync('cityAdderss'); + if(add!=''){ + that.city=add.name; + var location=add.location.split(",") + that.longitude = location[0] + that.latitude = location[1] + console.log("location=========>",location) + } this.getTpMy(); this.getTpCount(); // this.checkNewUser(); @@ -554,8 +509,7 @@ this.getKTCityList(); this.getHomeArtificerList(); this.getHomeNearbyList(); - this.latitude = uni.getStorageSync('latitude') - this.longitude = uni.getStorageSync('longitude') + }else{ uni.navigateTo({ url: '/pages/public/login' @@ -646,32 +600,50 @@ goCity(){ var that = this uni.navigateTo({ - url:'/pages/index/searchAddress' + url:'/pages/index/searchAddress?text='+'index' }) - // uni.chooseLocation({ - // success: function(res) { - // console.log('经度:' + res); - // that.detailaddress = res.name - // that.latitude = res.latitude - // that.longitude = res.longitude - // that.selectCity(res.longitude, res.latitude); - // } - // }); - }, selectCity(longitude, latitude) { var that=this; - that.$Request.get('/app/Login/selectCity?lat=' + latitude + '&lng=' + longitude).then(res => { - if (res.code == 0) { - let chinaAddressParts = res.data.address.match(/^(?[^省]+省|[^自]+自治区|[^市]+市|[^县]+县|[^区]+区|[^town]+town|[^镇]+镇)?(?[^市]+市|[^县]+县|[^区]+区|[^town]+town|[^镇]+镇)?(?[^区]+区|[^县]+县|[^乡]+乡|[^街道]+街道)?(?.+)$/); - // uni.setStorageSync('city', res.data.province) - that.city=chinaAddressParts.groups.street - that.page = 1 - // that.getorderlist('') - that.getKTCityList(); - - } + 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.city=that.latadd + that.page = 1 + that.getKTCityList(); + } 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({ diff --git a/pages/index/searchAddress.vue b/pages/index/searchAddress.vue index e27681c..b73fbdd 100644 --- a/pages/index/searchAddress.vue +++ b/pages/index/searchAddress.vue @@ -1,13 +1,28 @@ @@ -15,27 +30,39 @@ export default{ data(){ return{ - latitude:'43.812042', - longitude:'125.438430', + latitude:'43.896819', + longitude:'125.430478', serviceTrue:true, - searchValue: '中意国际', + searchValue: '', address:'https://restapi.amap.com/v3/geocode/regeo', - gaojiIp:'https://restapi.amap.com/v5/place/text' + gaojiIp:'https://restapi.amap.com/v5/place/text', + gaojiIp1:'https://restapi.amap.com/v5/ip/location', + gaojiIp2:'https://restapi.amap.com/v3/geocode/geo', + Key1:'4f23770b6e53b96e7d0661a7ccfb9c21', + Key2:'ad684a15ebbb6f5d12c407a3d593c949', + adderssData:[], + textAdderss:'', + current:'' } }, - onLoad() { + onLoad(e) { var that=this; - that.getAdderrs() + if(e){ + that.textAdderss=e.text + that.current=e.current + } + uni.showLoading({ + title: '加载中...' + }) + // that.getDingwei() uni.getLocation({ - type: 'wgs84', + type: 'gcj02', geocode: true, //设置该参数为true可直接获取经纬度及城市信息 + highAccuracyExpireTime: 500, success: function(res) { - console.log(res, '地理位置') - // that.latitude = res.latitude - // that.longitude = res.longitude - - // that.getAdderrs() - + that.latitude = res.latitude + that.longitude = res.longitude + that.getDingwei() }, fail: function(e) { console.log("获取信息失败,请重试!",e) @@ -43,36 +70,85 @@ }) }, methods:{ + activeAdder(item){ + if(this.textAdderss=='index'){ + uni.setStorageSync('cityAdderss',item) + uni.switchTab({ + url:'/pages/index/index' + }) + }else{ + item.current=this.current + uni.setStorageSync('cityTherapist',item) + uni.switchTab({ + url:'/pages/therapist/therapist' + }) + } + }, + shuaxin(){ + this.getDingwei() + }, + getDingwei(){ + var that=this; + let longitude = that.longitude; + let latitude = that.latitude; + let amapKey = that.Key2; // 替换为你的高德地图API Key + let url = `https://restapi.amap.com/v3/geocode/regeo?key=${amapKey}&location=${longitude},${latitude}&radius=3000`; + uni.request({ + url: url, + success: (response) => { + uni.hideLoading(); + 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 latadd = address.replace(province,'').replace(city,'').replace(district,'').replace(township,'') + that.getAdderrs(latadd,city) + // 此处可以将地址设置到页面数据中,或者进行其他操作 + } else { + uni.hideLoading(); + uni.showToast({ + icon:'error', + title:'逆地理编码失败' + }) + console.log('逆地理编码失败', response.data); + } + }, + fail: (error) => { + uni.hideLoading(); + uni.showToast({ + icon:'error', + title:'网络请求失败' + }) + console.log('网络请求失败', error); + } + }); + }, input(res) {//搜索 输入框 this.searchValue=res; }, searchBtn(){//搜索按钮 - this.getAdderrs() + this.getDingwei() }, - getAdderrs(){ + getAdderrs(latadd,city){ var that=this; - // var dizhi={ - // keyword:that.searchValue, - // key:'4f23770b6e53b96e7d0661a7ccfb9c21', - // location:that.longitude+','+that.latitude, - // radius:'1000', - // extensions:'all', - // output:'JSON' - // } var dizhi={ - keywords:that.searchValue, - key:'4f23770b6e53b96e7d0661a7ccfb9c21', - location:that.longitude+','+that.latitude, + key:that.Key2, + keywords:that.searchValue!=''?that.searchValue:latadd, + // types:'120000', + region:city, + city_limit:true, + show_fields: "name,address", } uni.request({ url:that.gaojiIp, data:dizhi, method:'GET', - success(rea) { - console.log("获取城市名称成功", rea) - if (rea.statusCode ==200) { - // that.city = rea.data.regeocode.addressComponent.township; - // uni.setStorageSync('citySou',rea.data.regeocode.addressComponent.city) + success(res) { + if (res.statusCode ==200) { + console.log("获取城市名称成功", res.data.pois) + that.adderssData=res.data.pois } else { console.log("获取信息失败,请重试!") } @@ -84,7 +160,41 @@ \ No newline at end of file diff --git a/pages/my/index.vue b/pages/my/index.vue index 4bdfb6d..7a34605 100644 --- a/pages/my/index.vue +++ b/pages/my/index.vue @@ -289,15 +289,6 @@ } }, methods: { - itemClick(item) { //热门精选,推荐套餐 跳详情 - if(item.type){ - - } - uni.navigateTo({ - url: '/pages/my/fuwuDateil?id=' + item.id + '&limit=' + '10' + '&page=' + - '1' - }) - }, goMsg() { //客服聊天 let data = { userId: uni.getStorageSync('userId'), diff --git a/pages/therapist/therapist.vue b/pages/therapist/therapist.vue index 308e2b4..6fab878 100644 --- a/pages/therapist/therapist.vue +++ b/pages/therapist/therapist.vue @@ -12,12 +12,8 @@ action-text="搜索" @custom="onSearch()"> - + - @@ -36,9 +32,7 @@ - + @@ -54,13 +48,7 @@ {{item.time}} - + @@ -69,16 +57,14 @@ - + 评论 {{ item.commentCount ? item.commentCount : 0 }} - + 收藏 {{ item.collectCount ? item.collectCount : 0 }} @@ -91,28 +77,16 @@ {{item.consortiaName}} - {{ item.distance }} - - - + ', this, uni); this.initMap(); + //this.initMapPointThread(); }, onUnload() { @@ -488,39 +438,26 @@ import permision from "@/components/permission.js"; }, methods: { changeClick(index,item){ - // this.classifyId=item.id this.artificerName=''; this.technicianType=item.id - console.log('this.technicianType===========>',this.technicianType) this.getlist() }, getlist() { - // if (this.city === '请选择城市') { - // return; - // } - // if (this.tabIndex == 0) { - // return; - // } - // let index = this.list[this.listIndex].id + var that=this; let index = 2 let data = { - // id: curTab, - artificerName: this.artificerName, - classifyId: this.tabIndex, - page: this.page, - limit: this.limit, - technicianType:this.technicianType, - // massageTypeId: this.massageTypeId, - // condition: this.value1, //智能优选 - // authentication: this.value2, //不限男女 + artificerName: that.artificerName, + classifyId: that.tabIndex, + page: that.page, + limit: that.limit, + technicianType:that.technicianType, by: index, //价格 - latitude: this.latitude, - longitude: this.longitude, - city: this.city + latitude: that.latitude, + longitude: that.longitude, + city: that.city } - // console.log(data) - this.$Request.get("/app/artificer/selectArtificerList", data).then(res => { - this.loading = false; + that.$Request.get("/app/artificer/selectArtificerList", data).then(res => { + that.loading = false; if (res.code == 0) { for (var i = 0; i < res.data.list.length; i++) { if (res.data.list[i].lifePhoto) { @@ -534,24 +471,24 @@ import permision from "@/components/permission.js"; } } - if (this.page == 1) { - this.orderList = res.data.list + if (that.page == 1) { + that.orderList = res.data.list } else { - this.orderList = [...this.orderList, ...res.data.list] + that.orderList = [...that.orderList, ...res.data.list] } //加载到地图里 - if (this.amap) { + if (that.amap) { // debugger; - console.log(this.orderList) - if (this.orderList.length > 0) { + console.log("that.orderList=========>",that.orderList) + if (that.orderList.length > 0) { let rmap = {}; - let onLineArtificerList = this.orderList.filter((item) => item.status == 1); + let onLineArtificerList = that.orderList.filter((item) => item.status == 1); onLineArtificerList.forEach(x => { rmap[x.userId] = x.latitude + ',' + x.longitude; //没有给个签到坐标 }); console.log('在orderList初始化:', JSON.parse(JSON.stringify(rmap))); - this.pointMap = rmap; - this.creatMarker(rmap); + that.pointMap = rmap; + that.creatMarker(rmap); } } @@ -596,7 +533,6 @@ import permision from "@/components/permission.js"; }else{ this.current = 0; } - console.log('switch1 发生 change 事件,携带值为', Number(e),e) }, showTips() { uni.showToast({ @@ -616,7 +552,10 @@ import permision from "@/components/permission.js"; return; } // #endif - this.Cityshow = true; + var that = this + uni.navigateTo({ + url:'/pages/index/searchAddress?text='+'therapist'+'¤t='+that.current + }) }, async checkPermission() { let status = permision.isIOS ? await permision.requestIOS('location') : await permision.requestAndroid( @@ -779,19 +718,36 @@ import permision from "@/components/permission.js"; } }); }, - // selectCity(longitude, latitude) { - // this.$Request.get('/app/Login/selectCity?lat=' + latitude + '&lng=' + longitude).then(res => { - // if (res.code == 0) { - // // this.city = res.data.city ? res.data.city : '未知' - // // uni.setStorageSync('city', res.data.city) - // let data = { - // num: 1, - // size: 10 - // } - // this.getData(data) - // } - // }); - // }, + 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.city=that.latadd + that.page = 1 + that.getKTCityList(); + } else { + console.log('逆地理编码失败', response.data); + } + }, + fail: (error) => { + console.log('网络请求失败', error); + } + }); + }, tanChange(index, item) { this.orderIndex = index this.tabIndex = item.id @@ -897,36 +853,6 @@ import permision from "@/components/permission.js"; this.page = 1 this.getlist() }, - // 选择城市 - goSelectCity() { - // uni.navigateTo({ - // url: '/pages/index/citys/citys' - // }); - let that = this - uni.chooseLocation({ - success: function(res) { - console.log('位置名称:' + res.name); - console.log('详细地址:' + res.address); - console.log('纬度:' + res.latitude); - console.log('经度:' + res.longitude); - that.latitude = res.latitude - that.longitude = res.longitude - uni.setStorageSync('latitude', res.latitude) - uni.setStorageSync('longitude', res.longitude) - that.selectCity(that.longitude, that.latitude); - } - }); - }, - selectCity(longitude, latitude) { - this.$Request.get('/app/Login/selectCity?lat=' + latitude + '&lng=' + longitude).then(res => { - if (res.code == 0) { - this.city = res.data.city ? res.data.city : '未知' - uni.setStorageSync('city', res.data.city) - this.page = 1 - this.getlist() - } - }); - }, // 乐享低价 goLowTaking() { uni.navigateTo({ @@ -1039,11 +965,19 @@ import permision from "@/components/permission.js"; success: function(res) { let longitude = res.longitude; let latitude = res.latitude; - console.log('当前位置的经度:' + longitude); - console.log('当前位置的纬度:' + latitude); - console.log('定位成功', latitude, longitude); + console.log('当前位置的经度=========1:' + longitude); + console.log('当前位置的纬度2=========:' + latitude); if (amap) { - uni.amap.setCenter([longitude, latitude]) + var add=uni.getStorageSync('cityTherapist'); + if(add!=''){ + var location=add.location.split(",") + that.longitude = location[0] + that.latitude = location[1] + console.log("locationlocationlocationlocation>",location) + uni.amap.setCenter([location[0],location[1]]) + + + } } }, fail(res) { @@ -1064,6 +998,8 @@ import permision from "@/components/permission.js"; }, creatMarker(map) { let that = this; + console.log("uni.amap=============>",uni.amap) + console.log("map=============>",map) webMap.addMarker(uni.amap, map, this.orderList, (e, udata) => { that.currentMarkerIndex = udata.userId; that.showPopup = true; @@ -1263,6 +1199,18 @@ import permision from "@/components/permission.js";