select-room.js
1.35 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
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});
}
}
})