select-room.js
1.17 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
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,
seletroomlist:{
type:Array,
value:[]
}
},
data:{
},
attached(){
this.room=this.selectComponent('#room');
console.log('xxxxx',this.data.seller);
},
methods:{
selectroom(e){
console.log(e)
let _target=e.detail;
let seletroomlist=this.data.seletroomlist;
if(e.detail.action=='cancel'){
seletroomlist.forEach((v,i)=>{
if(v.id==_target.id){
seletroomlist.splice(i,1)
}
})
}else{
let obj={
id:_target.id,
name:_target.name
}
seletroomlist.push(obj);
}
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});
},
}
})