cook-class.js
1.11 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
Component({
properties:{
cooklist:Array,
hasListModel:{
type:Boolean,
value:false
},
},
data:{
menuHidden:true,
activeMenuID:'',
},
attached(){
let obj={
menuHidden:!this.data.hasListModel,
};
this.setData(obj)
},
methods:{
changeList:function(e){
var _target=e.currentTarget.dataset;
console.log(_target);
this.setData({
activeMenuID:_target.id
})
this.triggerEvent("changeList",_target);
if(!this.data.hasListModel){
this.close();
}
},
show:function(){
let obj={
menuHidden:false
};
if(!this.data.activeMenuID){
obj.activeMenuID=this.data.cooklist[0].id||'';
}
this.setData(obj)
},
close:function () {
this.setData({
menuHidden:true
})
},
activeMenuID(id){
this.setData({
activeMenuID:id
})
},
}
})