123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872 |
- <template>
- <view class="hotelList">
- <view class="fixed-box">
- <view class="search-box">
- <view class="city-box">
- <image class="icon" src="../static/blue-position.png" mode=""></image>
- {{query.cityName}}
- </view>
- <view class="input-box">
- <view class="time-box" @click="show = true">
- <view class="time">
- <view class="label">
- 住
- </view>
- <view class="value">
- {{query.checkInDate | filterDate('time')}}
- </view>
- </view>
- <view class="time">
- <view class="label">
- 离
- </view>
- <view class="value">
- {{query.checkOutDate | filterDate('time')}}
- </view>
- </view>
- </view>
- <input class="input" type="text" v-model="query.keyword" placeholder="搜索酒店名/地名/关键词" />
- </view>
- </view>
- <view class="tab-box">
- <view class="tab-item" :class="[query.sortKey?'active':'']" @click="handleTab(0)">
- 推荐排序
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- <view class="tab-item" :class="[query.filter.star.length||query.filter.price.length?'active':'']" @click="handleTab(1)">
- 档次价格
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- <view class="tab-item" :class="[query.filter.poiCode?'active':'']" @click="handleTab(2)">
- 位置距离
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- <view class="tab-item" @click="handleTab(3)">
- 综合筛选
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- </view>
- </view>
-
-
- <!-- 列表 -->
- <zs-list class="store-box" mt="150rpx" @load="loadMore" :status="status">
- <view class="hotel-item" v-for="(item,index) in list" :key="index" @click="goDetail(item.hotelId)">
- <zs-img :src="item.picture" width="190rpx" height="296rpx" radius="full" mode="widthFix" ></zs-img>
- <view class="info">
- <view class="title">
- {{item.chineseName}}
- <!-- <view :class="[getTag(item.star).tag]">
- {{item.starName}}
- </view> -->
- </view>
- <image class="star" v-for="(i,d) in getTag(item.star).num" :key="d" src="../static/star.png" mode=""></image>
- <view class="district">
- <!-- 观山湖区 -->
- </view>
- <view class="distance-box">
- <view class="distance">
- 距你{{item|filterDistance}}公里
- </view>
- <view class="price-box" v-if="item.price">
- <view class="price">
- ¥{{item.price}}
- </view>
- <view class="label">
- 起
- </view>
- </view>
- <view class="price-box" v-else>
- <view class="label">
- 暂无报价
- </view>
-
- </view>
- </view>
- </view>
-
- </view>
- </zs-list>
-
-
- <u-popup :show="show1" :round="16" mode="top" :closeOnClickOverlay="false" @close="show1 = false">
- <view class="content">
- <view class="search-box">
- <view class="city-box">
- <image class="icon" src="../static/blue-position.png" mode=""></image>
- {{query.cityName}}
- </view>
- <view class="input-box">
- <view class="time-box" @click="show = true">
- <view class="time">
- <view class="label">
- 住
- </view>
- <view class="value">
- {{query.checkInDate | filterDate('time')}}
- </view>
- </view>
- <view class="time">
- <view class="label">
- 离
- </view>
- <view class="value">
- {{query.checkOutDate | filterDate('time')}}
- </view>
- </view>
- </view>
- <input class="input" type="text" v-model="query.keyword" placeholder="搜索酒店名/地名/关键词" />
- </view>
- </view>
- <view class="tab-box">
- <view class="tab-item" :class="[active == 0?'active':'']" @click="handleTab(0)">
- {{currentLabel}}
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- <view class="tab-item" :class="[active == 1?'active':'']" @click="handleTab(1)">
- 档次价格
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- <view class="tab-item" :class="[active == 2?'active':'']" @click="handleTab(2)">
- 位置距离
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- <view class="tab-item" :class="[active == 3?'active':'']" @click="handleTab(3)">
- 综合筛选
- <image class="icon" src="@/static/shop-desc.png" mode=""></image>
- </view>
- </view>
-
-
- <view class="choose-box">
- <view class="radio-box" v-if="active == 0">
- <view class="radio" v-for="item in sortList" :key="item.value" @click="chooseTab(item.value,0,item.label)">
- <view class="label">
- {{item.label}}
- </view>
- <view class="value" v-if="query.sortKey == item.value">
- √
- </view>
- </view>
- </view>
- <template v-else-if="active == 1">
-
- <view class="sub-title">
- 星级(可多选)
- </view>
- <view class="tab-box">
- <view class="tab" :class="[index%4!=0?'ml20':'',query.filter.star.indexOf(item.id) != -1?'active':'']" v-for="(item,index) in starList" :key="item.id" @click="chooseTab(item,1)">
- {{item.label}}
- </view>
- </view>
- <view class="sub-title mb28">
- 价格区间 <text class="price-range">{{`¥${priceValue[0]}~¥${priceValue[1]}`}}</text>
- </view>
- <zs-slider class="zs-slider" ref="slider" v-model="priceValue" :min="0" :max="2500" :step="10" :blockWidth="40" @end="moveEnd" />
- <view class="price-tab-box">
- <view class="price-tab" :class="[index%4!=0?'ml20':'',item.max == curPrice?'active':'']" v-for="(item,index) in priceList" :key="index" @click="choosePrice(item)">
- ¥{{item.min}}{{ item.max == 2500?'以上': '-'+item.max}}
- </view>
- </view>
- </template>
- <view class="radio-box" v-else-if="active == 2">
- <view class="radio" v-for="item in areaList" :key="item.code" @click="chooseTab(item,2)">
- <view class="label">
- {{item.name}}
- </view>
- <view class="value" v-if="query.filter.poiCode == item.code">
- √
- </view>
- </view>
- </view>
- <view class="filter-box" v-else-if="active == 3">
- <view class="left-box">
- <view class="left-item" :class="[filterIndex == index?'active':'']" v-for="(item,index) in filterObj" :key="index" @click="chooseType(index)">
- {{item.filterName}}
- </view>
- </view>
- <view class="right-box" >
- <view class="right-item" v-for="(item,index) in filterObj[filterIndex].pros" :key="index" @click="chooseItem(item)">
- <view class="label">
- {{item.name}}
- </view>
- <view class="value" v-if="query.filter[filterObj[filterIndex].filterId].indexOf(item.code)!=-1">
- √
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <view class="btn-box">
- <view class="btn" type="default" @click="reset">重置</view>
- <view class="btn" type="default" @click="submit">完成</view>
- </view>
- </u-popup>
-
- <u-calendar
- startText="住店"
- endText="离店"
- :monthNum="5"
- confirmDisabledText="请选择离店日期"
- :show="show"
- mode="range"
- @confirm="confirm"
- @close="show = false"
- ref="calendar"
- :rowHeight="100"
- closeOnClickOverlay
- color="#EE4320"
- >
- </u-calendar>
-
-
- </view>
- </template>
- <script>
- import {getHotelList} from '@/api/hotel.js';
- import {debounce} from '@/utils/tool.js'
- export default {
- data() {
- return {
- day:1,
- active:0,
- show:false,
- show1:false,
- list: [],
- status:'more',
- 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('市',''),
- "filter": {
- "brand":[],
- "facility":[],
- "feature":[],
- "star":[],
- "price":[10, 2000],
- "poiKey": "",
- "poiCode": "",
- "latitude": '',
- "longitude": '',
- },
- "keyword": "",
- "limit": 10,
- "returnFilter": 1,
- "sortKey": "recommend",
- "start": 0
- },
- districtList:JSON.parse(uni.getStorageSync('districtList')),
- currentLabel:'推荐排序',
- sortList:[
- {
- value:'recommend',
- label:'推荐排序'
- },
- {
- value:'satisfaction',
- label:'口碑'
- },
- {
- value:'price-asc',
- label:'起价升序'
- },
- {
- value:'price-desc',
- label:'起价降序'
- }
- ],
- priceValue: [10, 2000], // 可以指定默认值
- starList:[
- // {
- // id:1,
- // label:'一星级',
- // data:[1,0]
- // },
- {
- id:2,
- // label:'二星级',
- // data:[2,6]
- label:'二星级及以下',
- data:[1,0,2,6]
- },
- {
- id:3,
- label:'三星级',
- data:[3,7]
- },
- {
- id:4,
- label:'四星级',
- data:[4,8]
- },
- {
- id:5,
- label:'五星级',
- data:[5,9]
- },
- // {
- // id:6,
- // label:'经济型'
- // },
- // {
- // id:7,
- // label:'舒适型'
- // },
- // {
- // id:8,
- // label:'高档型'
- // },
- // {
- // id:9,
- // label:'豪华型'
- // },
- // {
- // id:0,
- // label:'普通型'
- // }
- ],
- curPrice:'',
- priceList:[
- {
- min:0,
- max:250
- },
- {
- min:250,
- max:400
- },
- {
- min:400,
- max:650
- },
- {
- min:650,
- max:900
- },
- {
- min:900,
- max:2500
- }
- ],
- areaList:[],//存放行政区信息
- filterObj:{},//综合筛选
- filterIndex:0,
- location:{
- latitude:0,
- longitude:0,
- }
- }
- },
- filters: {
- filterDate: function(value,type) {
- let timestamp = new Date(value).getTime()
- if(type == 'time'){
- return uni.$u.timeFormat(timestamp, 'mm-dd');
- }else if(type == 'day'){
- let arr = ['日','一','二','三','四','五','六']
- let num = new Date(timestamp).getDay()
- return `周${arr[num]}`
- }
- },
- filterDistance: function(item) {
- let location = JSON.parse(uni.getStorageSync('location'))
- /*参数:两地的经纬度数值*/
- var radLat1 = location.latitude * Math.PI / 180.0;
- var radLat2 = item.latitude* Math.PI / 180.0;
- var a = radLat1 - radLat2;
- var b = location.longitude* Math.PI / 180.0 - item.longitude* Math.PI / 180.0;
- var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) +
- Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
- s = s * 6378137.0;//地球半径 单位米;
- s = Math.round(s * 10000) / 10000 /1000 //输出为千米
- s = s.toFixed(2)
- return s
-
- }
- },
- watch: {
- 'query.keyword':debounce(function(val) {
- this.search()
- })
- },
- methods: {
- chooseType(index){
- this.filterIndex = index
- },
- chooseItem(item){
- let key = this.filterObj[this.filterIndex].filterId
- let index = this.query.filter[key].indexOf(item.code)
- if(index!=-1){
- this.query.filter[key].splice(index,1)
- }else{
- this.query.filter[key].push(item.code)
- }
-
- },
- getTag(star){
- if(star == 0 ||star == 1){
- return {tag:'tag1',num:1}
- }else if(star == 2 ||star == 6){
- return {tag:'tag2',num:2}
- }if(star == 3 ||star == 7){
- return {tag:'tag2',num:3}
- }if(star == 4 ||star == 8){
- return {tag:'tag3',num:4}
- }if(star == 5 ||star == 9){
- return {tag:'tag3',num:5}
- }
- },
- moveEnd(){
- console.log('结束');
- this.query.filter.price = [this.priceValue[0]+'-'+this.priceValue[1]]
- // this.search()
- },
- reset(){
- this.query.sortKey = "recommend"
- this.query.filter.brand = []
- this.query.filter.facility = []
- this.query.filter.feature = []
- this.query.filter.star = []
- this.query.filter.price = []
- this.query.filter.poiCode = ''
- this.query.filter.poiKey = ""
- this.query.filter.latitude = this.location.latitude
- this.query.filter.longitude = this.location.longitude
- this.curPrice = ''
- // this.search()
- this.$refs.slider.updateValue(10, 2000)
-
- },
- submit(){
- this.search()
- this.show1 = false
- },
- chooseTab(val,type,label){
- if(type == 0){
- this.query.sortKey = val
- this.currentLabel = label
- }else if(type == 1){
- // 星级筛选
- if(this.query.filter.star.indexOf(val.data[0]) != -1){
- val.data.map(item=>{
- let index = this.query.filter.star.indexOf(item)
- this.query.filter.star.splice(index,1)
- })
- }else{
- this.query.filter.star = this.query.filter.star.concat(val.data)
- }
- }else if(type == 2){
- this.query.filter.poiKey = "DISTRICT"
- this.query.filter.poiCode = val.code
- this.query.filter.latitude = val.latitude
- this.query.filter.longitude = val.longitude
- }
- // this.search()
- },
- choosePrice(item){
- this.curPrice = item.max
- this.query.filter.price = [`${item.min}-${item.max}`]
- this.$refs.slider.updateValue(item.min, item.max)
- // this.search()
- },
- close(){},
- search(){
- this.query.start = 0
- this.list = []
- this.getHotelList()
- },
- confirm(e) {
- console.log(e);
- this.show = false
- if(e){
- console.log(this);
- this.day = e.length - 1
- this.query.checkInDate = e[0]
- this.query.checkOutDate = e[this.day]
- this.search()
- }
-
- },
- loadMore() {
- this.getHotelList()
- },
- jump(url){
- uni.navigateTo({
- url
- })
- },
- handleTab(val){
- this.show1 = true
- this.active = val
- },
- goDetail(id) {
- uni.navigateTo({
- url:`/hotel/hotelDetail?id=${id}&checkInDate=${this.query.checkInDate}&checkOutDate=${this.query.checkOutDate}&day=${this.day}`
- })
- },
- getHotelList(){
- if(this.status == 'loading') return
- this.status = 'loading'
- let query = JSON.parse(JSON.stringify(this.query))
- query.start = query.start*query.limit
- getHotelList(query).then(res=>{
- if(res.state == 'Success'){
- this.list = this.list.concat(res.content.data.hotelList)
- if(!this.areaList.length){
- let filterList = res.content.data.filter
- filterList.map((item,index)=>{
- if(item.filterName == '位置'){
- this.areaList = item.pros[0].filter
- filterList.splice(index,1)
- // item.pros.splice(0,1)
- }
- })
- this.filterObj = filterList
- console.log(2222222,this.filterObj);
- }else{
- this.query.returnFilter = 0
- }
- if((this.list.length) >= res.content.data.count){
- this.status = 'noMore'
- }else{
- this.status = 'more'
- this.query.start++
- }
- }
- }).catch(()=>{
- this.status = 'more'
- })
- }
- },
- onLoad(options) {
- this.location = JSON.parse(uni.getStorageSync('location'))
- this.query.keyword = options.key
- this.query.checkInDate = options.checkInDate
- this.query.checkOutDate = options.checkOutDate
- this.query.filter.latitude = this.location.latitude
- this.query.filter.longitude = this.location.longitude
- this.day = options.day
- this.getHotelList()
- }
- }
- </script>
- <style lang="scss" >
- .hotelList{
- padding: 0 24rpx;
- .fixed-box{
- position: fixed;
- top: 0%;
- left: 0%;
- z-index: 2;
- width: 100%;
- background: #fff;
-
- }
-
- .search-box{
- display: flex;
- align-items: center;
- padding: 0 24rpx;
- .city-box{
- display: flex;
- align-items: center;
- font-weight: 600;
- font-size: 28rpx;
- color: #222222;
- .icon{
- width: 30rpx;
- height: 30rpx;
- }
- }
- .input-box{
- width: 590rpx;
- height: 72rpx;
- background: #F6F6F6;
- border-radius: 32rpx;
- margin-left: 20rpx;
- padding: 0 20rpx;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- .time-box{
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- .time{
- display: flex;
- align-items: center;
- .label{
- font-size: 22rpx;
- color: #AAAAAA;
- }
- .value{
- font-size: 22rpx;
- color: #222222;
- padding-left: 10rpx;
- }
- }
- }
- .input{
- flex: 1;
- margin-left: 20rpx;
- font-size: 24rpx;
- color: #AAAAAA;
- }
- }
- }
- .tab-box{
- display: flex;
- align-items: center;
- padding: 20rpx 0;
- max-height: 800rpx;
- overflow: auto;
- .tab-item{
- flex: 1;
- display: flex;
- align-items: center;
- justify-content: center;
- font-size: 26rpx;
- .icon{
- width: 32rpx;
- height: 32rpx;
- }
- }
- .tab-item.active{
- color: #FF4D3A;
- }
- }
-
- .radio-box{
- max-height: 800rpx;
- overflow: auto;
- .radio{
- padding: 20rpx 0;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .label{
- font-size: 26rpx;
- color: #222222;
- }
- .value{
- color: #FF4D3A;
- }
- }
- }
-
- .filter-box{
- display: flex;
-
- .left-box{
- flex: 0 0 156rpx;
- height: 500rpx;
- overflow: auto;
- background: #F0F0F0;
- .left-item{
- line-height: 90rpx;
- text-indent: 24rpx;
- }
- .left-item.active{
- color: #EE4320;
- font-weight: bold;
- background: #fff;
- }
- }
-
- .right-box{
- flex: 1;
- height: 500rpx;
- overflow: auto;
- background: #fff;
- padding: 0 20rpx;
- .right-item{
- display: flex;
- justify-content: space-between;
- align-items: center;
- height: 90rpx;
- box-sizing: border-box;
- border-bottom:1rpx solid #F0F0F0;
- .label{
- font-size: 26rpx;
- color: #222222;
- }
- .value{
- color: #FF4D3A;
- }
- }
- }
-
- }
-
- .zs-list {
- margin-top: 20rpx;
- .hotel-item.disable{
- filter: grayscale(1);
- }
- .hotel-item {
- display: flex;
- align-items: center;
- background: #fff;
- border-bottom: 1rpx solid #F0F0F0;
- padding: 14rpx 0;
- .info{
- padding-left: 20rpx;
- flex: 1;
- .title{
- font-weight: 600;
- font-size: 32rpx;
- color: #222222;
- line-height: 50rpx;
- // width: 300rpx;
- // white-space: nowrap;
- // overflow: hidden;
- // text-overflow: ellipsis;
- // margin-top: 20rpx;
- }
- .district{
- display: flex;
- align-items: center;
- font-size: 24rpx;
- color: #AAAAAA;
- margin-top: 20rpx;
-
- }
- .star{
- width: 21rpx;
- height: 17rpx;
- margin-left: 3rpx;
- }
- .distance-box{
- display: flex;
- align-items: center;
- justify-content: space-between;
- .distance{
- font-size: 24rpx;
- color: #AAAAAA;
- margin-top: 20rpx;
- }
- .price-box{
- display: flex;
- align-items: center;
- .price{
- font-weight: 600;
- font-size: 36rpx;
- color: #FF4D3A;
- }
- .label{
- font-size: 24rpx;
- color: #AAAAAA;
- }
- }
- }
- }
- }
- }
-
- .content{
- padding: 20rpx 0;
- .choose-box{
- .tab-box{
- display: flex;
- flex-wrap: wrap;
- .tab{
- width: 160rpx;
- height: 52rpx;
- line-height: 52rpx;
- text-align: center;
- background: #F0F0F0;
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- font-size: 28rpx;
- color: #AAAAAA;
- box-sizing: border-box;
- margin-top: 20rpx;
- }
- .tab.active{
- background: #fff;
- border: 2rpx solid #EE4320;
- color: #EE4320;
- }
- }
- .price-tab-box{
- display: flex;
- flex-wrap: wrap;
- padding-top: 20rpx;
- .price-tab{
- width: 160rpx;
- height: 52rpx;
- line-height: 52rpx;
- text-align: center;
- background: #F0F0F0;
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- font-size: 28rpx;
- color: #AAAAAA;
- box-sizing: border-box;
- margin-top: 20rpx;
- }
-
- .price-tab.active{
- background: #fff;
- border: 2rpx solid #EE4320;
- color: #EE4320;
- }
- }
- }
-
- .sub-title{
- font-size: 28rpx;
- font-weight: bold;
- // margin: 20rpx 0;
- .price-range{
- font-weight: 300;
- font-size: 28rpx;
- color: #EE4320;
- }
- }
- .mb28{
- margin-bottom: 28rpx!important;
- }
-
- .mt60{
- margin-top: 60rpx!important;
- }
-
- .zs-slider{
- width: 92%;
- // margin-bottom: 60rpx;
- }
- }
-
- .ml20{
- margin-left: 20rpx;
- }
-
- .btn-box{
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 20rpx 0;
- .btn{
- width: 200rpx;
- height: 70rpx;
- line-height: 70rpx;
- text-align: center;
- border-radius: 35rpx;
- background: #F0F0F0;
- font-size: 28rpx;
- color: #AAAAAA;
- }
- .btn+.btn{
- background: #EE4320;
- color: #fff;
- margin-left: 20rpx;
- }
- }
- .u-safe-bottom{
- display: none!important;
- }
- }
- </style>
|