diff --git a/components/FilterPopup/FilterPopup.vue b/components/FilterPopup/FilterPopup.vue index 50e37f8..55295de 100644 --- a/components/FilterPopup/FilterPopup.vue +++ b/components/FilterPopup/FilterPopup.vue @@ -42,7 +42,7 @@ 伴宠师等级 - + 初级伴宠师 diff --git a/components/addressMap.vue b/components/addressMap.vue index f9ac786..9813f7e 100644 --- a/components/addressMap.vue +++ b/components/addressMap.vue @@ -73,9 +73,9 @@ // 根据最大距离设置缩放比例 // 距离越大,缩放比例越小 if (maxDistance > 100) { // - this.scale = 2 - }else if (maxDistance > 50) { // this.scale = 5 + }else if (maxDistance > 50) { // + this.scale = 8 }else if (maxDistance > 10) { // 10公里以上 this.scale = 10 } else if (maxDistance > 5) { // 5-10公里 diff --git a/pages/index.vue b/pages/index.vue index 51ba288..e6f26e6 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -149,36 +149,42 @@ - + + :src="item.userImage"> - {{defaultCompanion.name}} + {{ item.userName || '匿名' }} - sex + sex - 客户点赞数{{defaultCompanion.star}} - + 点赞数{{ item.appletUsersTeacher.thumbsUp || 0 }} + - - 距离{{defaultCompanion.distance}}km + + 距离{{ item.distanceText }}km + + + {{ '<' }}1km - - 简介:{{defaultCompanion.shortDescription}} + + 简介:{{ item.appletUsersTeacher.userBrief || '暂无' }} @@ -186,10 +192,16 @@ - 养宠{{defaultCompanion.year}}年 | 评价{{defaultCompanion.record}}条 | 服务小结{{defaultCompanion.serviceNum}}份 + 养宠{{ item.experience || 0 }}年 | 评价{{ item.commentNum || 0 }}条 | 服务小结{{ item.serviceSummaryNum || 0 }}份 + + + + 您周边没有伴宠师呢 + + @@ -240,7 +252,7 @@ style="width: 100%;" mode="widthFix" alt="service" /> - + { + uni.getLocation({ + type: 'gcj02', + success: (res) => { + resolve(res) + } + }) + }) + }, + async getCompanionList() { // 构建参数,使用当前位置坐标 let data = { - address: this.locationAddress || "上海市浦东新区浦东南路150弄", - latitude: this.locationLatitude || 31.22514, - longitude: this.locationLongitude || 121.49857, - petTypes: ["1", "2"], - staffName: "" + latitude: this.position.latitude, + longitude: this.position.longitude, } - console.log('获取周边伴宠师参数:', data); - - // 保存当前位置到Vuex,让position mixin能使用 - this.$store.commit('setPosition', { - address: this.locationAddress, - longitude: this.locationLongitude, - latitude: this.locationLatitude - }); - - getTeacherListIndex(data).then(response => { - if (response.code == 200 && response.rows && response.rows.length > 0) { - const nearbyTeacher = response.rows[0]; - console.log('伴宠师原始数据:', nearbyTeacher); - - // 如果伴宠师有地址信息,使用mixin的calculateDistanceAddress计算距离 - let distance = 0; - if (nearbyTeacher.addressList && nearbyTeacher.addressList.length > 0) { - distance = this.calculateDistanceAddress(nearbyTeacher.addressList); - } else if (nearbyTeacher.latitude && nearbyTeacher.longitude) { - // 如果没有地址列表但有经纬度信息,则构造地址对象 - const addressList = [{ - latitude: nearbyTeacher.latitude, - longitude: nearbyTeacher.longitude - }]; - distance = this.calculateDistanceAddress(addressList); - } - - // 处理用户图片 - let userImageUrl = ""; - if (typeof nearbyTeacher.userImage === 'string') { - userImageUrl = nearbyTeacher.userImage; - } else if (nearbyTeacher.userImage && Array.isArray(nearbyTeacher.userImage) && nearbyTeacher.userImage.length > 0) { - userImageUrl = nearbyTeacher.userImage[0].url || ""; - } - - // 构建伴宠师信息对象 - this.defaultCompanion = { - name: nearbyTeacher.userName || '宠小二', - gender: nearbyTeacher.gender || '1', // 性别,1-男,2-女 - star: nearbyTeacher.likeNum || 0, - distance: distance.toFixed(1), - shortDescription: nearbyTeacher.shortDescription || '专业伴宠师,用心照顾每一位小宠物', - staffImages: [{ - url: userImageUrl || "https://catmdogf.oss-cn-shanghai.aliyuncs.com/CMDF/front/personal/pet/catdog.png" - }], - year: nearbyTeacher.serviceAge || 1, // 服务年限 - record: nearbyTeacher.commentNum || 0, // 评价数 - serviceNum: nearbyTeacher.serviceSummaryNum || 0 // 服务小结数 - } - - console.log('周边伴宠师信息:', this.defaultCompanion); - } else { - console.log('没有找到周边伴宠师或返回数据有误'); + + if(!data.latitude){ + let res = await this.getLocation() + data.latitude = res.latitude + data.longitude = res.longitude + } + + getTeacherList(data).then(response => { + if (response.code == 200) { + this.companionList = response.rows + this.calculateTeacherListDistance() } - }).catch(err => { - console.error('获取周边伴宠师失败:', err); + console.log(response); + }) + }, + calculateTeacherListDistance(){ + this.companionList.forEach(item => { + item.distanceText = this.calculateDistanceAddress(item.appletAddresseList) }) + + this.companionList.sort((a,b) => a.distanceText - b.distanceText) }, getOrder(value) { if (value) { @@ -975,6 +962,18 @@ background-color: #F5F5F7 !important; } + .no-data{ + width: 100%; + height: 100%; + display: flex; + align-items: center; + justify-content: center; + .no-data-text{ + font-size: 24rpx; + color: #999; + } + } + .home-content { position: relative; diff --git a/pages/newOrder/serviceNew.vue b/pages/newOrder/serviceNew.vue index 4850ad6..3132124 100644 --- a/pages/newOrder/serviceNew.vue +++ b/pages/newOrder/serviceNew.vue @@ -29,7 +29,9 @@ - +