calendar.js
2.04 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
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();
},
ready(){
this.triggerEvent('selectdate',{date:this.data.date,action:'defalut'})
},
methods:{
//默认标记特殊日期
getspeciallist(){
let speciallist = [
{date: util.unixtoTime(date/1000, 'YYYY-MM-DD'), background: '', text: '今'},
{date: util.unixtoTime(date + 86400, 'YYYY-MM-DD'), background: '', text: '明'}
];
this.setData({
speciallist:speciallist
})
},
//根据指定年份月份获取当月满房的日期
gethousefulldate(){
let parmdata={
sid:this.data.seller.id,
date:this.data.date
}
App.Customer.GetHouseFullDate(parmdata).then((json)=>{
console.log(json)
if(json.ret==200){
if(json.data.length>0){
this.changespeciallist(json.data)
}
}
})
},
//修改标记特殊日期
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)
}
})
this.setData({
speciallist:newspeciallist
})
},
//下一月
nextMonth(e){
this.setData({
nextNum:this.data.nextNum+1
})
},
//上一月
prevMonth(e){
this.setData({
nextNum:this.data.nextNum-1
})
},
//点击日期
selectDate(e){
this.setData({
date:e.detail.date
})
this.triggerEvent('selectdate',{date:this.data.date,action:'click'})
}
}
})