cook-class.js 1.11 KB
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
        })
      },
    }
})