hotelDetail.vue
9.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<template>
<div>
<div class="box">
<el-card class="mt30" v-loading="loading">
<el-row v-if="form" class="hotel" align="middle" :gutter="20">
<!-- <el-col :span="6">-->
<!-- <img class="w100" :src="fillImgUrl(form.photos?.split(',')[0])"/>-->
<!-- </el-col>-->
<el-col :span="16">
<h3 class="esp flex">{{ form?.name }}
<div class="starBox">
<img v-for="i in Number(form?.starLevel||0)" src="@/assets/booking/star.png">
</div>
</h3>
<div class="tagbox">
<span v-for="(t,index) in form?.label?.split(',')" v-show="index<4">{{ t }}</span>
<a v-show="form?.label?.split(',').length>4">{{ language == 0 ? '更多' : 'MORE' }} ></a>
</div>
<div>
<el-icon></el-icon>
<span class="mr10">{{ language == 0 ? '入住时间' : 'Check-in' }}:{{ form?.checkInTime }}</span>
<span>{{ language == 0 ? '离店时间' : 'Check-out' }}:{{ form?.checkOutTime }}</span>
</div>
<div v-if="form?.introduction" class="flex esp">
<el-icon></el-icon>
{{ language == 0 ? '酒店简介' : 'Introduction' }}:<span v-html="form.introduction.toString()"></span>
</div>
<!-- <p class="esp addr">-->
<!-- <el-icon size="16" style="position: relative;top: 2px" color="#929AA0"><LocationFilled /></el-icon>-->
<!-- {{form?.address}}-->
<!-- </p>-->
</el-col>
<el-col :span="8" class="text-right">
<div class="mapBox">
<div id="map"></div>
</div>
</el-col>
</el-row>
<el-empty v-else :image="`/img/order_no.png`" :image-size="228" description=""/>
</el-card>
<div class="mt30">
<el-row :gutter="20">
<el-col v-for="(p,index) in form?.photos?.split(',')" :span="index==0?12:6">
<div class="imgbox hotelImg">
<img :src="fillImgUrl(p)">
</div>
</el-col>
</el-row>
</div>
<el-card class="mt30 mb60">
<div class="lineHead">
<ul>
<li>{{ language == 0 ? '房型选择' : 'Available Rooms' }}</li>
</ul>
</div>
<div>
<div v-for="(r,index) in roomList" :key="index" class="room">
<el-row :gutter="30" align="middle">
<el-col :span="4">
<div class="roomImg">
<img :src="fillImgUrl(r.photo?.split(',')[0])">
</div>
</el-col>
<el-col :span="14">
<h3 class="name">{{ r.roomType }}</h3>
<el-row :gutter="10">
<el-col :span="8">{{ r.area }}m²</el-col>
<el-col :span="8" v-show="r.windowFlag==1"> {{ language==0?'有窗':'With windows' }}</el-col>
<el-col :span="8" v-show="r.windowFlag==0"> {{ language==0?'无窗':'Windowless' }}</el-col>
<el-col :span="8" v-show="r.bathroomFlag==1"> {{ language==0?'热水洗浴':'Shower' }}</el-col>
<!-- <text v-show="r.bathroomFlag==0"> </text> -->
<el-col :span="8" v-show="r.addBedFlag==1"> {{ language==0?'允许加床':'Extra bed' }} </el-col>
<el-col :span="8" v-if="r.breakfastNum&&r.breakfastNum > '0'">
{{ r.breakfastNum }}{{ language==0?'份早餐':' breakfasts' }}
</el-col>
<el-col :span="8" v-else>{{ language==0?'无早餐':'No breakfast' }}</el-col>
</el-row>
</el-col>
<el-col :span="3">
<div class="price">{{ language==0?'¥':'€' }}<span>{{language==0?r.roomPrice:r.roomPriceEn}}</span></div>
</el-col>
<el-col :span="3">
<div class="bg-lineg" v-if="language==0" @click="goOrder(r)">
订
<div>{{ language==0?'在线付':'Online' }}</div>
</div>
<el-button v-else class="btn-lineG w100" round type="primary" @click="goOrder(r)">Select</el-button>
<div class="text-center text-primary mt10 fontsize14 pointer" v-if="language == 0">
剩余 {{(r.roomCount - (r.useCount||0)).toFixed()}} 间
</div>
<div class="text-center text-primary mt10 fontsize14" v-else>
{{(r.roomCount - (r.useCount||0)).toFixed()}} Remaining rooms
</div>
</el-col>
</el-row>
</div>
<el-empty v-if="roomList.length == 0" :image="`/img/order_no.png`" :image-size="228" description=""/>
</div>
</el-card>
</div>
</div>
</template>
<script setup lang="ts">
import {useRouter} from "vue-router";
import {ref, reactive, onMounted} from "vue";
import {useRoute} from "vue-router";
import {getHotelById, getHotelRooms} from "@/apiPc/booking"
import {useStorage} from "@vueuse/core/index";
import useUserStore from "@/store/modules/user";
const user = useUserStore().user
const language = useStorage('language', 0)
const router = useRouter()
const route = useRoute()
const form = ref({})
const query = ref({
hotelId: route.query.id
})
const loading = ref(false)
const roomList = ref([])
const map = ref(null)
onMounted(() => {
getData()
})
function getData() {
loading.value = true
getHotelById(route.params.hotelId).then(res => {
loading.value = false
form.value = res.data
initMap()
}).catch(err => {
console.log(err)
})
query.value.hotelId = route.query.id
getHotelRooms(query.value).then(res => {
roomList.value = res.rows
})
}
function initMap() {
const TMap = (window as any).TMap
var center = new TMap.LatLng(form.value.latitude, form.value.longitude);//设置中心点坐标'
var map = new TMap.Map("map", {
center: center,//设置地图中心点坐标
zoom: 17, //设置地图缩放级别
});
var infoWindowLocation = new TMap.LatLng(form.value.latitude, form.value.longitude);//创建一个坐标
//创建InfoWindow实例,并进行初始化
var infowindow = new TMap.InfoWindow({
content: form.value.address, //信息窗口内容
position: infoWindowLocation,//显示信息窗口的坐标
map: map,
offset: {x: 0, y: -32}
});
infowindow.close();
var marker = new TMap.MultiMarker({
map: map,
//样式定义
styles: {
"myStyle": new TMap.MarkerStyle({
"anchor": {x: 16, y: 32}
})
},
//点标记数据数组
geometries: [{
"id": "1", //点标记唯一标识,后续如果有删除、修改位置等操作,都需要此id
// "styleId": 'myStyle', //指定样式id
"position": new TMap.LatLng(form.value.latitude, form.value.longitude), //点标记坐标位置
"properties": {//自定义属性
"title": form.value.name
}
}
]
})
marker.on("click", function (evt) {
//设置infoWindow
infowindow.open(); //打开信息窗
infowindow.setPosition(evt.geometry.position);//设置信息窗位置
})
}
function goOrder(room) {
if(!user){
useUserStore().setReLogin()
return
}
router.push({
name:'hotelOrder',
params:{
roomId:room.id
},
query:{
room:encodeURIComponent(JSON.stringify(room)),
hotelName:form.value.name,
checkInTime:form.value.checkInTime
}
})
}
</script>
<style scoped lang="scss">
.room {
background: #FAFBFD;margin: 20px 0 0;padding: 20px;
border: 1px solid #E5E5E5;
.name{font-size: 20px;margin: 0 0 10px;}
.roomImg{aspect-ratio: 16/9;border-radius: 10px;overflow: hidden;
img{width: 100%;object-fit: cover;object-position: center;height: 100%;}
}
.price{color: #FF8124;font-size: 24px;
span{font-size: 36px;font-family: "DIN Alternate"}
}
.bg-lineg{margin: auto;border-radius: 10px;text-align: center;padding: 7px 2px 2px;
font-size: 24px;width:66px;cursor: pointer;
div{background: #fff;font-size: 13px;border-radius: 20px;padding: 0 10px;
color: #453DEA;font-weight: 500;}
}
}
.hotel {
h3 {
margin: 0 0 20px;
}
img.w100 {
object-fit: cover;
aspect-ratio: 16/9
}
.addr {
font-size: 16px;
color: #929AA0;
font-weight: 400;
}
.price {
margin: 0 0 25px;
color: #FF8124;
font-size: 18px;
span {
font-size: 24px;
margin: 0 8px;
font-family: 'DINAlternate-Bold';
font-weight: 600;
}
i {
font-style: normal;
color: #929AA0;
}
}
}
.starBox {
img {
display: inline-block;
margin-right: 4px
}
}
.tagbox {
margin: 15px 0;
a {
color: #AFB5B9;
font-size: 12px;
}
span {
border-radius: 13px;
font-size: 12px;
padding: 4px 10px;
margin-right: 10px;
font-weight: 400;
}
span:nth-child(4n) {
background: rgba(50, 177, 108, 0.2);
color: rgba(50, 177, 108, 1);
}
span:nth-child(4n+1) {
background: rgba(243, 152, 0, 0.2);
color: rgba(243, 152, 0, 1);
}
span:nth-child(4n+2) {
background: rgba(0, 160, 233, 0.2);
color: rgba(0, 160, 233, 1);
}
span:nth-child(4n+3) {
background: rgba(247, 64, 166, 0.2);
color: rgba(247, 64, 166, 1);
}
}
.mapBox {
position: relative;
overflow: hidden;
height: 200px;
#map {
position: relative;
left: -70px;
width: calc(100% + 160px);
}
}
.hotelImg{border-radius: 10px;overflow: hidden;aspect-ratio: 16/9;
img{object-fit: cover;object-position: center;width: 100%;height: 100%;
}
}
</style>