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