瀏覽代碼

no message

xiaoxin 2 年之前
父節點
當前提交
a66dac408c
共有 1 個文件被更改,包括 42 次插入15 次删除
  1. 42 15
      pages/home3/home3.vue

+ 42 - 15
pages/home3/home3.vue

@@ -60,7 +60,7 @@
 
 
 			<view class="body">
 			<view class="body">
 				<!-- 优选民宿区域 -->
 				<!-- 优选民宿区域 -->
-				<view class="body_top" v-if="hotelList.length">
+				<view class="body_top" v-if="hotelList_you.length">
 					<view class="circle"></view>
 					<view class="circle"></view>
 					<view class="circle color"></view>
 					<view class="circle color"></view>
 					<view class="top_title">优选民宿 .</view>
 					<view class="top_title">优选民宿 .</view>
@@ -72,7 +72,7 @@
 				</view>
 				</view>
 				<view class="body_list">
 				<view class="body_list">
 					<!-- 每一个民宿区域 -->
 					<!-- 每一个民宿区域 -->
-					<view class="list_item" v-for="item in hotelList.slice(0, 4)" :key="item.id" @click="goPageDetail(item)">
+					<view class="list_item" v-for="(item, index) in hotelList_you" :key="index" @click="goPageDetail(item)">
 						<image class="item-img" :src="item.coverImg" mode="scaleToFill"></image>
 						<image class="item-img" :src="item.coverImg" mode="scaleToFill"></image>
 						<view class="descrition">
 						<view class="descrition">
 							<text class="title">{{ item.hotel_name }}</text>
 							<text class="title">{{ item.hotel_name }}</text>
@@ -286,8 +286,10 @@ export default {
 			placeIndex: 0,
 			placeIndex: 0,
 			// 选择乡镇弹窗数据
 			// 选择乡镇弹窗数据
 			popList: [],
 			popList: [],
-			// 民宿列表数组
+			// 精选民宿列表数组
 			hotelList: [],
 			hotelList: [],
+			// 优选民宿列表数组
+			hotelList_you: [],
 			// 当前乡镇
 			// 当前乡镇
 			town: '',
 			town: '',
 			// 民宿级别
 			// 民宿级别
@@ -339,7 +341,7 @@ export default {
 	onReachBottom() {
 	onReachBottom() {
 		if (this.hotelList.length < this.total) {
 		if (this.hotelList.length < this.total) {
 			this.page++
 			this.page++
-			this.getHotelList()
+			this.getHotelList_jing()
 		} else {
 		} else {
 			uni.showToast({
 			uni.showToast({
 				title: '没有更多数据了',
 				title: '没有更多数据了',
@@ -410,8 +412,8 @@ export default {
 				data: {
 				data: {
 					curPage: 1,
 					curPage: 1,
 					pageSize: 4,
 					pageSize: 4,
-					hot: 1,
-					state:1
+					hot: 1,
+					state: 1
 				}
 				}
 			})
 			})
 			// console.log(res)
 			// console.log(res)
@@ -478,7 +480,8 @@ export default {
 										this.myLat = res.latitude
 										this.myLat = res.latitude
 										this.myLng = res.longitude
 										this.myLng = res.longitude
 										this.showdDistance = true
 										this.showdDistance = true
-										this.getHotelList()
+										this.getHotelList_you()
+										this.getHotelList_jing()
 									}
 									}
 								})
 								})
 							},
 							},
@@ -497,7 +500,8 @@ export default {
 											})
 											})
 										} else {
 										} else {
 											this.showdDistance = false
 											this.showdDistance = false
-											this.getHotelList()
+											this.getHotelList_you()
+											this.getHotelList_jing()
 											uni.showToast({
 											uni.showToast({
 												title: '获取定位权限失败',
 												title: '获取定位权限失败',
 												icon: 'none'
 												icon: 'none'
@@ -514,7 +518,8 @@ export default {
 								this.myLat = res.latitude
 								this.myLat = res.latitude
 								this.myLng = res.longitude
 								this.myLng = res.longitude
 								this.showdDistance = true
 								this.showdDistance = true
-								this.getHotelList()
+								this.getHotelList_you()
+								this.getHotelList_jing()
 							}
 							}
 						})
 						})
 					}
 					}
@@ -547,16 +552,39 @@ export default {
 				}, 1500)
 				}, 1500)
 			}
 			}
 		},
 		},
-		// 获取民宿列表
-		async getHotelList() {
+		// 获取民宿列表  优选
+		async getHotelList_you() {
+			const res = await this.$myRequest({
+				url: '/mhotel/ahppreferredPage.action',
+				data: {
+					page: 1,
+					rows: 4,
+					type: 3,
+					userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
+				}
+			})
+			// console.log(res)
+			if (res.code === 200) {
+				this.hotelList_you = res.data.pageList
+
+				// 如果定位成功则获取和民宿之间的距离
+				if (this.showdDistance && this.hotelList_you.length) {
+					this.hotelList_you.forEach((ele) => {
+						let lat = ele.hpositionWens.split(',')[0]
+						let lng = ele.hpositionWens.split(',')[1]
+						ele.distance = this.calculateDistance(lat, lng)
+					})
+				}
+			}
+		},
+		// 获取民宿列表  精选
+		async getHotelList_jing() {
 			const res = await this.$myRequest({
 			const res = await this.$myRequest({
-				url: '/mhotel/ahphomePage.action',
+				url: '/mhotel/ahpselectedPage.action',
 				data: {
 				data: {
-					// queryValue: this.keywords,
 					page: this.page,
 					page: this.page,
 					rows: this.rows,
 					rows: this.rows,
 					type: 3,
 					type: 3,
-					// hotel_township: this.placeList[this.placeIndex].id || '',
 					userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
 					userId: uni.getStorageSync('userInfo') ? uni.getStorageSync('userInfo').id : ''
 				}
 				}
 			})
 			})
@@ -573,7 +601,6 @@ export default {
 						ele.distance = this.calculateDistance(lat, lng)
 						ele.distance = this.calculateDistance(lat, lng)
 					})
 					})
 				}
 				}
-				this.$refs.popup_sale.open()
 			}
 			}
 		},
 		},
 		handleOpen() {
 		handleOpen() {