Ver código fonte

添加城市选择

wenjie 9 meses atrás
pai
commit
935ad68f61
4 arquivos alterados com 136 adições e 44 exclusões
  1. 20 5
      hotel/cityList.vue
  2. 36 20
      hotel/index.vue
  3. 9 4
      hotel/search.vue
  4. 71 15
      pages/index/index.vue

+ 20 - 5
hotel/cityList.vue

@@ -19,15 +19,26 @@
 			return {
 				value:'',
 				list:[],
-				status:'more'
+				status:'more',
+				backUrl:'',
+				checkInDate:'',
+				checkOutDate:'',
+				key:''
 			}
 		},
 		methods: {
 			handleCity(name){
 				let city = name.replace('市','')
-				uni.navigateTo({
-					url:'/hotel/index?cityName='+city
-				})
+				if(this.backUrl){
+					uni.navigateTo({
+						url:`${this.backUrl}?cityName=${city}&key=${this.key}&checkInDate=${this.checkInDate}&checkOutDate=${this.checkOutDate}`
+					})
+				}else{
+					uni.navigateTo({
+						url:'/hotel/index?cityName='+city
+					})
+				}
+				
 			},
 			getCityList() {
 				this.status = 'loading'
@@ -39,7 +50,11 @@
 				})
 			}
 		},
-		onLoad() {
+		onLoad(options) {
+			this.backUrl = options.backUrl
+			this.checkInDate=options.checkInDate,
+			this.checkOutDate=options.checkOutDate,
+			this.key=options.key
 			this.getCityList()
 		}
 	}

+ 36 - 20
hotel/index.vue

@@ -5,10 +5,12 @@
 	
 	<view class="search-box">
 		<view class="address-box">
-			<view class="address" @click="jump('./cityList')">
-				{{address}}
+			<view class="box">
+				<view class="address" @click="jump('./cityList')">
+					{{city||address}}
+				</view>
+				<image class="more" src="@/static/right.png" mode=""></image>
 			</view>
-			<image class="more" src="@/static/right.png" mode=""></image>
 			<view class="nearby" @click="handleSearch(1)">
 				当前位置
 			</view>
@@ -164,6 +166,7 @@
 	export default {
 		data() {
 			return {
+				city:'',
 				address:'',
 				list:[],
 				list1:[],
@@ -226,8 +229,8 @@
 							type: 'gcj02',
 							success: (res) => {
 								// 解析地址
-								that.query['location.lat'] = res.latitude
-								that.query['location.lon'] = res.longitude
+								// that.query['location.lat'] = res.latitude
+								// that.query['location.lon'] = res.longitude
 								// 存储经纬度
 								uni.setStorageSync('location',JSON.stringify({latitude:res.latitude,longitude:res.longitude}))
 								qqmapsdk.reverseGeocoder({
@@ -254,7 +257,7 @@
 			},
 			handleSearch(type){
 				uni.navigateTo({
-					url:`./search?key=${this.query.keyword}&checkInDate=${this.query.checkInDate}&checkOutDate=${this.query.checkOutDate}&day=${this.day}&isNear=${type}`
+					url:`./search?key=${this.query.keyword}&checkInDate=${this.query.checkInDate}&checkOutDate=${this.query.checkOutDate}&day=${this.day}&isNear=${type}&cityName=${this.city}`
 				})
 			},
 			confirm(e) {
@@ -281,6 +284,9 @@
 				this.status = 'loading'
 				let query = JSON.parse(JSON.stringify(this.query))
 				query.start = query.start*query.limit
+				if(this.city){
+					query.cityName = this.city
+				}
 				getHotelList(query).then(res=>{
 					if(res.state == 'Success'){
 						let list = []
@@ -311,8 +317,13 @@
 					this.background = false
 				}
 		},
-		onLoad() {
-			this.getCity()
+		onLoad(options) {
+			if(options.cityName){
+				this.city = options.cityName
+			}else{
+				this.getCity()
+			}
+			
 			
 		}
 	}
@@ -339,19 +350,24 @@
 			display: flex;
 			align-items: center;
 			padding-bottom: 30rpx;
-			.address{
+			.box{
 				flex: 1;
-				font-weight: 600;
-				font-size: 32rpx;
-				color: #222222;
-				white-space: nowrap;
-				overflow: hidden;
-				text-overflow: ellipsis;
-			}
-			.more{
-				width: 48rpx;
-				height: 48rpx;
-				margin: 0 16rpx;
+				display: flex;
+				align-items: center;
+				.address{
+					max-width: 400rpx;
+					font-weight: 600;
+					font-size: 32rpx;
+					color: #222222;
+					white-space: nowrap;
+					overflow: hidden;
+					text-overflow: ellipsis;
+				}
+				.more{
+					width: 48rpx;
+					height: 48rpx;
+					margin: 0 16rpx;
+				}
 			}
 			.nearby{
 				font-weight: 300;

+ 9 - 4
hotel/search.vue

@@ -2,7 +2,7 @@
 	<view class="hotelList">
 		<view class="fixed-box">
 			<view class="search-box">
-				<view class="city-box">
+				<view class="city-box" @click="chooseCity">
 					<image class="icon" src="../static/blue-position.png" mode=""></image>
 					{{query.cityName}}
 				</view>
@@ -250,11 +250,12 @@
 				show1:false,
 				list: [],
 				status:'more',
+				city:'',
 				query:{
 				  "checkInDate":uni.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd') ,
 				  "checkOutDate":uni.$u.timeFormat(new Date().getTime()+1000*60*60*24, 'yyyy-mm-dd'),
 				  "cityCode": 0,
-				  "cityName": uni.getStorageSync('city').replace('市',''),
+				  "cityName": '',
 				  "filter": {
 					  "brand":[],
 					  "facility":[],
@@ -464,6 +465,8 @@
 				this.query.filter.price = []
 				this.query.filter.poiCode = ''
 				this.query.filter.poiKey =  ""
+				this.query.filter.latitude = ""
+				this.query.filter.longitude = ""
 				// this.query.filter.latitude = this.location.latitude
 				// this.query.filter.longitude = this.location.longitude
 				this.curPrice = ''
@@ -524,9 +527,9 @@
 			loadMore() {
 				this.getHotelList()
 			},
-			jump(url){
+			chooseCity(){
 				uni.navigateTo({
-					url
+					url:`/hotel/cityList?backUrl=/hotel/search&key=${this.query.keyword}&checkInDate=${this.query.checkInDate}&checkOutDate=${this.query.checkOutDate}`
 				})
 			},
 			handleTab(val){
@@ -576,6 +579,8 @@
 			}
 		},
 		onLoad(options) {
+			this.query.cityName = options.cityName || uni.getStorageSync('city').replace('市','')
+			
 			this.location = JSON.parse(uni.getStorageSync('location'))
 			this.query.keyword = options.key
 			this.query.checkInDate = options.checkInDate

+ 71 - 15
pages/index/index.vue

@@ -60,9 +60,9 @@
 								<!-- <zs-img :src="item.goodsVos[0].goodsImg" width="344rpx" height="344rpx" mode=""></zs-img> -->
 								<view class="info">
 									<view class="title">
-										<view class="tag">
+										<!-- <view class="tag">
 											今日特惠
-										</view>
+										</view> -->
 										<view class="text">
 											{{item.title}}
 										</view>
@@ -70,16 +70,19 @@
 									<!-- <view class="desc">
 										{{item.goodsVos[0].goodsDescribe}}
 									</view> -->
-									<view class="discount-tag" v-if="item.salePrice&&item.originalPrice">
+								<!-- 	<view class="discount-tag" v-if="item.salePrice&&item.originalPrice">
 										{{(item.salePrice/item.originalPrice)*10}}
-									</view>
+									</view> -->
 									<view class="price-box">
 										<view class="left">
 											<view class="price" v-if="item.salePrice">
-											¥{{item.salePrice}}
+											¥{{(item.salePrice/100).toFixed(2)}}
 											</view>
+								<!-- 			<view class="label" v-if="item.productType!='Shop'&&item.productType!='ShopGoods'&&item.productType!='ShopService'&&item.productType!='PetrolStation'">
+												起
+											</view> -->
 											<view class="old-price" v-if="item.originalPrice">
-											¥{{item.originalPrice}}
+											¥{{(item.originalPrice/100).toFixed(2)}}
 											</view>
 										</view>
 										
@@ -87,6 +90,15 @@
 											销量{{item.salesCount}}
 										</view>
 									</view>
+									
+									<view class="address-box">
+										<view class="address">
+											{{item.address || ''}}
+										</view>
+										<view class="distance">
+											{{item.distance | filterDis}}
+										</view>
+									</view>
 								</view>
 							</view>
 							
@@ -103,27 +115,29 @@
 								<zs-img :src="item.cover[0]" width="344rpx" height="344rpx" mode=""></zs-img>
 								<view class="info">
 									<view class="title">
-										<view class="tag">
+									<!-- 	<view class="tag">
 											今日特惠
-										</view>
+										</view> -->
 										<view class="text">
 											{{item.title}}
 										</view>
 									</view>
-									<view class="discount-tag">
-										<!-- {{(item.salePrice/item.originalPrice)*10}} -->
-										4.5折
-									</view>
+									<!-- <view class="discount-tag">
+										{{(item.salePrice/item.originalPrice)*10}}
+									</view> -->
 									<!-- <view class="desc">
 										{{item.goodsVos[0].goodsDescribe}}
 									</view> -->
 									<view class="price-box">
 										<view class="left">
 										<view class="price" v-if="item.salePrice">
-											¥{{item.salePrice}}
+											¥{{(item.salePrice/100).toFixed(2)}}
 											</view>
+									<!-- 		<view class="label" v-if="item.productType!='Shop'&&item.productType!='ShopGoods'&&item.productType!='ShopService'&&item.productType!='PetrolStation'">
+												起
+											</view> -->
 											<view class="old-price" v-if="item.originalPrice">
-											¥{{item.originalPrice}}
+											¥{{(item.originalPrice/100).toFixed(2)}}
 											</view>
 										</view>
 										
@@ -131,6 +145,15 @@
 											销量{{item.salesCount}}
 										</view>
 									</view>
+									
+									<view class="address-box">
+										<view class="address">
+											{{item.address || ''}}
+										</view>
+										<view class="distance">
+											{{item.distance |filterDis}}
+										</view>
+									</view>
 								</view>
 							</view>
 						</view>
@@ -194,7 +217,15 @@
 				
 			}
 		},
-		
+		filters: {
+			filterDis: function(value) {
+				if(value<1000){
+					return value +'m';
+				}else{
+					return (value/1000).toFixed(0)+'km'
+				}
+			}
+		},
 		methods: {
 			// swiper变动
 			swiperChange(val) {
@@ -821,6 +852,7 @@
 									color: $uni-color-primary;
 									font-weight: bold;
 								}
+								
 								.old-price{
 									font-size: 20rpx;
 									color: #AAAAAA;
@@ -834,6 +866,30 @@
 							}
 						}
 						
+						.address-box{
+							display: flex;
+							align-items: center;
+							justify-content: space-between;
+							font-size: 20rpx;
+							color: #AAAAAA;
+							margin-top: 15rpx;
+							.address{
+								width: 200rpx;
+								overflow: hidden;
+								text-overflow: ellipsis;
+								/* 弹性伸缩盒子模型显示 */
+								display: -webkit-box;
+								/* 限制在一个块元素显示的文本的行数 */
+								-webkit-line-clamp: 1;
+								/* 设置或检索伸缩盒对象的子元素的排列方式 */
+								-webkit-box-orient: vertical;
+								
+							}
+							.distance{
+								
+							}
+						}
+						
 					}
 				}
 			}