<template>
  <div v-if="permission.screen_service">
    <div class="wel__title" >
        <i class="iconfont iconshujudaping" style="margin-right: 10px;color: #25f3e6;"></i>
        大屏服务
    </div>
   <!-- <el-row :gutter="20">
      <el-col :span="6" v-for="(item,index) in topMenu" :key="index" @click.native="jumpToBigData(item)">
        <div class="wel__topMenu" :style="{background: item.bg}">
          {{item.name}}
        </div>
      </el-col>
    </el-row> -->
    <el-row :gutter="20">
      <el-col :span="4" v-if="permission.data_service" @click.native="jumpToBigData('smartCommunity')">
        <div class="wel__topMenu" style="background:linear-gradient(to right,#4b94b4,#335791)">
          数据服务
        </div>
      </el-col>
      <el-col :span="4" v-if="permission.fight_service" @click.native="jumpToBigData('fireControl')">
        <div class="wel__topMenu" style="background:linear-gradient(to right,#fdb783,#f86c89)">
          消防服务
        </div>
      </el-col>
      <el-col :span="4" v-if="permission.elderly_care_service"  @click.native="jumpToBigData('smartPension')">
        <div class="wel__topMenu" style="background:linear-gradient(to right,#f38bd6,#f36a97)">
          养老服务
        </div>
      </el-col>
      <el-col :span="4" v-if="permission.police_service" @click.native="jumpToBigData('smartPolice')">
        <div class="wel__topMenu" style="background:linear-gradient(to right,#25e7ab,#0db5e2)">
          公安服务
        </div>
      </el-col>
      <el-col :span="4" v-if="permission.business_service" @click.native="jumpToBigData('operatePlatform')">
        <div class="wel__topMenu" style="background:linear-gradient(to right,#25e7ab,#0db5e2)">
          运营服务
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
  import {
    mapGetters,
  } from "vuex";
  import {getUserInfo} from "@/util/util.js"
  import {getList} from "@/api/community/agency.js"
  import {getList as getResList} from "@/api/community/residential.js"
  export default{

    data(){
      return{
        topMenu:[{
          name:'数据服务',
          path:'index1',
          bg:'linear-gradient(to right,#4b94b4,#335791)'
        },{
          name:'消防服务',
          path:'fireControl',
          bg:'linear-gradient(to right,#fdb783,#f86c89)'
        },{
          name:'养老服务',
          path:'',
          bg:'linear-gradient(to right,#f38bd6,#f36a97)'
        },{
          name:'公安服务',
          path:'',
          bg:'linear-gradient(to right,#25e7ab,#0db5e2)'
        }],
        GardenDataList:{},
        ResDataList:{}
      }
    },
    computed: {

      ...mapGetters([
        "userInfo","permission","orgInfo"
      ])
      // permission(){
      //   return{

      //   }
      // }

    },
    created() {
      // console.log("当前租户id:"+this.userInfo.tenant_id);

      // if(this.userInfo.tenant_id === "804981"){
      //   // debugger
      //   this.topMenu = [{
      //     name:'数据服务',
      //     path:'index1',
      //     bg:'linear-gradient(to right,#4b94b4,#335791)'
      //   },{
      //     name:'消防服务',
      //     path:'fireControl',
      //     bg:'linear-gradient(to right,#fdb783,#f86c89)'
      //   }]
      // }
      this.getGardenDataList()
      this.getResList()
    },
    methods:{
      // jumpToBigData(item) {
      //   this.$router.push({
      //     path: item.path
      //   })
      // },
      getResList(){
        var _this = this;
        getResList().then((res)=>{
          // _this.communityData = res.data.data;
          if(res.data.data.records.length>0){
            _this.ResDataList = res.data.data.records[0]
          }
        }).catch((err)=>{
          console.log(err)
        })
      },
      getGardenDataList(){
        var _this = this;
        return getList().then((res)=>{
          // _this.communityData = res.data.data;
          console.log(res)
          if(res.data.data.records.length>0){
            _this.GardenDataList = res.data.data.records[0]
          }
        }).catch((err)=>{
          console.log(err)
        })
      },
      jumpToBigData(path) {
        if(path=="smartCommunity"){
          if(getUserInfo()){
            localStorage.setItem("agencies1",JSON.stringify(this.GardenDataList))
            path = 'index2'
          }else{
            let orgInfo = this.$store.getters.orgInfo
            if(orgInfo.deptType=="5"){
              //社区
              localStorage.setItem("agencies1",JSON.stringify(this.GardenDataList))
              path = 'index2'
            }else if(orgInfo.deptType=="6"||orgInfo.deptType=="1"||orgInfo.deptType=="4"){
              //小区
              localStorage.setItem("agencies2",JSON.stringify(this.ResDataList))
              path = 'index3'
            }
          }
        }
        this.$router.push({
          path: path
        })
      },
    }
  }
</script>

<style lang="scss" scoped >

  .wel{
      &__title {
        font-size: 16px;
        font-weight: bold;
        height: 40px;
      }
      &__icon{

      }
      &__topMenu{
         border-radius: 5px;
         color: #fff;
         height: 80px;
         line-height: 80px;
         cursor: pointer;
         font-size: 14px;
         text-align: center;
         letter-spacing: 2px;
         transition: all 0.5s linear;
         font-weight: 600;
         margin-bottom: 20px;
       }
       &__topMenu:hover{
         box-shadow:0px 0px 5px 2px #b8b7b7;
         transition: all 0.2s linear;
       }
  }

</style>
