Commit 91b928a44c3ea647d63c890ef839f5265d9369ca

Authored by vking
2 parents 571c135e 2ec8fc4f

Merge remote-tracking branch 'origin/master'

1 import util from '../../../utils/util'; 1 import util from '../../../utils/util';
2 import App from '../../../utils/api'; 2 import App from '../../../utils/api';
3 -let date=new Date();  
4 Component({ 3 Component({
5 properties:{ 4 properties:{
6 seller:Object, 5 seller:Object,
7 //选中日期 6 //选中日期
8 date:{ 7 date:{
9 type:String, 8 type:String,
10 - value:util.unixtoTime(date/1000,'YYYY-MM-DD'), 9 + value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
11 } 10 }
12 }, 11 },
13 data: { 12 data: {
14 - curYear: date.getFullYear(), // 年份  
15 - curMonth: date.getMonth() + 1,// 月份 1-12  
16 - day:date.getDate(), 13 + curYear: new Date().getFullYear(), // 年份
  14 + curMonth: new Date().getMonth() + 1,// 月份 1-12
  15 + day:new Date().getDate(),
17 header_show: true, // 主标题是否显示 16 header_show: true, // 主标题是否显示
18 next: true, // 下一个月按钮是否显示 17 next: true, // 下一个月按钮是否显示
19 closelaststyle:true, 18 closelaststyle:true,
20 speciallist: [], 19 speciallist: [],
21 nextNum:0, 20 nextNum:0,
22 - },  
23 - attached(){  
24 - //默认标记特殊日期  
25 - this.getspeciallist();  
26 - this.gethousefulldate(this.data.curYear,this.data.curMonth,'defalut');  
27 - },  
28 - ready(){  
29 - },  
30 - methods:{  
31 - //默认标记特殊日期  
32 - getspeciallist(){  
33 - let speciallist = [  
34 - {date: util.unixtoTime(date/1000, 'YYYY-MM-DD'), background: '', text: '今'},  
35 - {date: util.unixtoTime(date/1000 + 86400, 'YYYY-MM-DD'), background: '', text: '明'}  
36 - ];  
37 - this.setData({  
38 - speciallist:speciallist  
39 - })  
40 }, 21 },
41 - //根据指定年份月份获取当月满房的日期  
42 - gethousefulldate(year,month,action){  
43 - let parmdata={  
44 - sid:this.data.seller.id,  
45 - date:year+'-'+month 22 + attached(){
  23 + //默认标记特殊日期
  24 + this.getspeciallist();
  25 + this.gethousefulldate(this.data.curYear,this.data.curMonth,'defalut');
  26 + },
  27 + ready(){
  28 + },
  29 + detached(){
  30 + console.log('在组件实例被从页面节点树移除时执行')
  31 + },
  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 + })
  43 + }
  44 + console.log(this.data.date,new Date());
  45 + },
  46 + hide(){
  47 + console.log(this.data.date);
46 } 48 }
47 - App.Customer.GetHouseFullDate(parmdata).then((json)=>{  
48 - console.log(json)  
49 - let obj={  
50 - date:this.data.date,  
51 - action:'defalut',  
52 - overdate:0, 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 + ];
  57 + this.setData({
  58 + speciallist:speciallist
  59 + })
  60 + },
  61 + //根据指定年份月份获取当月满房的日期
  62 + gethousefulldate(year,month,action){
  63 + let parmdata={
  64 + sid:this.data.seller.id,
  65 + date:year+'-'+month
53 } 66 }
54 - if(json.ret==200){  
55 - this.houseFullDate=json.data;  
56 - //默认  
57 - if(action=='defalut'){  
58 - if(this.houseFullDate.indexOf(this.data.date)==-1){  
59 - obj.houseFullStatus=0;  
60 - }else{ //满房  
61 - obj.houseFullStatus=1;  
62 - }  
63 - this.triggerEvent('selectdate',obj)  
64 - }  
65 - if(json.data.length>0){  
66 - this.changespeciallist(json.data) 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,
67 } 73 }
68 -  
69 - }else{  
70 - //不可预订  
71 - if(json.ret==401){ 74 + if(json.ret==200){
  75 + this.houseFullDate=json.data;
  76 + //默认
72 if(action=='defalut'){ 77 if(action=='defalut'){
73 - this.houseFullDate=null  
74 - this.triggerEvent('selectdate',obj);  
75 - obj.action=401;  
76 - this.triggerEvent('selectdate',obj); 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)
  84 + }
  85 + if(json.data.length>0){
  86 + this.changespeciallist(json.data)
  87 + }
  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);
77 97
  98 + }
78 } 99 }
  100 +
79 } 101 }
80 -  
81 - }  
82 - })  
83 - },  
84 - //修改标记特殊日期  
85 - changespeciallist(houseFullDate){  
86 - let speciallist=this.data.speciallist;  
87 - let newspeciallist=[];  
88 - houseFullDate.forEach((v,i)=>{  
89 - newspeciallist.push({  
90 - date:v,  
91 - background:'',  
92 - text:'满'  
93 }) 102 })
94 - })  
95 - speciallist.forEach((v,i)=>{  
96 - if(houseFullDate.indexOf(v.date)==-1){  
97 - newspeciallist.push(v) 103 + },
  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:'满'
  113 + })
  114 + })
  115 + speciallist.forEach((v,i)=>{
  116 + if(houseFullDate.indexOf(v.date)==-1){
  117 + newspeciallist.push(v)
  118 + }
  119 + })
  120 + console.log(newspeciallist)
  121 + this.setData({
  122 + speciallist:newspeciallist
  123 + })
  124 + },
  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 + })
  132 + },
  133 + //上一月
  134 + prevMonth(e){
  135 + this.gethousefulldate(e.detail.currentYear,e.detail.currentMonth,'click');
  136 + this.setData({
  137 + nextNum:this.data.nextNum-1
  138 + })
  139 + },
  140 + //点击日期
  141 + selectDate(e){
  142 + this.setData({
  143 + date:e.detail.date
  144 + })
  145 + let obj={
  146 + date:this.data.date,
  147 + action:'click',
98 } 148 }
99 - })  
100 - console.log(newspeciallist)  
101 - this.setData({  
102 - speciallist:newspeciallist  
103 - })  
104 - },  
105 - //下一月  
106 - nextMonth(e){  
107 - console.log(e)  
108 - this.gethousefulldate(e.detail.currentYear,e.detail.currentMonth,'click');  
109 - this.setData({  
110 - nextNum:this.data.nextNum+1  
111 - })  
112 - },  
113 - //上一月  
114 - prevMonth(e){  
115 - this.gethousefulldate(e.detail.currentYear,e.detail.currentMonth,'click');  
116 - this.setData({  
117 - nextNum:this.data.nextNum-1  
118 - })  
119 - },  
120 - //点击日期  
121 - selectDate(e){  
122 - this.setData({  
123 - date:e.detail.date  
124 - })  
125 - let obj={  
126 - date:this.data.date,  
127 - action:'click',  
128 - }  
129 - if(Number(util.timetouUnix(this.data.date,'-'))-new Date()/1000>=-24*60*60){ //今天以及之后日期  
130 - obj.overdate=0;  
131 - //可预订  
132 - if(this.houseFullDate){  
133 - if(this.houseFullDate.indexOf(this.data.date)==-1){  
134 - obj.houseFullStatus=0;  
135 - }else{ //满房 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;
  157 + }
  158 + this.triggerEvent('selectdate',obj)
  159 + }else{
  160 + //不可预订
136 obj.houseFullStatus=1; 161 obj.houseFullStatus=1;
  162 + this.triggerEvent('selectdate',obj);
  163 + obj.action=401
  164 + this.triggerEvent('selectdate',obj);
137 } 165 }
138 - this.triggerEvent('selectdate',obj)  
139 - }else{  
140 - //不可预订 166 + }else{ //overdate为1过期日期
  167 + obj.overdate=1;
141 obj.houseFullStatus=1; 168 obj.houseFullStatus=1;
142 - this.triggerEvent('selectdate',obj);  
143 - obj.action=401  
144 - this.triggerEvent('selectdate',obj); 169 + this.triggerEvent('selectdate',obj)
145 } 170 }
146 - }else{ //overdate为1过期日期  
147 - obj.overdate=1;  
148 - obj.houseFullStatus=1;  
149 - this.triggerEvent('selectdate',obj)  
150 } 171 }
151 - }  
152 - } 172 + }
153 173
154 }) 174 })
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 cur-year="{{curYear}}" 2 cur-year="{{curYear}}"
3 cur-month="{{curMonth}}" 3 cur-month="{{curMonth}}"
4 day="{{day}}" 4 day="{{day}}"
5 -selectedDate="{{date}}"  
6 header_show='{{header_show}}' 5 header_show='{{header_show}}'
7 prev='{{nextNum}}' 6 prev='{{nextNum}}'
8 next='{{next}}' 7 next='{{next}}'
@@ -28,6 +28,7 @@ Component({ @@ -28,6 +28,7 @@ Component({
28 'date': function(newdate) { 28 'date': function(newdate) {
29 if(newdate!=''){ 29 if(newdate!=''){
30 this.setData({ 30 this.setData({
  31 + current:0,
31 durlist:[] 32 durlist:[]
32 }) 33 })
33 this.getroombydate(); 34 this.getroombydate();
@@ -210,7 +210,7 @@ @@ -210,7 +210,7 @@
210 <share id="share" seller_id="{{seller.id}}"></share> 210 <share id="share" seller_id="{{seller.id}}"></share>
211 </view> 211 </view>
212 <view hidden="{{activeTab!='reserve'}}" wx:if="{{seller.id}}"> 212 <view hidden="{{activeTab!='reserve'}}" wx:if="{{seller.id}}">
213 - <view class="olreserve"> 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> 215 <people seller="{{seller}}" bindselectpeople="selectpeople" wx:if="{{!hasFullHouse}}"></people>
216 <view class="reserve-time Semibold">可订时间</view> 216 <view class="reserve-time Semibold">可订时间</view>