0491bdfe by zhangmeng

Merge branch 'hotel' into bug-order

2 parents ad624431 c4e194be
...@@ -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,35 @@ function goNext(room) { ...@@ -230,10 +272,35 @@ 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(e){
283 console.log(hotTime.value)
284 getData()
285 console.log(e)
286 }
287
288 function disabledDateRZ(date) {
289 //判读今天大与form.value.hqStart
290 console.log(formTime.value.hqStart)
291 // const start=dayjs(formTime.value.hqStart).format('YYYY-MM-DD')
292 // const end=dayjs(formTime.value.hqStart).format('YYYY-MM-DD')
293 if (formTime.value.hqStart) {
294 const today = dayjs().format('YYYY-MM-DD')
295 if (formTime.value.hqStart < today) {
296 return !((date.getTime() >= dayjs(today).valueOf())&&(date.getTime() <= dayjs(formTime.value.hqEnd).valueOf()))
297 } else {
298 return !((date.getTime() >= dayjs(formTime.value.hqStart).valueOf())&&(date.getTime() <= dayjs(formTime.value.hqEnd).valueOf()))
299 }
300 }
301 return true
302 }
303
237 function goMap() { 304 function goMap() {
238 return 305 return
239 // var tencentMapUrl = "https://map.qq.com/"; 306 // var tencentMapUrl = "https://map.qq.com/";
...@@ -242,6 +309,7 @@ function goMap() { ...@@ -242,6 +309,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"; 309 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") 310 window.open(url, "_blank")
244 } 311 }
312
245 </script> 313 </script>
246 314
247 <style scoped lang="scss"> 315 <style scoped lang="scss">
...@@ -363,4 +431,13 @@ function goMap() { ...@@ -363,4 +431,13 @@ function goMap() {
363 .el-icon{margin-right: 5px;} 431 .el-icon{margin-right: 5px;}
364 } 432 }
365 .oddmb:nth-child(2){margin-bottom: 20px;} 433 .oddmb:nth-child(2){margin-bottom: 20px;}
434 .forbid{
435 cursor:not-allowed !important;
436 background-color: rgba(0,0,0,.5) !important;
437 background: linear-gradient(90deg, #b38ce3, #3d3a79) !important;
438 color: #aca7a7 !important;
439 div{
440 color: #aca7a7 !important;
441 }
442 }
366 </style> 443 </style>
......
...@@ -29,19 +29,21 @@ ...@@ -29,19 +29,21 @@
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"-->
41 </el-form-item> 43 </el-form-item>
42 <el-form-item :label="language==0?'房间数':'Rooms'" required prop="roomNum"> 44 <el-form-item :label="language==0?'房间数':'Rooms'" required prop="roomNum">
43 <el-input-number v-model="form.roomNum" :min="0" :max="canOrderNum" @change="changeRoomNum"/> 45 <el-input-number v-model="form.roomNum" :min="0" :max="canOrderNum" @change="changeRoomNum"/>
44 <div class="red ml20" v-if="rzRange[1]"> 46 <div class="red ml20" v-if="rzRange?.[1]">
45 <span v-if="language == 0">剩余房间数:{{ canOrderNum }}</span> 47 <span v-if="language == 0">剩余房间数:{{ canOrderNum }}</span>
46 <span v-else>{{ canOrderNum }} Remaining rooms</span> 48 <span v-else>{{ canOrderNum }} Remaining rooms</span>
47 </div> 49 </div>
...@@ -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?rzRange.value[0]:null)
333 var d2 = Date.parse(rzRange.value?rzRange.value[1]:null)
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.')
...@@ -332,9 +342,10 @@ function getDaysBetween(e) { ...@@ -332,9 +342,10 @@ function getDaysBetween(e) {
332 usedays = days 342 usedays = days
333 } 343 }
334 countMoney() 344 countMoney()
335 var startTime = getDate(rzRange.value[0]); 345 var startTime = getDate(rzRange.value?rzRange.value[0]:null);
336 var endTime = getDate(rzRange.value[1]); 346 var endTime = getDate(rzRange.value?rzRange.value[1]:null);
337 var dateArr = []; 347 var dateArr = [];
348 if (!startTime||!endTime)return;
338 while ((endTime.getTime() - startTime.getTime()) > 0) { 349 while ((endTime.getTime() - startTime.getTime()) > 0) {
339 var year = startTime.getFullYear(); 350 var year = startTime.getFullYear();
340 var month = (startTime.getMonth() + 1).toString().length === 1 ? "0" + (parseInt(startTime.getMonth() 351 var month = (startTime.getMonth() + 1).toString().length === 1 ? "0" + (parseInt(startTime.getMonth()
...@@ -348,6 +359,7 @@ function getDaysBetween(e) { ...@@ -348,6 +359,7 @@ function getDaysBetween(e) {
348 } 359 }
349 360
350 function getDate(datestr) { 361 function getDate(datestr) {
362 if (!datestr) return
351 var temp = datestr.split("-"); 363 var temp = datestr.split("-");
352 if (temp[1] === '01') { 364 if (temp[1] === '01') {
353 temp[0] = parseInt(temp[0], 10) - 1; 365 temp[0] = parseInt(temp[0], 10) - 1;
...@@ -364,12 +376,12 @@ function countMoney() { ...@@ -364,12 +376,12 @@ function countMoney() {
364 if (language.value == 0) { 376 if (language.value == 0) {
365 money.value = ((room.value.roomPrice * form.value.roomNum * usedays) + (room.value.bedPrice * form.value 377 money.value = ((room.value.roomPrice * form.value.roomNum * usedays) + (room.value.bedPrice * form.value
366 .addNum * usedays)).toFixed(2) 378 .addNum * usedays)).toFixed(2)
367
368 } else { 379 } else {
369 money.value = ((room.value.roomPriceEn * form.value.roomNum * usedays) + (room.value.bedPriceEn * form.value 380 money.value = ((room.value.roomPriceEn * form.value.roomNum * usedays) + (room.value.bedPriceEn * form.value
370 .addNum * usedays)).toFixed(2) 381 .addNum * usedays)).toFixed(2)
382
371 } 383 }
372 // console.log(usedays,money.value) 384 if (money.value == 'NaN') money.value=0.00
373 } 385 }
374 386
375 function submit() { 387 function submit() {
...@@ -377,7 +389,7 @@ function submit() { ...@@ -377,7 +389,7 @@ function submit() {
377 useUserStore().setReLogin() 389 useUserStore().setReLogin()
378 return 390 return
379 } 391 }
380 392 if(!rzRange.value)return ElMessage.warning(language.value == 0 ? '请选择入住时间' : 'Please select check-in time')
381 if (usedays == 0) { 393 if (usedays == 0) {
382 ElMessage.warning(language.value == 0 ? '入住时间跨度需大于一天' : 'Check-in time must be greater than one day') 394 ElMessage.warning(language.value == 0 ? '入住时间跨度需大于一天' : 'Check-in time must be greater than one day')
383 return 395 return
...@@ -390,6 +402,7 @@ function submit() { ...@@ -390,6 +402,7 @@ function submit() {
390 ElMessage.warning(language.value == 0 ? '请填写手机号' : 'Please fill in the phone number') 402 ElMessage.warning(language.value == 0 ? '请填写手机号' : 'Please fill in the phone number')
391 return 403 return
392 } 404 }
405
393 form.value.rzStart = rzRange.value[0] 406 form.value.rzStart = rzRange.value[0]
394 form.value.rzEnd = rzRange.value[1] 407 form.value.rzEnd = rzRange.value[1]
395 408
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!