online-calendar.js 1.54 KB
import util from '../../../utils/util';
import App from '../../../utils/api';
Component({
	properties:{
		seller:Object,
		date:{
			type:String,
			value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD'),
		},
	},
	data:{
		marklist:[]
	},
	attached(){

	},
	observers:{
		'seller'(newseller){
			if(newseller){
				this.showYearMonth=this.getshowmonth();
				console.log(newseller,this.showYearMonth);
				this.gethousefulldate(newseller,this.showYearMonth)
			}
		}
	},
	methods:{
		//获取当前选中日期
		getshowmonth(){
			let datearr=this.data.date.split('-');
			return{
				showyear:Number(datearr[0]),
				showmonth:Number(datearr[1]),
			}
		},
		//切换月份
		getmonth(e){
			console.log('tellmonth',e)
			this.showYearMonth=e.detail;
			if(e.detail.action='click'){
				this.gethousefulldate(this.data.seller,this.showYearMonth)
			}
		},
		//根据指定年份月份获取当月满房的日期
		gethousefulldate(seller,showYearMonth){
			let parmdata={
				sid:seller.id,
				type:'month',
				date:showYearMonth.showyear+'-'+(showYearMonth.showmonth<10 ? '0'+showYearMonth.showmonth : showYearMonth.showmonth)
			}
			App.Customer.GetHouseFullDate(parmdata).then((json)=>{
				console.log(json)
				if(json.ret==200){
					if(json.data && json.data.length>0){
						let marklist=[];
						json.data.forEach((v,i)=>{
							marklist.push({
								date:v,
								mark:'满'
							})
						})
						this.setData({
							marklist:marklist
						})
					}
					
				}
			})
		},
		tellselectdate(e){
			this.triggerEvent('tellselectdate',e.detail);
		}
	}
})