{
    template:'${tmpl}',
    data:function(){
        return {
          apps:null,
          bubbles:['x','y','x','y','x','y','x','y','x','y'],
          pxheight:"800px",
          myapps:[],
          carisshow:false,
        }
    },
    mounted:function(){
      this.initApps();
      this.pxheight=(this.$root.stageHeight-60)+"px";
      this.myapps=tocompanyinfo?tocompanyinfo.apps:[];
      $("#buycar").hide();
      if(this.currentUser && this.currentUser.roles.indexOf("common")>=0){
        this.showcar();
      }
    },
    created:function(){
     
    },
    computed: {
      inUseStr: function () {
        if(this.myapps && this.myapps.length>=1){
              return this.myapps.map((app)=>{
                return app.id;
          }).join(",");
        }else{
          return "";
        }

      }
    },
    methods:{
       async goapplogin(app){
          var d=  await this.$root.postReq("/web/auth/userCtl/goLoginForApp",app);
          if(d && d.status==0 && d.data){
            console.log(JSON.stringify(d.data));
            window.open(d.data.jumpUrl);
          }else{
   
          }
        },
        showcar(){
          if(this.carisshow){
            $("#buycar").fadeOut(1500);
            this.carisshow=false;
          }else{
            $("#buycar").fadeIn(1500);
            this.carisshow=true;
          }
        },
        async buy(app){
          if(app.inUse){
            return;
          }
          if(!tocompanyinfo){
            this.$alert("请先选择要采购APP的租户公司");
            return false;
          }
          var d=  await this.$root.postReq("/web/common/companyCtl/buyApp",app);
          if(d && d.status==0 && d.data){
            this.myapps=d.data;
            this.initInUse(this.apps);
          }else{
   
          }
        },
        cmpsclick(){
            this.$router.push("/companyinfo");
        },
        xclick(code){
            console.log(code);
        },
        goclick(app){
          window.open(app.homePage);
        },
        async queryapi(app){
          console.log("ccccccccccccccccccccccccc");
          console.log(app);
          if(app.docUrl){
            var x=encodeURIComponent(JSON.stringify(app));
            this.$router.push({
              path:"/docquery",
              query:{app:x}
            });
          }
  
        },
        initInUse(appmap){
            for(var k in appmap){
              var darray=appmap[k];
              darray.forEach((item)=>{
                item.inUse= (this.inUseStr.indexOf(item.id)>=0);
            });
          }
        },
        async initApps(){
            var d=  await this.$root.postReq("/web/common/appCtl/findAllApps",{});
            if(d && d.status==0 && d.data){
              this.initInUse(d.data);
              this.apps=d.data;
            }else{
     
            }
          },
    },
    vname:"gsb_home"
}
