086b11ec by zhangmeng

酒店预订

1 parent 19257536
...@@ -59,7 +59,19 @@ ...@@ -59,7 +59,19 @@
59 <el-card class="mt30 mb60"> 59 <el-card class="mt30 mb60">
60 <div class="lineHead"> 60 <div class="lineHead">
61 <ul> 61 <ul>
62 <li>{{ language == 0 ? '房型选择' : 'Available Rooms' }}</li> 62 <li>
63 {{ language == 0 ? '房型选择' : 'Available Rooms' }}
64 <span style="margin-left: 100px">
65 <el-date-picker
66 @change="getDaysBetween"
67 v-model="hotTime"
68 type="daterange"
69 :disabled-date="disabledDateRZ"
70 :placeholder="language==0?'选择日期':'Select date'"
71 format="YYYY-MM-DD"
72 value-format="YYYY-MM-DD"/>
73 </span>
74 </li>
63 </ul> 75 </ul>
64 </div> 76 </div>
65 <div> 77 <div>
...@@ -89,11 +101,14 @@ ...@@ -89,11 +101,14 @@
89 <div class="price">{{ language==0?'¥':'€' }}<span>{{language==0?r.roomPrice:r.roomPriceEn}}</span></div> 101 <div class="price">{{ language==0?'¥':'€' }}<span>{{language==0?r.roomPrice:r.roomPriceEn}}</span></div>
90 </el-col> 102 </el-col>
91 <el-col :span="3"> 103 <el-col :span="3">
92 <div class="bg-lineg" v-if="language==0" @click="goOrder(r)"> 104 <el-link v-if="language==0" @click="goOrder(r)" :disabled="!r.useCount">
105 <div class="bg-lineg " :class="{'forbid':!r.useCount}" >
93 106
94 <div>{{ language==0?'在线付':'Online' }}</div> 107 <div>{{ language==0?'在线付':'Online' }}</div>
95 </div> 108 </div>
96 <el-button v-else class="btn-lineG w100" round type="primary" @click="goOrder(r)">Select</el-button> 109 </el-link>
110
111 <el-button v-else class="btn-lineG w100" round type="pri mary" @click="goOrder(r)">Select</el-button>
97 <!-- <div class="text-center text-primary mt10 fontsize14 pointer" v-if="language == 0">--> 112 <!-- <div class="text-center text-primary mt10 fontsize14 pointer" v-if="language == 0">-->
98 <!-- 剩余 {{(r.roomCount - (r.useCount||0)).toFixed()}} 间--> 113 <!-- 剩余 {{(r.roomCount - (r.useCount||0)).toFixed()}} 间-->
99 <!-- </div>--> 114 <!-- </div>-->
...@@ -111,11 +126,14 @@ ...@@ -111,11 +126,14 @@
111 </div> 126 </div>
112 </template> 127 </template>
113 128
114 <script setup lang="ts"> 129 <script setup >
115 import {useRouter} from "vue-router"; 130 import {useRouter} from "vue-router";
116 import {ref, reactive, onMounted} from "vue"; 131 import {ref, reactive, onMounted} from "vue";
117 import {useRoute} from "vue-router"; 132 import {useRoute} from "vue-router";
133 import {dayjs} from 'element-plus'
118 import {getHotelById, getHotelRooms,checkRoomPayByUserId} from "@/apiPc/booking" 134 import {getHotelById, getHotelRooms,checkRoomPayByUserId} from "@/apiPc/booking"
135 import {getBaseInfoByActiveId} from "@/apiPc/booking";
136
119 137
120 import {useStorage} from "@vueuse/core/index"; 138 import {useStorage} from "@vueuse/core/index";
121 import useUserStore from "@/store/modules/user"; 139 import useUserStore from "@/store/modules/user";
...@@ -129,12 +147,34 @@ const form = ref({}) ...@@ -129,12 +147,34 @@ const form = ref({})
129 const query = ref({ 147 const query = ref({
130 hotelId: route.query.id 148 hotelId: route.query.id
131 }) 149 })
150 const hotTime=ref([])
132 const showAll = ref(false) 151 const showAll = ref(false)
133 const loading = ref(false) 152 const loading = ref(false)
134 const roomList = ref([]) 153 const roomList = ref([])
135 const map = ref(null) 154 const map = ref(null)
155 const formTime=ref({})
136 onMounted(() => { 156 onMounted(() => {
137 getData() 157 console.log(route.params)
158 getBaseInfoByActiveId(route.params.cptId).then(res=>{
159 formTime.value = res.data || null
160 }).catch(err=>{
161 console.log(err)
162 formTime.value = null
163 }).finally(()=>{
164 console.log(formTime.value)
165 if (formTime.value){
166 if (dayjs().isBefore(dayjs(formTime.value.hqStart))){
167 hotTime.value[0]=dayjs(formTime.value.hqStart).format('YYYY-MM-DD')
168 hotTime.value[1]=dayjs(formTime.value.hqEnd).add(1,'day').format('YYYY-MM-DD')
169 } else{
170 hotTime.value[0]=dayjs().format('YYYY-MM-DD')
171 hotTime.value[1]=dayjs().add(1,'day').format('YYYY-MM-DD')
172 }
173 }
174
175 getData()
176 })
177
138 }) 178 })
139 179
140 function getData() { 180 function getData() {
...@@ -147,13 +187,15 @@ function getData() { ...@@ -147,13 +187,15 @@ function getData() {
147 console.log(err) 187 console.log(err)
148 }) 188 })
149 query.value.hotelId = route.query.id 189 query.value.hotelId = route.query.id
190 query.value.rzStart=hotTime.value?hotTime.value[0]:null
191 query.value.rzEnd=hotTime.value?hotTime.value[1]:null
150 getHotelRooms(query.value).then(res => { 192 getHotelRooms(query.value).then(res => {
151 roomList.value = res.rows 193 roomList.value = res.rows
152 }) 194 })
153 } 195 }
154 196
155 function initMap() { 197 function initMap() {
156 const TMap = (window as any).TMap 198 // const TMap = (window as any).TMap
157 var center = new TMap.LatLng(form.value.latitude, form.value.longitude);//设置中心点坐标' 199 var center = new TMap.LatLng(form.value.latitude, form.value.longitude);//设置中心点坐标'
158 var map = new TMap.Map("map", { 200 var map = new TMap.Map("map", {
159 center: center,//设置地图中心点坐标 201 center: center,//设置地图中心点坐标
...@@ -208,7 +250,7 @@ function goOrder(room) { ...@@ -208,7 +250,7 @@ function goOrder(room) {
208 ).then((res) => { 250 ).then((res) => {
209 console.log(res) 251 console.log(res)
210 router.push({ 252 router.push({
211 name:'myReservation' 253 name:'myReservation',
212 }) 254 })
213 }) 255 })
214 // .catch((res) => { 256 // .catch((res) => {
...@@ -230,10 +272,19 @@ function goNext(room) { ...@@ -230,10 +272,19 @@ function goNext(room) {
230 query:{ 272 query:{
231 room:encodeURIComponent(JSON.stringify(room)), 273 room:encodeURIComponent(JSON.stringify(room)),
232 hotelName:form.value.name, 274 hotelName:form.value.name,
233 checkInTime:form.value.checkInTime 275 checkInTime:form.value.checkInTime,
276 start:hotTime.value[0],
277 end:hotTime.value[1],
234 } 278 }
235 }) 279 })
236 } 280 }
281
282 function getDaysBetween(){
283 console.log(hotTime.value)
284 getData()
285 }
286
287
237 function goMap() { 288 function goMap() {
238 return 289 return
239 // var tencentMapUrl = "https://map.qq.com/"; 290 // var tencentMapUrl = "https://map.qq.com/";
...@@ -242,6 +293,7 @@ function goMap() { ...@@ -242,6 +293,7 @@ function goMap() {
242 var mapUrl_tx = "http://apis.map.qq.com/uri/v1/marker?marker=coord:"+form.value.latitude+","+form.value.longitude+"&referer=yellowpage"; 293 var mapUrl_tx = "http://apis.map.qq.com/uri/v1/marker?marker=coord:"+form.value.latitude+","+form.value.longitude+"&referer=yellowpage";
243 window.open(url, "_blank") 294 window.open(url, "_blank")
244 } 295 }
296
245 </script> 297 </script>
246 298
247 <style scoped lang="scss"> 299 <style scoped lang="scss">
...@@ -363,4 +415,13 @@ function goMap() { ...@@ -363,4 +415,13 @@ function goMap() {
363 .el-icon{margin-right: 5px;} 415 .el-icon{margin-right: 5px;}
364 } 416 }
365 .oddmb:nth-child(2){margin-bottom: 20px;} 417 .oddmb:nth-child(2){margin-bottom: 20px;}
418 .forbid{
419 cursor:not-allowed !important;
420 background-color: rgba(0,0,0,.5) !important;
421 background: linear-gradient(90deg, #b38ce3, #3d3a79) !important;
422 color: #aca7a7 !important;
423 div{
424 color: #aca7a7 !important;
425 }
426 }
366 </style> 427 </style>
......
...@@ -29,12 +29,14 @@ ...@@ -29,12 +29,14 @@
29 <div class="border-rr mt20 pd20"> 29 <div class="border-rr mt20 pd20">
30 <el-form :model="form" :label-width="language == 0 ?'100':'160'" :rules="rules" ref="formRef"> 30 <el-form :model="form" :label-width="language == 0 ?'100':'160'" :rules="rules" ref="formRef">
31 <el-form-item :label="language==0?'入住日期':'Check-in&Check-out'" required> 31 <el-form-item :label="language==0?'入住日期':'Check-in&Check-out'" required>
32 32 <el-date-picker
33 <el-date-picker @change="getDaysBetween" 33 @change="getDaysBetween"
34 v-model="rzRange" 34 v-model="rzRange"
35 type="daterange" :disabled-date="disabledDateRZ" 35 type="daterange"
36 :placeholder="language==0?'选择日期':'Select date'" format="YYYY-MM-DD" 36 :disabled-date="disabledDateRZ"
37 value-format="YYYY-MM-DD"/> 37 :placeholder="language==0?'选择日期':'Select date'"
38 format="YYYY-MM-DD"
39 value-format="YYYY-MM-DD"/>
38 <div class="tip" v-if="lform.hqStart">{{ language==0?'可订日期':'Available date' }}{{ lform.hqStart.slice(0, 10) }} ~ {{ lform.hqEnd.slice(0, 10) }}</div> 40 <div class="tip" v-if="lform.hqStart">{{ language==0?'可订日期':'Available date' }}{{ lform.hqStart.slice(0, 10) }} ~ {{ lform.hqEnd.slice(0, 10) }}</div>
39 41
40 <!-- :picker-options="pickerOptions"--> 42 <!-- :picker-options="pickerOptions"-->
...@@ -249,7 +251,9 @@ const ddDateArr = ref([ ...@@ -249,7 +251,9 @@ const ddDateArr = ref([
249 label: '02:00' 251 label: '02:00'
250 } 252 }
251 ]) 253 ])
252 const rules = ref({}) 254 const rules = ref({
255 phone: { required: true, message: language.value==0? '请输入联系电话':"Please enter a contact number", trigger: 'blur' }
256 })
253 257
254 let usedays = 0 258 let usedays = 0
255 onMounted(() => { 259 onMounted(() => {
...@@ -258,7 +262,11 @@ onMounted(() => { ...@@ -258,7 +262,11 @@ onMounted(() => {
258 console.log(room.value) 262 console.log(room.value)
259 hotelName.value = route.query.hotelName 263 hotelName.value = route.query.hotelName
260 money.value = 0 264 money.value = 0
265 rzRange.value=[]
266 rzRange.value=[route.query.start,route.query.end]
261 initDays() 267 initDays()
268 getDaysBetween()
269 // checkreRooms()
262 }) 270 })
263 function initDays() { 271 function initDays() {
264 getBaseInfoByActiveId(route.params.cptId).then(res=>{ 272 getBaseInfoByActiveId(route.params.cptId).then(res=>{
...@@ -318,9 +326,11 @@ function checkreRooms() { ...@@ -318,9 +326,11 @@ function checkreRooms() {
318 } 326 }
319 327
320 function getDaysBetween(e) { 328 function getDaysBetween(e) {
321 console.log('入住时间arr', e, rzRange.value) 329 // console.log('入住时间arr', e, rzRange.value)
322 var d1 = Date.parse(e[0]) 330 // console.log(e)
323 var d2 = Date.parse(e[1]) 331 // console.log(Date.parse(rzRange.value[0]))
332 var d1 = Date.parse(rzRange.value[0])
333 var d2 = Date.parse(rzRange.value[1])
324 if (d1 == d2) { 334 if (d1 == d2) {
325 usedays = 0 335 usedays = 0
326 ElMessage.error(language == 0 ? '入住时间跨度需大于一天' :'The duration of the stay must be more than one day.') 336 ElMessage.error(language == 0 ? '入住时间跨度需大于一天' :'The duration of the stay must be more than one day.')
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!