|
|
|
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'),
|
|
|
|
value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
|
|
|
|
}
|
|
|
|
},
|
|
|
|
data: {
|
|
|
|
curYear: date.getFullYear(), // 年份
|
|
|
|
curMonth: date.getMonth() + 1,// 月份 1-12
|
|
|
|
day:date.getDate(),
|
|
|
|
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,
|
|
|
|
},
|
|
|
|
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
|
|
|
|
attached(){
|
|
|
|
//默认标记特殊日期
|
|
|
|
this.getspeciallist();
|
|
|
|
this.gethousefulldate(this.data.curYear,this.data.curMonth,'defalut');
|
|
|
|
},
|
|
|
|
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(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
console.log(this.data.date,new Date());
|
|
|
|
},
|
|
|
|
hide(){
|
|
|
|
console.log(this.data.date);
|
|
|
|
}
|
|
|
|
App.Customer.GetHouseFullDate(parmdata).then((json)=>{
|
|
|
|
console.log(json)
|
|
|
|
let obj={
|
|
|
|
date:this.data.date,
|
|
|
|
action:'defalut',
|
|
|
|
overdate:0,
|
|
|
|
},
|
|
|
|
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: '明'}
|
|
|
|
];
|
|
|
|
this.setData({
|
|
|
|
speciallist:speciallist
|
|
|
|
})
|
|
|
|
},
|
|
|
|
//根据指定年份月份获取当月满房的日期
|
|
|
|
gethousefulldate(year,month,action){
|
|
|
|
let parmdata={
|
|
|
|
sid:this.data.seller.id,
|
|
|
|
date:year+'-'+month
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
App.Customer.GetHouseFullDate(parmdata).then((json)=>{
|
|
|
|
console.log(json)
|
|
|
|
let obj={
|
|
|
|
date:this.data.date,
|
|
|
|
action:'defalut',
|
|
|
|
overdate:0,
|
|
|
|
}
|
|
|
|
|
|
|
|
}else{
|
|
|
|
//不可预订
|
|
|
|
if(json.ret==401){
|
|
|
|
if(json.ret==200){
|
|
|
|
this.houseFullDate=json.data;
|
|
|
|
//默认
|
|
|
|
if(action=='defalut'){
|
|
|
|
this.houseFullDate=null
|
|
|
|
this.triggerEvent('selectdate',obj);
|
|
|
|
obj.action=401;
|
|
|
|
this.triggerEvent('selectdate',obj);
|
|
|
|
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)
|
|
|
|
},
|
|
|
|
//修改标记特殊日期
|
|
|
|
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',
|
|
|
|
}
|
|
|
|
})
|
|
|
|
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{ //满房
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
this.triggerEvent('selectdate',obj)
|
|
|
|
}else{
|
|
|
|
//不可预订
|
|
|
|
}else{ //overdate为1过期日期
|
|
|
|
obj.overdate=1;
|
|
|
|
obj.houseFullStatus=1;
|
|
|
|
this.triggerEvent('selectdate',obj);
|
|
|
|
obj.action=401
|
|
|
|
this.triggerEvent('selectdate',obj);
|
|
|
|
this.triggerEvent('selectdate',obj)
|
|
|
|
}
|
|
|
|
}else{ //overdate为1过期日期
|
|
|
|
obj.overdate=1;
|
|
|
|
obj.houseFullStatus=1;
|
|
|
|
this.triggerEvent('selectdate',obj)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|