Newer
Older
CloudBrainNew / src / views / socialLive / components / community / introduce.vue
StephanieGitHub on 4 Feb 2021 5 KB first commit
<!--
 * @Description: 社区基本概况
 * @Author: 王晓颖
 * @Date: 2020-11-21 11:46:03
 -->
<template>
  <chart-layout title="基本概况" @click="getData">
    <div class="block-container">
      <div class="block" v-for="(value,key,index) in data" :key="index">
        <simple-block :data="value" :color="value.color">
          <img :src="value.icon">
        </simple-block>
      </div>
    </div>
    <corner1 slot="corner"/>
  </chart-layout>
</template>

<script>
import Corner1 from '@/components/corner/Corner1'
import SimpleBlock from '@/components/block/simpleBlock'
import {fetchInfrastructure} from '@/api/community'
export default {
  name: 'Introduce',
  components: {SimpleBlock, Corner1},
  data () {
    return {
      data: {
        community: {name: '社区数量', value: '7', unit: '个', color: '', icon: require('@/assets/images/social/icon-community.png')},
        loudong: {name: '楼栋数量', value: '1', unit: '个', color: '', icon: require('@/assets/images/social/icon-loudong.png')},
        fangwu: {name: '房屋数量', value: '43', unit: '个', color: '', icon: require('@/assets/images/social/icon-fangwu.png')},
        chuzu: {name: '出租总户数', value: '10', unit: '个', color: '', icon: require('@/assets/images/social/icon-chuzu.png')},
        kongzhi: {name: '空置房屋数量', value: '32', unit: '个', color: '', icon: require('@/assets/images/social/icon-kongzhi.png')},
        changzhu: {name: '常住人口', value: '1', unit: '个', color: '', icon: require('@/assets/images/social/icon-changzhu.png')},
        liudong: {name: '流动人口', value: '12', unit: '个', color: '', icon: require('@/assets/images/social/icon-liudong.png')},
        jiedao: {name: '街道', value: '34', unit: '个', color: '', icon: require('@/assets/images/social/icon-street.png')},
        wuye: {name: '物业', value: '5', unit: '个', color: '', icon: require('@/assets/images/social/icon-wuye.png')},
        door: {name: '智能门禁', value: '24', unit: '个', color: '', icon: require('@/assets/images/social/icon-door.png')}
      }
    }
  },
  mounted () {
    this.getData()
  },
  methods: {
    getData () {
      this.getPark()
      this.getAdministrative()
      this.getCashBussiness()
      this.getHospitial()
      this.getSchool()
      this.getWelfareHouse()
      this.getCulture()
      this.getEntertainment()
      this.getBussiness()
      this.getParkLot()
    },
    // 公园数量
    getPark () {
      fetchInfrastructure('community').then(response => {
        if (response.code === 200) {
          this.data.community.value = response.data.total
        }
      }).catch((e) => {
        this.data.community.value = 7
      })
    },
    // 行政服务中心
    getAdministrative () {
      fetchInfrastructure('administrative').then(response => {
        if (response.code === 200) {
          this.data.loudong.value = response.data.total
        }
      }).catch((e) => {
        this.data.loudong.value = 7
      })
    },
    // 金融邮电数量
    getCashBussiness () {
      fetchInfrastructure('cashBusiness').then(response => {
        if (response.code === 200) {
          this.data.fangwu.value = response.data.total
        }
      }).catch((e) => {
        this.data.fangwu.value = 7
      })
    },
    // 医疗机构数量
    getHospitial () {
      fetchInfrastructure('chuzu').then(response => {
        if (response.code === 200) {
          this.data.chuzu.value = response.data.total
        }
      }).catch((e) => {
        this.data.chuzu.value = 7
      })
    },
    // 学校数量
    getSchool () {
      fetchInfrastructure('kongzhi').then(response => {
        if (response.code === 200) {
          this.data.kongzhi.value = response.data.total
        }
      }).catch((e) => {
        this.data.kongzhi.value = 7
      })
    },
    // 福利院数量
    getWelfareHouse () {
      fetchInfrastructure('changzhu').then(response => {
        if (response.code === 200) {
          this.data.changzhu.value = response.data.total
        }
      }).catch((e) => {
        this.data.changzhu.value = 7
      })
    },
    // 文化体育场所数量
    getCulture () {
      fetchInfrastructure('liudong').then(response => {
        if (response.code === 200) {
          this.data.liudong.value = response.data.total
        }
      }).catch((e) => {
        this.data.liudong.value = 7
      })
    },
    // 娱乐场所数量
    getEntertainment () {
      fetchInfrastructure('jiedao').then(response => {
        if (response.code === 200) {
          this.data.jiedao.value = response.data.total
        }
      }).catch((e) => {
        this.data.jiedao.value = 7
      })
    },
    // 文化体育场所数量
    getBussiness () {
      fetchInfrastructure('wuye').then(response => {
        if (response.code === 200) {
          this.data.wuye.value = response.data.total
        }
      }).catch((e) => {
        this.data.wuye.value = 7
      })
    },
    // 停车场数量
    getParkLot () {
      fetchInfrastructure('door').then(response => {
        if (response.code === 200) {
          this.data.door.value = response.data.total
        }
      }).catch((e) => {
        this.data.door.value = 7
      })
    }

  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .block-container{
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 0.04rem;
    padding-top:0.04rem;
    .block{
      width: 20%;
      height: 45%;
    }
  }
</style>