Commit 49882ac220e0be63bcd7702728d2ba31cf8af82c

Authored by liuxuqinfhp1220
1 parent 1a190b6b

no message

@@ -121,6 +121,10 @@ @@ -121,6 +121,10 @@
121 "bmCalendar": { 121 "bmCalendar": {
122 "version": "1.2.1", 122 "version": "1.2.1",
123 "provider": "wx23a9cef3522e4f7c" 123 "provider": "wx23a9cef3522e4f7c"
  124 + },
  125 + "myPlugin": {
  126 + "version": "2.1.0",
  127 + "provider": "wx6b6cb15df2836ebe"
124 } 128 }
125 }, 129 },
126 "permission": { 130 "permission": {
@@ -117,6 +117,9 @@ @@ -117,6 +117,9 @@
117 .black-font{ 117 .black-font{
118 color:#353535; 118 color:#353535;
119 } 119 }
  120 +.gray-font{
  121 + color:#999999;
  122 +}
120 .white-font{ 123 .white-font{
121 color:#fff; 124 color:#fff;
122 } 125 }
@@ -7,168 +7,249 @@ Component({ @@ -7,168 +7,249 @@ Component({
7 date:{ 7 date:{
8 type:String, 8 type:String,
9 value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'), 9 value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
  10 + },
  11 + hidecalendar:{
  12 + type:Boolean,
  13 + value:true
10 } 14 }
11 }, 15 },
12 data: { 16 data: {
13 - curYear: new Date().getFullYear(), // 年份  
14 - curMonth: new Date().getMonth() + 1,// 月份 1-12  
15 - day:new Date().getDate(),  
16 - header_show: true, // 主标题是否显示  
17 - next: true, // 下一个月按钮是否显示  
18 - closelaststyle:true,  
19 - speciallist: [],  
20 - nextNum:0, 17 + showprev:false
  18 + },
  19 + observers: {
  20 + 'seller,date': function(seller,newdate) {
  21 + if(seller && newdate!=''){
  22 + let showYearMonth=this.getshowmonth();
  23 + if(this.data.showYearMonth){ //周历点击
  24 + if(showYearMonth.showyear==this.data.showYearMonth.showyear && showYearMonth.showmonth==this.data.showYearMonth.showmonth){
  25 + this.changedatestyle(newdate);
  26 + }else{
  27 + this.setData({
  28 + showYearMonth:showYearMonth,
  29 + showprev:this.isShowPrev(showYearMonth)
  30 + })
  31 + this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
  32 + // this.gethousefulldate(seller);
  33 + }
  34 + }else{
  35 + //初始化---默认
  36 + this.setData({
  37 + showYearMonth:showYearMonth,
  38 + showprev:this.isShowPrev(showYearMonth)
  39 + })
  40 + this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
  41 + // this.gethousefulldate(seller);
  42 + }
  43 +
  44 + }
  45 +
  46 + }
21 }, 47 },
22 attached(){ 48 attached(){
23 - //默认标记特殊日期  
24 - this.getspeciallist();  
25 - this.gethousefulldate(this.data.curYear,this.data.curMonth,'defalut'); 49 + this.getweeklist();
26 }, 50 },
27 ready(){ 51 ready(){
28 }, 52 },
29 detached(){ 53 detached(){
30 console.log('在组件实例被从页面节点树移除时执行') 54 console.log('在组件实例被从页面节点树移除时执行')
31 }, 55 },
32 - //测试  
33 - pageLifetimes: {  
34 - show(){  
35 - //日期改变重新标记  
36 - if(this.data.speciallist.date!=util.unixtoTime(new Date()/1000, 'YYYY-MM-DD')){  
37 - this.getspeciallist();  
38 - this.setData({  
39 - curYear: new Date().getFullYear(), // 年份  
40 - curMonth: new Date().getMonth() + 1,// 月份 1-12  
41 - day:new Date().getDate(),  
42 - }) 56 + methods:{
  57 + //获取当前选中日期
  58 + getshowmonth(){
  59 + let datearr=this.data.date.split('-');
  60 + return{
  61 + showyear:Number(datearr[0]),
  62 + showmonth:Number(datearr[1]),
43 } 63 }
44 - console.log(this.data.date,new Date());  
45 }, 64 },
46 - hide(){  
47 - console.log(this.data.date);  
48 - }  
49 - },  
50 - methods:{  
51 - //默认标记特殊日期  
52 - getspeciallist(){  
53 - let speciallist = [  
54 - {date: util.unixtoTime(new Date()/1000, 'YYYY-MM-DD'), background: '', text: '今'},  
55 - {date: util.unixtoTime(new Date()/1000 + 86400, 'YYYY-MM-DD'), background: '', text: '明'}  
56 - ]; 65 + //获得周列表
  66 + getweeklist(){
  67 + let week=['日','一','二','三','四','五','六'];
  68 + let weeklist=[];
  69 + for(let i=0;i<week.length;i++){
  70 + weeklist.push({
  71 + weekfont:week[i],
  72 + weeknum:i
  73 + })
  74 + }
57 this.setData({ 75 this.setData({
58 - speciallist:speciallist 76 + weeklist:weeklist,
59 }) 77 })
60 }, 78 },
61 - //根据指定年份月份获取当月满房的日期  
62 - gethousefulldate(year,month,action){  
63 - let parmdata={  
64 - sid:this.data.seller.id,  
65 - date:year+'-'+month 79 + //获取显示月份天数
  80 + getMonthdays(year,month){
  81 + var d = new Date(year,month,0);
  82 + return d.getDate();
  83 + },
  84 + //获取某一天是星期几
  85 + getdayweek:function(year,month,day){
  86 + var tmpdate=new Date(year,month,day);
  87 + return tmpdate.getDay()
  88 + },
  89 + //获取当月日期
  90 + getdayslist(year,month){
  91 + this.today={
  92 + curdate:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
  93 + curtimestamp:new Date()/1000
66 } 94 }
67 - App.Customer.GetHouseFullDate(parmdata).then((json)=>{  
68 - console.log(json)  
69 - let obj={  
70 - date:this.data.date,  
71 - action:'defalut',  
72 - overdate:0,  
73 - }  
74 - if(json.ret==200){  
75 - this.houseFullDate=json.data;  
76 - //默认  
77 - if(action=='defalut'){  
78 - if(this.houseFullDate.indexOf(this.data.date)==-1){  
79 - obj.houseFullStatus=0;  
80 - }else{ //满房  
81 - obj.houseFullStatus=1;  
82 - }  
83 - this.triggerEvent('selectdate',obj) 95 + //当前显示月份天数
  96 + let monthdays=this.getMonthdays(year,month);
  97 + //当前月1号星期几
  98 + let dayweek=this.getdayweek(year,month,1);
  99 + let daylist=[];
  100 + //多少行
  101 + let singlelen=Math.ceil((monthdays+dayweek)/7);
  102 + for(let i=0;i<singlelen;i++){
  103 + daylist.push({
  104 + list:[]
  105 + })
  106 + }
  107 + //本月日期
  108 + for(let i=0;i<singlelen*7;i++){
  109 + let thisdayobj={};
  110 + if(i>=dayweek && i<monthdays+dayweek){
  111 + let thisday=i-dayweek+1;
  112 + let thisdate=year+'-'+(month<10 ? '0'+month : month)+'-'+(thisday<10 ? '0'+thisday : thisday);
  113 + let thistimestamp=Number(util.timetouUnix(thisdate,'-'));
  114 + thisdayobj={
  115 + year:year,
  116 + month:month,
  117 + day:thisday,
  118 + week:i%7,
  119 + date:thisdate,
  120 + istoday:false,
  121 + overdate:thistimestamp<(new Date()/1000)-86400 ? true : false, //日期是否过期,
84 } 122 }
85 - if(json.data.length>0){  
86 - this.changespeciallist(json.data) 123 + if(thisdate==this.today.curdate){
  124 + thisdayobj.istoday=true;
  125 + thisdayobj.mark='今'
87 } 126 }
88 -  
89 - }else{  
90 - //不可预订  
91 - if(json.ret==401){  
92 - if(action=='defalut'){  
93 - this.houseFullDate=null  
94 - this.triggerEvent('selectdate',obj);  
95 - obj.action=401;  
96 - this.triggerEvent('selectdate',obj);  
97 -  
98 - } 127 + if(util.unixtoTime(this.today.curtimestamp+86400,'YYYY-MM-DD')==thisdate){
  128 + thisdayobj.mark='明'
99 } 129 }
100 - 130 + thisdayobj.isselected=this.data.date==thisdate ? true : false;
101 } 131 }
  132 + daylist[Math.floor(i/7)].list.push(thisdayobj)
  133 + }
  134 + this.setData({
  135 + daylist:daylist
102 }) 136 })
  137 + console.log(daylist)
103 }, 138 },
104 - //修改标记特殊日期  
105 - changespeciallist(houseFullDate){  
106 - let speciallist=this.data.speciallist;  
107 - let newspeciallist=[];  
108 - houseFullDate.forEach((v,i)=>{  
109 - newspeciallist.push({  
110 - date:v,  
111 - background:'',  
112 - text:'满' 139 + //选择日期
  140 + selectdate(e){
  141 + let _target=e.currentTarget.dataset;
  142 + this.changedatestyle(_target.date);
  143 + this.triggerEvent('tellselectdate',{date:_target.date,action:'click'});
  144 + },
  145 + //修改日期列表
  146 + changedatestyle(selecteddate){
  147 + let daylist=this.data.daylist;
  148 + let prevsingle,previndex,cursingle,curindex;
  149 + daylist.forEach((v,i)=>{
  150 + v.list.forEach((r,n)=>{
  151 + if(r.isselected){
  152 + prevsingle=i;
  153 + previndex=n;
  154 + let prevkey='daylist['+prevsingle+'].list['+previndex+'].isselected';
  155 + this.setData({
  156 + [prevkey]:false,
  157 + })
  158 + }
  159 + if(r.date==selecteddate){
  160 + cursingle=i;
  161 + curindex=n;
  162 + }
113 }) 163 })
114 }) 164 })
115 - speciallist.forEach((v,i)=>{  
116 - if(houseFullDate.indexOf(v.date)==-1){  
117 - newspeciallist.push(v)  
118 - }  
119 - })  
120 - console.log(newspeciallist) 165 + let currentkey='daylist['+cursingle+'].list['+curindex+'].isselected';
121 this.setData({ 166 this.setData({
122 - speciallist:newspeciallist 167 + [currentkey]:true
123 }) 168 })
124 }, 169 },
125 - //下一月  
126 - nextMonth(e){  
127 - console.log(e)  
128 - this.gethousefulldate(e.detail.currentYear,e.detail.currentMonth,'click');  
129 - this.setData({  
130 - nextNum:this.data.nextNum+1  
131 - }) 170 + //计算是否显示prev
  171 + isShowPrev(showYearMonth){
  172 + let curyear=new Date().getFullYear();
  173 + let curmonth=new Date().getMonth() + 1;
  174 + let curtitle=''+curyear+(curmonth<10 ? '0'+curmonth : curmonth);
  175 + let showtitle=''+showYearMonth.showyear+(showYearMonth.showmonth< 10 ? '0'+showYearMonth.showmonth : showYearMonth.showmonth)
  176 + return Number(showtitle)>Number(curtitle);
132 }, 177 },
133 - //上一月  
134 - prevMonth(e){  
135 - this.gethousefulldate(e.detail.currentYear,e.detail.currentMonth,'click'); 178 + //回退月份
  179 + prevmonth(){
  180 + var showyear=this.data.showYearMonth.showyear;
  181 + var showmonth=this.data.showYearMonth.showmonth;
  182 + if(showmonth==1){
  183 + showmonth=12;
  184 + showyear=showyear-1;
  185 + }else{
  186 + showmonth-=1;
  187 + }
  188 + let showYearMonth={
  189 + showyear:showyear,
  190 + showmonth:showmonth
  191 + }
136 this.setData({ 192 this.setData({
137 - nextNum:this.data.nextNum-1 193 + showYearMonth:showYearMonth,
  194 + showprev:this.isShowPrev(showYearMonth)
138 }) 195 })
  196 + this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
  197 + this.gethousefulldate(this.data.seller);
139 }, 198 },
140 - //点击日期  
141 - selectDate(e){ 199 + //推前月份
  200 + nextmonth(){
  201 + var showyear=this.data.showYearMonth.showyear;
  202 + var showmonth=this.data.showYearMonth.showmonth;
  203 + if(showmonth==12){
  204 + showmonth=1;
  205 + showyear=showyear+1;
  206 + }else{
  207 + showmonth+=1;
  208 + }
  209 + let showYearMonth={
  210 + showyear:showyear,
  211 + showmonth:showmonth
  212 + }
142 this.setData({ 213 this.setData({
143 - date:e.detail.date 214 + showYearMonth:showYearMonth,
  215 + showprev:this.isShowPrev(showYearMonth)
144 }) 216 })
145 - let obj={  
146 - date:this.data.date,  
147 - action:'click', 217 + this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
  218 + this.gethousefulldate(this.data.seller);
  219 + },
  220 + //根据指定年份月份获取当月满房的日期
  221 + gethousefulldate(seller){
  222 + let showYearMonth=this.data.showYearMonth;
  223 + let parmdata={
  224 + sid:seller.id,
  225 + type:'month',
  226 + date:showYearMonth.showyear+'-'+(showYearMonth.showmonth<10 ? '0'+showYearMonth.showmonth : showYearMonth.showmonth)
148 } 227 }
149 - if(Number(util.timetouUnix(this.data.date,'-'))-new Date()/1000>=-24*60*60){ //今天以及之后日期  
150 - obj.overdate=0;  
151 - //可预订  
152 - if(this.houseFullDate){  
153 - if(this.houseFullDate.indexOf(this.data.date)==-1){  
154 - obj.houseFullStatus=0;  
155 - }else{ //满房  
156 - obj.houseFullStatus=1; 228 + App.Customer.GetHouseFullDate(parmdata).then((json)=>{
  229 + console.log(json)
  230 + if(json.ret==200){
  231 + if(json.data && json.data.length>0){
  232 + this.markFullHouse(json.data);
157 } 233 }
158 - this.triggerEvent('selectdate',obj)  
159 - }else{  
160 - //不可预订  
161 - obj.houseFullStatus=1;  
162 - this.triggerEvent('selectdate',obj);  
163 - obj.action=401  
164 - this.triggerEvent('selectdate',obj);  
165 } 234 }
166 - }else{ //overdate为1过期日期  
167 - obj.overdate=1;  
168 - obj.houseFullStatus=1;  
169 - this.triggerEvent('selectdate',obj)  
170 - }  
171 - } 235 + })
  236 + },
  237 + //标记满房
  238 + markFullHouse(fullHouseDate){
  239 + let daylist=this.data.daylist;
  240 + daylist.forEach((v,i)=>{
  241 + v.list.forEach((r,n)=>{
  242 + fullHouseDate.forEach((r1,n1)=>{
  243 + if(r1==r.date){
  244 + r.mark='满'
  245 + }
  246 + })
  247 + })
  248 + })
  249 + this.setData({
  250 + daylist:daylist
  251 + })
  252 + },
172 } 253 }
173 254
174 }) 255 })
1 { 1 {
2 "component": true, 2 "component": true,
3 "usingComponents": { 3 "usingComponents": {
4 - "calendar": "plugin://bmCalendar/calendar" 4 +
5 } 5 }
6 } 6 }
1 -<calendar  
2 -cur-year="{{curYear}}"  
3 -cur-month="{{curMonth}}"  
4 -day="{{day}}"  
5 -header_show='{{header_show}}'  
6 -prev='{{nextNum}}'  
7 -next='{{next}}'  
8 -speciallist="{{speciallist}}"  
9 -closelaststyle="{{closelaststyle}}"  
10 -colored="#e0e0e0"  
11 -circle_show="{{false}}"  
12 -weekheight="100"  
13 -txt_style="txt_style"  
14 -calendar-style="calendar-style"  
15 -weektitle-style="week-style"  
16 -datefont-style="datefont-style"  
17 -header-style="header-style"  
18 -active-colort="active-colort"  
19 -active-coloro="active-coloro"  
20 -bindnextMonth="nextMonth"  
21 -bindprevMonth="prevMonth"  
22 -bindselectDate="selectDate"/>  
  1 +<view class="calendar" hidden="{{hidecalendar}}">
  2 + <view class="calendar-title flex-lr">
  3 + <view class="black-font font30r Semibold calendar-title-date">{{showYearMonth.showyear}}-{{showYearMonth.showmonth<10 ? '0'+showYearMonth.showmonth : showYearMonth.showmonth}}</view>
  4 + <view class="calendar-title-tab-list flex-rr">
  5 + <block wx:if="{{showprev}}">
  6 + <view class="calendar-title-tab-cover calendar-title-prev-cover" bindtap="prevmonth">
  7 + <view class="calendar-title-prev calendar-title-tab"></view>
  8 + </view>
  9 + </block>
  10 + <view class="calendar-title-tab-cover calendar-title-next-cover" bindtap="nextmonth">
  11 + <view class="calendar-title-next calendar-title-tab"></view>
  12 + </view>
  13 + </view>
  14 + </view>
  15 + <view class="calendar-week flex-lr">
  16 + <block wx:for="{{weeklist}}" wx:key="{{index}}">
  17 + <view class="week-single gray-font font30r Semibold flex-cc">{{item.weekfont}}</view>
  18 + </block>
  19 + </view>
  20 + <view class="calendar-content">
  21 + <block wx:for="{{daylist}}" wx:for-item="itemlist" wx:for-index="indexlist" wx:key="{{indexlist}}">
  22 + <view class="calendar-week-day flex-lr">
  23 + <block wx:for="{{itemlist.list}}" wx:key="{{index}}">
  24 + <view class="{{item.overdate ? 'gray-font' : 'font-font'}} calendar-day flex-cc font30r Semibold {{item.istoday ? 'today' : ''}} {{item.isselected ? 'bg-yellow white-font' : ''}}" data-date="{{item.date}}" catchtap="{{item.overdate ? '' : 'selectdate'}}">{{item.mark ? item.mark : item.day}}</view>
  25 + </block>
  26 + </view>
  27 + </block>
  28 +
  29 + </view>
  30 +</view>
1 -.calendar-style{ 1 +@import "../../../app.wxss";
  2 +.calendar{
  3 + width:100%;
2 background: #FFFBF2; 4 background: #FFFBF2;
  5 + border-top-left-radius:20rpx;
  6 + border-top-right-radius:20rpx;
  7 + overflow: hidden;
  8 + padding:30rpx 0;
3 } 9 }
4 -.week-style{  
5 - color:#999;  
6 - font-size:28rpx;  
7 - font-weight:bold;  
8 -}  
9 -.datefont-style{  
10 - color:#353535;  
11 - font-size:30rpx;  
12 - font-weight:bold;  
13 -}  
14 -.header-style{  
15 - color:#353535;  
16 - font-size:30rpx!important;  
17 - font-weight:bold;  
18 -}  
19 -.header-style text:before{  
20 - font-size:30rpx!important;  
21 - color:#666666!important;  
22 - padding:0 30rpx;  
23 -}  
24 -.active-colort{  
25 - color:#C0A369;  
26 - font-weight:bold;  
27 - font-size:28rpx;  
28 - border:1px solid #C0A369;  
29 -}  
30 -.active-coloro{  
31 - color:#fff!important;  
32 - font-weight:bold;  
33 - font-size:28rpx; 10 +.calendar-title{
  11 + width:100%;
  12 + padding:0 40rpx;
  13 + box-sizing: border-box;
  14 +}
  15 +.calendar-title-date{
  16 + padding:30rpx 0 30rpx 20rpx;
  17 +}
  18 +.calendar-title-tab-cover{
  19 + padding:20rpx;
  20 + margin-left:40rpx;
  21 +}
  22 +.calendar-title-prev-cover{
  23 + padding-left:8rpx;
  24 +}
  25 +.calendar-title-next-cover{
  26 + padding-right:8rpx;
  27 +}
  28 +.calendar-week, .calendar-content{
  29 + width:100%;
  30 + padding:0 38rpx;
  31 + box-sizing: border-box;
  32 +}
  33 +.week-single{
  34 + width:80rpx;
  35 + padding-bottom: 12rpx;
  36 +}
  37 +.calendar-week-day{
  38 + width:100%;
  39 + height:80rpx;
  40 +}
  41 +.calendar-title-tab{
  42 + width:0;
  43 + height:0;
  44 + border:12rpx solid transparent;
  45 +}
  46 +.calendar-title-next{
  47 + border-left:12rpx solid #999;
  48 +}
  49 +.calendar-title-prev{
  50 + border-right:12rpx solid #999;
  51 +}
  52 +.calendar-week-day{
  53 + margin-bottom: 14rpx;
  54 +}
  55 +.calendar-day{
  56 + width:80rpx;
  57 + height:80rpx;
  58 + border-radius:50%;
  59 + box-sizing: border-box;
  60 +}
  61 +.calendar-day.today{
  62 + border:2rpx solid #C0A369;
  63 +}
  64 +.calendar-day.bg-yellow{
34 background: -webkit-linear-gradient(top, #F2D190, #C0A369); /* Safari 5.1 - 6.0 */ 65 background: -webkit-linear-gradient(top, #F2D190, #C0A369); /* Safari 5.1 - 6.0 */
35 background: -o-linear-gradient(-45deg, #F2D190, #C0A369); /* Opera 11.1 - 12.0 */ 66 background: -o-linear-gradient(-45deg, #F2D190, #C0A369); /* Opera 11.1 - 12.0 */
36 background: -moz-linear-gradient(top, #F2D190, #C0A369); /* Firefox 3.6 - 15 */ 67 background: -moz-linear-gradient(top, #F2D190, #C0A369); /* Firefox 3.6 - 15 */
37 background: linear-gradient(to bottom, #F2D190, #C0A369); 68 background: linear-gradient(to bottom, #F2D190, #C0A369);
  69 + border-width:0;
38 } 70 }
39 -.txt_style{  
40 - color:#C0A369;  
41 - margin-top:-10px;  
42 - fon-size:20rpx;  
43 -}  
  71 +
  1 +Component({
  2 +
  3 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 + }
  5 +}
  1 +import util from '../../../utils/util';
  2 +import App from '../../../utils/api';
  3 +Component({
  4 + properties:{
  5 + seller:Object,
  6 + //选中日期
  7 + date:{
  8 + type:String,
  9 + value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
  10 + }
  11 + },
  12 + attached(){
  13 + console.log('xxxxx',this.data.seller);
  14 + },
  15 + observers: {
  16 + 'date'(newdate){
  17 + if(newdate!=''){
  18 + //今天日期
  19 + let today=util.unixtoTime(new Date()/1000,'YYYY-MM-DD');
  20 + this.getsectionlist();
  21 + if(today==newdate){
  22 + this.markoversection();
  23 + }else{
  24 + this.changesectionstyle(this.data.sectionlist[0].section);
  25 + let obj={
  26 + section:this.data.sectionlist[0].section,
  27 + action:'defalut',
  28 + time:this.data.sectionlist[0].sectiondur.split('-')[0]
  29 + }
  30 + this.triggerEvent('selectsection',obj)
  31 + }
  32 + }
  33 +
  34 + }
  35 + },
  36 + ready(){
  37 +
  38 + },
  39 + methods:{
  40 + getsectionlist(){
  41 + let section={'morning':'早餐','noon':'午餐','night':'晚餐','midnight':'夜宵'};
  42 + let sectionlist=[];
  43 + for(let key in this.data.seller.daily){
  44 + if(this.data.seller.daily[key]!=""){
  45 + sectionlist.push({
  46 + section:key,
  47 + sectiondur:this.data.seller.daily[key],
  48 + showmark:section[key],
  49 + overdate:false,
  50 + isselected:false
  51 + })
  52 + }
  53 + }
  54 + this.setData({
  55 + sectionlist:sectionlist
  56 + })
  57 + console.log(sectionlist)
  58 + },
  59 + markoversection(){
  60 + let sectionlist=this.data.sectionlist;
  61 + //今天日期
  62 + let today=util.unixtoTime(new Date()/1000,'YYYY-MM-DD');
  63 + let curtimestamp=new Date()/1000;
  64 + let interval=[];
  65 + sectionlist.forEach((v,i)=>{
  66 + let sectionarr=v.sectiondur.split('-');
  67 + if(curtimestamp>=new Date(today+' '+sectionarr[1]+':00')/1000){
  68 + v.overdate=true
  69 + }
  70 + if(!v.overdate){
  71 + let intervaldur=curtimestamp-new Date(today+' '+sectionarr[0]+':00')/1000;
  72 + interval.push({
  73 + intervaldur:intervaldur,
  74 + index:i
  75 + })
  76 + }
  77 + })
  78 + console.log(interval)
  79 + if(interval.length>0){
  80 + sectionlist[interval[0].index].isselected=true;
  81 + this.tellsection(sectionlist[interval[0].index].section,'defalut',interval[0].index)
  82 + }
  83 + this.setData({
  84 + sectionlist:sectionlist
  85 + })
  86 + console.log(sectionlist)
  87 + },
  88 + //点击时段
  89 + selectsection(e){
  90 + let _target=e.currentTarget.dataset;
  91 + this.changesectionstyle(_target.section);
  92 + this.tellsection(_target.section,'click',_target.index);
  93 + },
  94 + //通知时段
  95 + tellsection(selectsection,action,index){
  96 + let today=util.unixtoTime(new Date()/1000,'YYYY-MM-DD');
  97 + let curtimestamp=new Date()/1000;
  98 + let sectionarr=this.data.sectionlist[index].sectiondur.split('-');
  99 + let starttimestamp=new Date(today+' '+sectionarr[0]+':00')/1000;
  100 + let endtimestamp=new Date(today+' '+sectionarr[1]+':00')/1000;
  101 + let obj={
  102 + section:selectsection,
  103 + action:action
  104 + }
  105 + if(curtimestamp>=starttimestamp && curtimestamp<endtimestamp){
  106 + obj.time=sectionarr[1]
  107 + }else{
  108 + if(curtimestamp>=endtimestamp){
  109 + obj.time=sectionarr[1]
  110 + }else{
  111 + obj.time=sectionarr[0]
  112 + }
  113 + }
  114 + this.triggerEvent('selectsection',obj)
  115 +
  116 + },
  117 + changesectionstyle(selectsection){
  118 + let sectionlist=this.data.sectionlist;
  119 + let previndex,curindex;
  120 + sectionlist.forEach((v,i)=>{
  121 + if(v.isselected){
  122 + previndex=i;
  123 + let prevkey='sectionlist['+previndex+'].isselected';
  124 + this.setData({
  125 + [prevkey]:false
  126 + })
  127 + }
  128 + if(selectsection==v.section){
  129 + curindex=i;
  130 + }
  131 + })
  132 + let curkey='sectionlist['+curindex+'].isselected';
  133 + this.setData({
  134 + [curkey]:true
  135 + })
  136 + }
  137 + }
  138 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 +
  5 + }
  6 +}
  1 +<view class="section flex-ll">
  2 + <block wx:for="{{sectionlist}}" wx:key="{{index}}">
  3 + <view class="flex-vc section-single {{item.isselected ? 'bg-yellow' : ''}}" style="width:{{690/sectionlist.length}}rpx;" data-section="{{item.section}}" data-index="{{index}}" catchtap="{{item.overdate ? '' : 'selectsection'}}">
  4 + <view class="{{item.overdate ? 'gray-font' : (item.isselected ? 'white-font' : '')}} font30r Semibold">{{item.showmark}}</view>
  5 + <view class="{{item.overdate ? 'gray-font' : (item.isselected ? 'white-font' : '')}} font24r" style="line-height:34rpx;">{{item.sectiondur}}</view>
  6 + </view>
  7 + </block>
  8 +</view>
  1 +@import "../../../app.wxss";
  2 +.section{
  3 + width:690rpx;
  4 + height:90rpx;
  5 + border-radius:10rpx;
  6 + box-shadow: 0 0 8rpx rgba(166,166,166,.5);
  7 + overflow: hidden;
  8 + margin:0 auto;
  9 +}
  10 +.section-single{
  11 + height:100%;
  12 +}
  13 +.section-single.bg-yellow{
  14 + background: -webkit-linear-gradient(top, #F2D190, #C0A369); /* Safari 5.1 - 6.0 */
  15 + background: -o-linear-gradient(-45deg, #F2D190, #C0A369); /* Opera 11.1 - 12.0 */
  16 + background: -moz-linear-gradient(top, #F2D190, #C0A369); /* Firefox 3.6 - 15 */
  17 + background: linear-gradient(to bottom, #F2D190, #C0A369);
  18 + border-width:0;
  19 +}
  1 +import App from '../../../utils/api';
  2 +import util from '../../../utils/util';
  3 +Component({
  4 + properties:{
  5 + seller:Object,
  6 + date:{
  7 + type:String,
  8 + value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD')
  9 + },
  10 + section:String,
  11 + seletroom:{
  12 + type:Array,
  13 + value:[]
  14 + }
  15 + },
  16 + data:{
  17 +
  18 + }
  19 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
  1 +import util from '../../../utils/util';
  2 +import App from '../../../utils/api';
  3 +Component({
  4 + properties:{
  5 + seller:Object,
  6 + //选中日期
  7 + date:{
  8 + type:String,
  9 + value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
  10 + }
  11 + },
  12 + data:{
  13 + hidecalendar:true
  14 + },
  15 + attached(){
  16 + this.setData({
  17 + showYearMonth:this.getshowmonth(this.data.date)
  18 + })
  19 + this.triggerEvent('selectdate',{date:this.data.date,action:'defalut'})
  20 + this.getweeklist();
  21 + this.getdaylist();
  22 + this.getFullDate();
  23 + },
  24 + ready(){
  25 +
  26 + },
  27 + methods:{
  28 + //获取当前选中日期年月
  29 + getshowmonth(selecteddate){
  30 + let datearr=selecteddate.split('-');
  31 + return{
  32 + showyear:Number(datearr[0]),
  33 + showmonth:Number(datearr[1]),
  34 + }
  35 + },
  36 + //获得周列表
  37 + getweeklist(){
  38 + let week=['日','一','二','三','四','五','六'];
  39 + let weeklist=[];
  40 + for(let i=0;i<week.length;i++){
  41 + weeklist.push({
  42 + weekfont:week[i],
  43 + weeknum:i
  44 + })
  45 + }
  46 + this.setData({
  47 + weeklist:weeklist,
  48 + })
  49 + },
  50 + //获取日期列表
  51 + getdaylist(){
  52 + //选中时间时间戳
  53 + let selectedtime=Number(util.timetouUnix(this.data.date,'-'));
  54 + //选中日期星期几
  55 + let selectedweek=new Date(selectedtime*1000).getDay();
  56 + //今天日期
  57 + let today=util.unixtoTime(new Date()/1000,'YYYY-MM-DD');
  58 + console.log('selectedweek',selectedweek)
  59 + let daylist=[{list:[]},{list:[]}];
  60 + //用于月历点击的时候判断是否改变周历列表
  61 + this.datelist={};
  62 + for(let i=0;i<14;i++){
  63 + let thistimestamp=selectedtime+(i-selectedweek)*86400;
  64 + let thisdate=new Date(thistimestamp*1000);
  65 + let thisdayobj={
  66 + year:thisdate.getFullYear(),
  67 + month:thisdate.getMonth()+1,
  68 + day:thisdate.getDate(),
  69 + week:thisdate.getDay(),
  70 + date:util.unixtoTime(thistimestamp,'YYYY-MM-DD'),
  71 + overdate:thistimestamp<(new Date()/1000)-86400 ? true : false, //日期是否过期
  72 + istoday:false
  73 + }
  74 + //是否是今天
  75 + if(today==thisdayobj.date){
  76 + thisdayobj.istoday=true;
  77 + thisdayobj.mark='今'
  78 + }
  79 + if(util.unixtoTime(new Date()/1000+86400,'YYYY-MM-DD')==thisdayobj.date){
  80 + thisdayobj.mark='明'
  81 + }
  82 + thisdayobj.isselected=this.data.date==thisdayobj.date ? true : false;
  83 + //日期是否选中
  84 + daylist[Math.floor(i/7)].list.push(thisdayobj);
  85 + this.datelist[thisdayobj.date]=Math.floor(i/7)+'-'+(i-Math.floor(i/7)*7)
  86 + }
  87 + this.setData({
  88 + daylist:daylist
  89 + })
  90 + console.log(daylist,this.datelist)
  91 + },
  92 + //获取满房日期
  93 + getFullDate(){
  94 + let parmdata={
  95 + sid:this.data.seller.id,
  96 + type:'week',
  97 + date:this.data.daylist[0].list[0].date
  98 + }
  99 + App.Customer.GetHouseFullDate(parmdata).then((json)=>{
  100 + console.log(json)
  101 + if(json.ret==200){
  102 + if(json.data && json.data.length>0){
  103 + this.markFullHouse(json.data);
  104 + }
  105 + }
  106 + })
  107 + },
  108 + //标记满房
  109 + markFullHouse(fullHouseDate){
  110 + let daylist=this.data.daylist;
  111 + daylist.forEach((v,i)=>{
  112 + v.list.forEach((r,n)=>{
  113 + fullHouseDate.forEach((r1,n1)=>{
  114 + if(r1==r.date){
  115 + r.mark='满'
  116 + }
  117 + })
  118 + })
  119 + })
  120 + this.setData({
  121 + daylist:daylist
  122 + })
  123 + },
  124 + //选择日期
  125 + selectdate(e){
  126 + let _target=e.currentTarget.dataset;
  127 + this.changedatestyle(_target.date);
  128 + this.triggerEvent('selectdate',{date:_target.date,action:'click'});
  129 + this.setData({
  130 + date:_target.date,
  131 + showYearMonth:this.getshowmonth(_target.date)
  132 + })
  133 + },
  134 + //日历组件---通知事件
  135 + tellselectdate(e){
  136 + console.log(e)
  137 + let _target=e.detail;
  138 + this.triggerEvent('selectdate',{date:_target.date,action:'click'});
  139 + this.setData({
  140 + date:_target.date,
  141 + showYearMonth:this.getshowmonth(_target.date)
  142 + })
  143 + if(_target.date in this.datelist){
  144 + this.changedatestyle(_target.date)
  145 + }else{
  146 + this.getdaylist();
  147 + this.getFullDate();
  148 + }
  149 + },
  150 + //修改日期列表
  151 + changedatestyle(selecteddate){
  152 + let daylist=this.data.daylist;
  153 + let prevsingle,previndex,cursingle,curindex;
  154 + daylist.forEach((v,i)=>{
  155 + v.list.forEach((r,n)=>{
  156 + if(r.isselected){
  157 + prevsingle=i;
  158 + previndex=n;
  159 + let prevkey='daylist['+prevsingle+'].list['+previndex+'].isselected';
  160 + this.setData({
  161 + [prevkey]:false,
  162 + })
  163 + }
  164 + if(r.date==selecteddate){
  165 + cursingle=i;
  166 + curindex=n;
  167 + }
  168 + })
  169 + })
  170 + let currentkey='daylist['+cursingle+'].list['+curindex+'].isselected';
  171 + this.setData({
  172 + [currentkey]:true
  173 + })
  174 + },
  175 + clickmore(){
  176 + this.setData({
  177 + hidecalendar:false
  178 + })
  179 + },
  180 + closecalendar(){
  181 + this.setData({
  182 + hidecalendar:true
  183 + })
  184 + }
  185 + }
  186 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 + "calendar":"../calendar/calendar"
  5 + }
  6 +}
  1 +<view class="week-calendar">
  2 + <view class="week-calendar-header flex-lr">
  3 + <view class="week-calendar-header-title week-calendar-header-item black-font font30r Semibold">{{showYearMonth.showyear}}-{{showYearMonth.showmonth<10 ? '0'+showYearMonth.showmonth : showYearMonth.showmonth}}</view>
  4 + <view class="week-calendar-header-more week-calendar-header-item flex-rr" catchtap="clickmore">
  5 + <view class="black-font font24r">更多</view>
  6 + <image class="click-icon" src="/pages/image/click-icon.png"></image>
  7 + </view>
  8 + </view>
  9 + <view class="week-calendar-week flex-lr">
  10 + <block wx:for="{{weeklist}}" wx:key="{{index}}">
  11 + <view class="gray-font font30r Semibold">{{item.weekfont}}</view>
  12 + </block>
  13 + </view>
  14 + <view class="week-calendar-content">
  15 + <block wx:for="{{daylist}}" wx:for-item="itemlist" wx:for-index="indexlist" wx:key="{{indexlist}}">
  16 + <view class="week-calendar-day-list flex-lr">
  17 + <block wx:for="{{itemlist.list}}" wx:key="{{index}}">
  18 + <view class="{{item.overdate ? 'gray-font' : 'font-font'}} font30r Semibold week-calendar-day flex-cc {{item.istoday ? 'today' : ''}} {{item.isselected ? 'bg-yellow white-font' : ''}}" data-date="{{item.date}}" catchtap="{{item.overdate ? '' : 'selectdate'}}">{{item.mark ? item.mark : item.day}}</view>
  19 + </block>
  20 + </view>
  21 + </block>
  22 + </view>
  23 +</view>
  24 +
  25 +<view class="calendar-mask" hidden="{{hidecalendar}}" catchtap="closecalendar"></view>
  26 +<calendar seller="{{seller}}" date="{{date}}" hidecalendar="{{hidecalendar}}" bind:tellselectdate="tellselectdate"></calendar>
  1 +@import "../../../app.wxss";
  2 +.week-calendar{
  3 + width:100%;
  4 + height:336rpx;
  5 + background:#FFFBF2;
  6 + padding:0 40rpx;
  7 + box-sizing: border-box;
  8 +}
  9 +.week-calendar-header, .week-calendar-week{
  10 + width:100%;
  11 + padding:0 20rpx;
  12 + box-sizing: border-box;
  13 +}
  14 +.week-calendar-header-item{
  15 + padding:30rpx 0;
  16 +}
  17 +.week-calendar-content{
  18 + width:100%;
  19 + padding-top:16rpx;
  20 +}
  21 +.week-calendar-day-list{
  22 + width:100%;
  23 + margin-bottom:30rpx;
  24 +}
  25 +.week-calendar-day{
  26 + width:70rpx;
  27 + height:70rpx;
  28 + box-sizing: border-box;
  29 + border-radius:50%;
  30 +}
  31 +.week-calendar-day.today{
  32 + border:2rpx solid #C0A369;
  33 +}
  34 +.week-calendar-day.bg-yellow{
  35 + background: -webkit-linear-gradient(top, #F2D190, #C0A369); /* Safari 5.1 - 6.0 */
  36 + background: -o-linear-gradient(-45deg, #F2D190, #C0A369); /* Opera 11.1 - 12.0 */
  37 + background: -moz-linear-gradient(top, #F2D190, #C0A369); /* Firefox 3.6 - 15 */
  38 + background: linear-gradient(to bottom, #F2D190, #C0A369);
  39 + border-width:0;
  40 +}
  41 +.click-icon{
  42 + width:12rpx;
  43 + height:20rpx;
  44 + padding-left:10rpx;
  45 +}
  46 +.calendar-mask{
  47 + position: fixed;
  48 + left:0;
  49 + right:0;
  50 + top:0;
  51 + bottom:0;
  52 + z-index:10;
  53 + background:rgba(21,20,20,.5);
  54 +}
@@ -273,6 +273,15 @@ Page({ @@ -273,6 +273,15 @@ Page({
273 273
274 } 274 }
275 }, 275 },
  276 + //时段改变
  277 + selectsection(e){
  278 + console.log(e);
  279 + this.setData({
  280 + reserveSection:e.detail.section
  281 + })
  282 + this.reserve.section=e.detail.section;
  283 + this.reserve.time=e.detail.time;
  284 + },
276 selecttime(e){//时间改变 285 selecttime(e){//时间改变
277 console.log(e); 286 console.log(e);
278 if(!e.detail.time){//满房 287 if(!e.detail.time){//满房
@@ -14,6 +14,8 @@ @@ -14,6 +14,8 @@
14 "share":"/components/reserve/share/share", 14 "share":"/components/reserve/share/share",
15 "people":"/components/reserve/people/people", 15 "people":"/components/reserve/people/people",
16 "dur":"/components/reserve/dur/dur", 16 "dur":"/components/reserve/dur/dur",
17 - "calendar":"/components/reserve/calendar/calendar" 17 + "calendar":"/components/reserve/week-calendar/week-calendar",
  18 + "section":"/components/reserve/section/section",
  19 + "select-room":"/components/reserve/select-room/select-room"
18 } 20 }
19 } 21 }
@@ -212,10 +212,9 @@ @@ -212,10 +212,9 @@
212 <view hidden="{{activeTab!='reserve'}}" wx:if="{{seller.id}}"> 212 <view hidden="{{activeTab!='reserve'}}" wx:if="{{seller.id}}">
213 <view class="olreserve bg_white"> 213 <view class="olreserve bg_white">
214 <calendar seller="{{seller}}" bindselectdate="selectdate"></calendar> 214 <calendar seller="{{seller}}" bindselectdate="selectdate"></calendar>
215 - <people seller="{{seller}}" bindselectpeople="selectpeople" wx:if="{{!hasFullHouse}}"></people>  
216 - <view class="reserve-time Semibold">可订时间</view>  
217 - <dur seller="{{seller}}" wx:if="{{!hasFullHouse}}"  
218 - date="{{reserveDate}}" bindselecttime="selecttime"></dur> 215 + <view class="reserve-time Semibold">预订时段</view>
  216 + <section seller="{{seller}}" date="{{reserveDate}}" bindselectsection="selectsection"></section>
  217 + <select-room seller="{{seller}}" date="{{reserveDate}}" section="{{reserveSection}}"></select-room>
219 <view class="hasFullHouse Semibold flex-vc" wx:if="{{hasFullHouse}}">{{fullHouseMsg}}</view> 218 <view class="hasFullHouse Semibold flex-vc" wx:if="{{hasFullHouse}}">{{fullHouseMsg}}</view>
220 </view> 219 </view>
221 </view> 220 </view>
@@ -511,7 +511,7 @@ @@ -511,7 +511,7 @@
511 padding-bottom: 0rpx; 511 padding-bottom: 0rpx;
512 } 512 }
513 .reserve-time{ 513 .reserve-time{
514 - padding: 60rpx 0 38rpx 30rpx; 514 + padding: 40rpx 0 30rpx 30rpx;
515 font-size: 32rpx; 515 font-size: 32rpx;
516 } 516 }
517 .hasFullHouse{ 517 .hasFullHouse{
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 "list": [] 45 "list": []
46 }, 46 },
47 "miniprogram": { 47 "miniprogram": {
48 - "current": 54, 48 + "current": 56,
49 "list": [ 49 "list": [
50 { 50 {
51 "id": 0, 51 "id": 0,