select-room.js 1.35 KB
import App from '../../../utils/api';
import util from '../../../utils/util';
Component({
	properties:{
		seller:Object,
		date:{
			type:String,
			value:util.unixtoTime(new Date()/1000,'YYYY-MM-DD')
		},
		section:String,
	},
	data:{
		seletroomlist:[]
	},
	attached(){
		this.room=this.selectComponent('#room');
		console.log('xxxxx',this.data.seller);
	},
	observers: {
		'date,section': function(newdate,newsection) {
			console.log('room',newdate,newsection)
			if(newdate && newsection){
				if(this.date && this.section){
					if(newdate!=this.date || this.section!=newsection){
						this.setData({
							seletroomlist:[]
						})
						this.date=newdate;
						this.section=newsection;
					}
				}else{
					this.date=newdate;
					this.section=newsection;
				}
				
			}
		}
	},
	methods:{
		selectroom(e){
			console.log(e)
			let _target=e.detail;
			let seletroomlist=this.data.seletroomlist;
			seletroomlist.push(_target);
			this.setData({
				seletroomlist:this.data.seletroomlist
			})
			this.triggerEvent('changeroom',{selectroom:this.data.seletroomlist})
		},
		cancelroom(e){
			let _target=e.currentTarget.dataset;
			this.data.seletroomlist.splice(_target.index,1);
			this.setData({
				seletroomlist:this.data.seletroomlist
			})
			this.room.cancelroom(_target.id);
			this.triggerEvent('changeroom',{selectroom:this.data.seletroomlist});
		}
	}
})