Showing
1 changed file
with
25 additions
and
13 deletions
| @@ -20,14 +20,14 @@ Component({ | @@ -20,14 +20,14 @@ Component({ | ||
| 20 | 20 | ||
| 21 | }, | 21 | }, |
| 22 | ready(){ | 22 | ready(){ |
| 23 | - this.getroombydate(); | ||
| 24 | - this.triggerEvent('selecttime',{time:this.data.time,action:'defalut'}) | 23 | + |
| 25 | }, | 24 | }, |
| 26 | observers: { | 25 | observers: { |
| 27 | - 'date': function(date) { | ||
| 28 | - this.setData({ | ||
| 29 | - date: date | ||
| 30 | - }) | 26 | + 'date': function(newdate) { |
| 27 | + if(newdate!=''){ | ||
| 28 | + this.getroombydate(); | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | } | 31 | } |
| 32 | }, | 32 | }, |
| 33 | methods:{ | 33 | methods:{ |
| @@ -37,7 +37,7 @@ Component({ | @@ -37,7 +37,7 @@ Component({ | ||
| 37 | }, | 37 | }, |
| 38 | //获得默认所有可订时间段 | 38 | //获得默认所有可订时间段 |
| 39 | getdurlist(houseFull){ | 39 | getdurlist(houseFull){ |
| 40 | - let currenttimemark=date.getHours()+new Date().getMinutes()/60; | 40 | + let currenttimemark=date.getHours()+date.getMinutes()/60; |
| 41 | let timedur=this.data.seller.daily; | 41 | let timedur=this.data.seller.daily; |
| 42 | for(let key in houseFull){ | 42 | for(let key in houseFull){ |
| 43 | if(houseFull[key]==1){ | 43 | if(houseFull[key]==1){ |
| @@ -50,10 +50,22 @@ Component({ | @@ -50,10 +50,22 @@ Component({ | ||
| 50 | //每个时段的开始时间、结束时间 | 50 | //每个时段的开始时间、结束时间 |
| 51 | let starttime=Number(arr[0].split(':')[0]); | 51 | let starttime=Number(arr[0].split(':')[0]); |
| 52 | let endtime=Number(arr[1].split(':')[0]); | 52 | let endtime=Number(arr[1].split(':')[0]); |
| 53 | - if(currenttimemark+0.5<endtime){ | ||
| 54 | - if(currenttimemark+0.5>starttime){ | ||
| 55 | - starttime=Math.round(currenttimemark)+0.5; | 53 | + if(util.unixtoTime(date/1000,'YYYY-MM-DD')==this.data.date){ |
| 54 | + if(currenttimemark+0.5<endtime){ | ||
| 55 | + if(currenttimemark+0.5>starttime){ | ||
| 56 | + starttime=Math.round(currenttimemark)+0.5; | ||
| 57 | + } | ||
| 58 | + for(let i=starttime;i<=endtime;i+=0.5){ | ||
| 59 | + let obj={}; | ||
| 60 | + if(i%1==0){ | ||
| 61 | + obj.showdur=i<10 ? '0'+i+':00' : i+':00' | ||
| 62 | + }else{ | ||
| 63 | + obj.showdur=i<10 ? '0'+Math.floor(i)+':30' : Math.floor(i)+':30' | ||
| 64 | + } | ||
| 65 | + durlist.push(obj) | ||
| 66 | + } | ||
| 56 | } | 67 | } |
| 68 | + }else{ | ||
| 57 | for(let i=starttime;i<=endtime;i+=0.5){ | 69 | for(let i=starttime;i<=endtime;i+=0.5){ |
| 58 | let obj={}; | 70 | let obj={}; |
| 59 | if(i%1==0){ | 71 | if(i%1==0){ |
| @@ -63,13 +75,13 @@ Component({ | @@ -63,13 +75,13 @@ Component({ | ||
| 63 | } | 75 | } |
| 64 | durlist.push(obj) | 76 | durlist.push(obj) |
| 65 | } | 77 | } |
| 66 | - } | ||
| 67 | - | 78 | + } |
| 68 | } | 79 | } |
| 69 | this.setData({ | 80 | this.setData({ |
| 70 | durlist:durlist, | 81 | durlist:durlist, |
| 71 | - time:this.data.time=='' ? durlist[0].showdur : this.data.time | 82 | + time:this.data.time=='' ? (durlist.length>0 ? durlist[0].showdur : '暂无可预订时段') : this.data.time |
| 72 | }) | 83 | }) |
| 84 | + this.triggerEvent('selecttime',{time:this.data.time,action:'defalut'}) | ||
| 73 | }, | 85 | }, |
| 74 | //获取具体日期时间段满房状态 | 86 | //获取具体日期时间段满房状态 |
| 75 | getroombydate(){ | 87 | getroombydate(){ |
-
Please register or login to post a comment