|
...
|
...
|
@@ -7,168 +7,249 @@ Component({ |
|
|
|
date:{
|
|
|
|
type:String,
|
|
|
|
value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
|
|
|
|
},
|
|
|
|
hidecalendar:{
|
|
|
|
type:Boolean,
|
|
|
|
value:true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
curYear: new Date().getFullYear(), // 年份
|
|
|
|
curMonth: new Date().getMonth() + 1,// 月份 1-12
|
|
|
|
day:new Date().getDate(),
|
|
|
|
header_show: true, // 主标题是否显示
|
|
|
|
next: true, // 下一个月按钮是否显示
|
|
|
|
closelaststyle:true,
|
|
|
|
speciallist: [],
|
|
|
|
nextNum:0,
|
|
|
|
showprev:false
|
|
|
|
},
|
|
|
|
observers: {
|
|
|
|
'seller,date': function(seller,newdate) {
|
|
|
|
if(seller && newdate!=''){
|
|
|
|
let showYearMonth=this.getshowmonth();
|
|
|
|
if(this.data.showYearMonth){ //周历点击
|
|
|
|
if(showYearMonth.showyear==this.data.showYearMonth.showyear && showYearMonth.showmonth==this.data.showYearMonth.showmonth){
|
|
|
|
this.changedatestyle(newdate);
|
|
|
|
}else{
|
|
|
|
this.setData({
|
|
|
|
showYearMonth:showYearMonth,
|
|
|
|
showprev:this.isShowPrev(showYearMonth)
|
|
|
|
})
|
|
|
|
this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
|
|
|
|
// this.gethousefulldate(seller);
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
//初始化---默认
|
|
|
|
this.setData({
|
|
|
|
showYearMonth:showYearMonth,
|
|
|
|
showprev:this.isShowPrev(showYearMonth)
|
|
|
|
})
|
|
|
|
this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
|
|
|
|
// this.gethousefulldate(seller);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
},
|
|
|
|
attached(){
|
|
|
|
//默认标记特殊日期
|
|
|
|
this.getspeciallist();
|
|
|
|
this.gethousefulldate(this.data.curYear,this.data.curMonth,'defalut');
|
|
|
|
this.getweeklist();
|
|
|
|
},
|
|
|
|
ready(){
|
|
|
|
},
|
|
|
|
detached(){
|
|
|
|
console.log('在组件实例被从页面节点树移除时执行')
|
|
|
|
},
|
|
|
|
//测试
|
|
|
|
pageLifetimes: {
|
|
|
|
show(){
|
|
|
|
//日期改变重新标记
|
|
|
|
if(this.data.speciallist.date!=util.unixtoTime(new Date()/1000, 'YYYY-MM-DD')){
|
|
|
|
this.getspeciallist();
|
|
|
|
this.setData({
|
|
|
|
curYear: new Date().getFullYear(), // 年份
|
|
|
|
curMonth: new Date().getMonth() + 1,// 月份 1-12
|
|
|
|
day:new Date().getDate(),
|
|
|
|
})
|
|
|
|
methods:{
|
|
|
|
//获取当前选中日期
|
|
|
|
getshowmonth(){
|
|
|
|
let datearr=this.data.date.split('-');
|
|
|
|
return{
|
|
|
|
showyear:Number(datearr[0]),
|
|
|
|
showmonth:Number(datearr[1]),
|
|
|
|
}
|
|
|
|
console.log(this.data.date,new Date());
|
|
|
|
},
|
|
|
|
hide(){
|
|
|
|
console.log(this.data.date);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods:{
|
|
|
|
//默认标记特殊日期
|
|
|
|
getspeciallist(){
|
|
|
|
let speciallist = [
|
|
|
|
{date: util.unixtoTime(new Date()/1000, 'YYYY-MM-DD'), background: '', text: '今'},
|
|
|
|
{date: util.unixtoTime(new Date()/1000 + 86400, 'YYYY-MM-DD'), background: '', text: '明'}
|
|
|
|
];
|
|
|
|
//获得周列表
|
|
|
|
getweeklist(){
|
|
|
|
let week=['日','一','二','三','四','五','六'];
|
|
|
|
let weeklist=[];
|
|
|
|
for(let i=0;i<week.length;i++){
|
|
|
|
weeklist.push({
|
|
|
|
weekfont:week[i],
|
|
|
|
weeknum:i
|
|
|
|
})
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
speciallist:speciallist
|
|
|
|
weeklist:weeklist,
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//根据指定年份月份获取当月满房的日期
|
|
|
|
gethousefulldate(year,month,action){
|
|
|
|
let parmdata={
|
|
|
|
sid:this.data.seller.id,
|
|
|
|
date:year+'-'+month
|
|
|
|
//获取显示月份天数
|
|
|
|
getMonthdays(year,month){
|
|
|
|
var d = new Date(year,month,0);
|
|
|
|
return d.getDate();
|
|
|
|
},
|
|
|
|
//获取某一天是星期几
|
|
|
|
getdayweek:function(year,month,day){
|
|
|
|
var tmpdate=new Date(year,month,day);
|
|
|
|
return tmpdate.getDay()
|
|
|
|
},
|
|
|
|
//获取当月日期
|
|
|
|
getdayslist(year,month){
|
|
|
|
this.today={
|
|
|
|
curdate:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
|
|
|
|
curtimestamp:new Date()/1000
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
//当前显示月份天数
|
|
|
|
let monthdays=this.getMonthdays(year,month);
|
|
|
|
//当前月1号星期几
|
|
|
|
let dayweek=this.getdayweek(year,month,1);
|
|
|
|
let daylist=[];
|
|
|
|
//多少行
|
|
|
|
let singlelen=Math.ceil((monthdays+dayweek)/7);
|
|
|
|
for(let i=0;i<singlelen;i++){
|
|
|
|
daylist.push({
|
|
|
|
list:[]
|
|
|
|
})
|
|
|
|
}
|
|
|
|
//本月日期
|
|
|
|
for(let i=0;i<singlelen*7;i++){
|
|
|
|
let thisdayobj={};
|
|
|
|
if(i>=dayweek && i<monthdays+dayweek){
|
|
|
|
let thisday=i-dayweek+1;
|
|
|
|
let thisdate=year+'-'+(month<10 ? '0'+month : month)+'-'+(thisday<10 ? '0'+thisday : thisday);
|
|
|
|
let thistimestamp=Number(util.timetouUnix(thisdate,'-'));
|
|
|
|
thisdayobj={
|
|
|
|
year:year,
|
|
|
|
month:month,
|
|
|
|
day:thisday,
|
|
|
|
week:i%7,
|
|
|
|
date:thisdate,
|
|
|
|
istoday:false,
|
|
|
|
overdate:thistimestamp<(new Date()/1000)-86400 ? true : false, //日期是否过期,
|
|
|
|
}
|
|
|
|
if(json.data.length>0){
|
|
|
|
this.changespeciallist(json.data)
|
|
|
|
if(thisdate==this.today.curdate){
|
|
|
|
thisdayobj.istoday=true;
|
|
|
|
thisdayobj.mark='今'
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//不可预订
|
|
|
|
if(json.ret==401){
|
|
|
|
if(action=='defalut'){
|
|
|
|
this.houseFullDate=null
|
|
|
|
this.triggerEvent('selectdate',obj);
|
|
|
|
obj.action=401;
|
|
|
|
this.triggerEvent('selectdate',obj);
|
|
|
|
|
|
|
|
}
|
|
|
|
if(util.unixtoTime(this.today.curtimestamp+86400,'YYYY-MM-DD')==thisdate){
|
|
|
|
thisdayobj.mark='明'
|
|
|
|
}
|
|
|
|
|
|
|
|
thisdayobj.isselected=this.data.date==thisdate ? true : false;
|
|
|
|
}
|
|
|
|
daylist[Math.floor(i/7)].list.push(thisdayobj)
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
daylist:daylist
|
|
|
|
})
|
|
|
|
console.log(daylist)
|
|
|
|
},
|
|
|
|
//修改标记特殊日期
|
|
|
|
changespeciallist(houseFullDate){
|
|
|
|
let speciallist=this.data.speciallist;
|
|
|
|
let newspeciallist=[];
|
|
|
|
houseFullDate.forEach((v,i)=>{
|
|
|
|
newspeciallist.push({
|
|
|
|
date:v,
|
|
|
|
background:'',
|
|
|
|
text:'满'
|
|
|
|
//选择日期
|
|
|
|
selectdate(e){
|
|
|
|
let _target=e.currentTarget.dataset;
|
|
|
|
this.changedatestyle(_target.date);
|
|
|
|
this.triggerEvent('tellselectdate',{date:_target.date,action:'click'});
|
|
|
|
},
|
|
|
|
//修改日期列表
|
|
|
|
changedatestyle(selecteddate){
|
|
|
|
let daylist=this.data.daylist;
|
|
|
|
let prevsingle,previndex,cursingle,curindex;
|
|
|
|
daylist.forEach((v,i)=>{
|
|
|
|
v.list.forEach((r,n)=>{
|
|
|
|
if(r.isselected){
|
|
|
|
prevsingle=i;
|
|
|
|
previndex=n;
|
|
|
|
let prevkey='daylist['+prevsingle+'].list['+previndex+'].isselected';
|
|
|
|
this.setData({
|
|
|
|
[prevkey]:false,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
if(r.date==selecteddate){
|
|
|
|
cursingle=i;
|
|
|
|
curindex=n;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
speciallist.forEach((v,i)=>{
|
|
|
|
if(houseFullDate.indexOf(v.date)==-1){
|
|
|
|
newspeciallist.push(v)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
console.log(newspeciallist)
|
|
|
|
let currentkey='daylist['+cursingle+'].list['+curindex+'].isselected';
|
|
|
|
this.setData({
|
|
|
|
speciallist:newspeciallist
|
|
|
|
[currentkey]:true
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//下一月
|
|
|
|
nextMonth(e){
|
|
|
|
console.log(e)
|
|
|
|
this.gethousefulldate(e.detail.currentYear,e.detail.currentMonth,'click');
|
|
|
|
this.setData({
|
|
|
|
nextNum:this.data.nextNum+1
|
|
|
|
})
|
|
|
|
//计算是否显示prev
|
|
|
|
isShowPrev(showYearMonth){
|
|
|
|
let curyear=new Date().getFullYear();
|
|
|
|
let curmonth=new Date().getMonth() + 1;
|
|
|
|
let curtitle=''+curyear+(curmonth<10 ? '0'+curmonth : curmonth);
|
|
|
|
let showtitle=''+showYearMonth.showyear+(showYearMonth.showmonth< 10 ? '0'+showYearMonth.showmonth : showYearMonth.showmonth)
|
|
|
|
return Number(showtitle)>Number(curtitle);
|
|
|
|
},
|
|
|
|
//上一月
|
|
|
|
prevMonth(e){
|
|
|
|
this.gethousefulldate(e.detail.currentYear,e.detail.currentMonth,'click');
|
|
|
|
//回退月份
|
|
|
|
prevmonth(){
|
|
|
|
var showyear=this.data.showYearMonth.showyear;
|
|
|
|
var showmonth=this.data.showYearMonth.showmonth;
|
|
|
|
if(showmonth==1){
|
|
|
|
showmonth=12;
|
|
|
|
showyear=showyear-1;
|
|
|
|
}else{
|
|
|
|
showmonth-=1;
|
|
|
|
}
|
|
|
|
let showYearMonth={
|
|
|
|
showyear:showyear,
|
|
|
|
showmonth:showmonth
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
nextNum:this.data.nextNum-1
|
|
|
|
showYearMonth:showYearMonth,
|
|
|
|
showprev:this.isShowPrev(showYearMonth)
|
|
|
|
})
|
|
|
|
this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
|
|
|
|
this.gethousefulldate(this.data.seller);
|
|
|
|
},
|
|
|
|
//点击日期
|
|
|
|
selectDate(e){
|
|
|
|
//推前月份
|
|
|
|
nextmonth(){
|
|
|
|
var showyear=this.data.showYearMonth.showyear;
|
|
|
|
var showmonth=this.data.showYearMonth.showmonth;
|
|
|
|
if(showmonth==12){
|
|
|
|
showmonth=1;
|
|
|
|
showyear=showyear+1;
|
|
|
|
}else{
|
|
|
|
showmonth+=1;
|
|
|
|
}
|
|
|
|
let showYearMonth={
|
|
|
|
showyear:showyear,
|
|
|
|
showmonth:showmonth
|
|
|
|
}
|
|
|
|
this.setData({
|
|
|
|
date:e.detail.date
|
|
|
|
showYearMonth:showYearMonth,
|
|
|
|
showprev:this.isShowPrev(showYearMonth)
|
|
|
|
})
|
|
|
|
let obj={
|
|
|
|
date:this.data.date,
|
|
|
|
action:'click',
|
|
|
|
this.getdayslist(showYearMonth.showyear,showYearMonth.showmonth);
|
|
|
|
this.gethousefulldate(this.data.seller);
|
|
|
|
},
|
|
|
|
//根据指定年份月份获取当月满房的日期
|
|
|
|
gethousefulldate(seller){
|
|
|
|
let showYearMonth=this.data.showYearMonth;
|
|
|
|
let parmdata={
|
|
|
|
sid:seller.id,
|
|
|
|
type:'month',
|
|
|
|
date:showYearMonth.showyear+'-'+(showYearMonth.showmonth<10 ? '0'+showYearMonth.showmonth : showYearMonth.showmonth)
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
App.Customer.GetHouseFullDate(parmdata).then((json)=>{
|
|
|
|
console.log(json)
|
|
|
|
if(json.ret==200){
|
|
|
|
if(json.data && json.data.length>0){
|
|
|
|
this.markFullHouse(json.data);
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//标记满房
|
|
|
|
markFullHouse(fullHouseDate){
|
|
|
|
let daylist=this.data.daylist;
|
|
|
|
daylist.forEach((v,i)=>{
|
|
|
|
v.list.forEach((r,n)=>{
|
|
|
|
fullHouseDate.forEach((r1,n1)=>{
|
|
|
|
if(r1==r.date){
|
|
|
|
r.mark='满'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|
|
|
|
this.setData({
|
|
|
|
daylist:daylist
|
|
|
|
})
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|