<template>
  <div class="Statistics">
    <div class="top">
      <div class="left" @click="linkTo('./SelectGird')">
        <img src="./components/img/gird-icon.png" alt="" />
        <div class="girdNmae">{{ girdMsgList.girdName || '' }}</div>
        <u-icon name="arrow-down" color="#666"></u-icon>
      </div>

      <div class="right" @click="linkTo('./SetGird')" v-if="checkType == 2">网格配置</div>
    </div>

    <div class="middle">
      <div class="girdPeople">网格内人员情况</div>

      <div class="card">
        <div class="box">
          <span class="count" v-if="peopleList && peopleList['网格长']">{{ peopleList['网格长']}}</span>
          <span class="count" v-else>0</span>
          <span class="girdCount">网格长</span>
        </div>

        <div class="box">
          <span class="count" v-if="peopleList && peopleList['网格员'] ">{{ peopleList['网格员']}}</span>
           <span class="count" v-else>0</span>
          <span class="girdCount">网格员</span>
        </div>

        <div class="box">
          <span class="count" v-if="peopleList && peopleList['责任家庭数']">{{ peopleList['责任家庭数'] }}</span>
          <span class="count" v-else>0</span>
          <span class="girdCount">责任家庭数</span>
        </div>
      </div>
    </div>

    <div class="bottom">
      <div class="girdMsg">网格信息</div>

      <div class="girdCont">
        <div class="boxes">
          <span class="boxesLeft">网格名称</span>

          <span class="boxesRight">{{ girdMsgList.girdName || '' }}</span>
          <!-- <span class="boxesRight">{{ girdUser.appGirdInfo.girdName }}</span> -->
        </div>

        <div class="boxes">
          <span class="boxesLeft">网格类型</span>

          <span class="boxesRight">
            {{ $dict.getLabel('girdType', girdMsgList.girdType) || '' }}
          </span>
        </div>

        <div class="boxes">
          <span class="boxesLeft">网格层级</span>

          <span class="boxesRight">{{ $dict.getLabel('girdType', girdMsgList.girdLevel) || '' }}</span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Statistics',
  components: {},
  props: {
    dict: Object,
    instance: Function,
    params: Object,
  },
  data() {
    return {
      girdUser: [],
      peopleList: {},
      girdMsgList: {},
      checkType: ''
    }
  },
  computed: {},
  watch: {},
  onLoad() {},
  mounted() {
    this.$dict.load('girdType', 'girdLevel').then(() => {})
    this.isGirdUser()
    uni.$on('goback', (res) => {
      this.girdMsgList = res
      this.getList()
    }) 
  },
  methods: {
    isGirdUser() {
      this.$http.post('/app/appgirdmemberinfo/checkLogOnUser').then((res) => {
        if (res.code == 0) {
          this.girdUser = res.data
          this.checkType = res.data.checkType
          if (this.girdUser.checkType != '0') {
            this.getList()
            if (this.girdUser.appGirdInfo) {
              this.girdMsgList = this.girdUser.appGirdInfo
            }
          } else {
            this.$u.toast('当前人员不是网格员或网格管理员')
          }
        }
      })
    },

    getList() {
      this.$http.post(`/app/appgirdmemberinfo/girdMemberAndResidentStatistic?girdId=${this.girdMsgList.girdId}`).then((res) => {
        if (res.code == 0) {
          this.peopleList = res.data
        }
      })
    },
    linkTo(url) {
      uni.navigateTo({url})
    }
  },
}
</script>

<style scoped lang="scss">
uni-page-body {
  height: 100%;
}
.Statistics {
  height: 100%;
  background: #f3f7f8;
  padding: 0 30px;
  padding-top: 30px;
  box-sizing: border-box;
  .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 32px;
    background: #fff;
    border-radius: 16px;
    .left {
      display: flex;
      align-items: center;
      img {
        width: 32px;
        height: 32px;
      }
      .girdNmae {
        margin-left: 20px;
        font-size: 34px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
      }
      .u-icon {
        margin-left: 8px;
      }
    }
    .right {
      font-size: 28px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #3f8df5;
    }
  }

  .middle {
    background: #ffffff;
    border-radius: 16px;
    margin-top: 32px;
    padding: 32px 0 60px 0;
    .girdPeople {
      padding: 0 0 56px 24px;
      font-size: 32px;
      font-family: PingFangSC-Regular, PingFang SC;
      color: #333333;
    }
    .card {
      display: flex;
      justify-content: space-around;
      .box {
        display: flex;
        flex-direction: column;
        align-items: center;
        .count {
          font-size: 64px;
          font-family: DINAlternate-Bold, DINAlternate;
          font-weight: bold;
          color: #3b424a;
        }
        .girdCount {
          margin-top: 8px;
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #999999;
        }
      }
    }
  }

  .bottom {
    background: #ffffff;
    border-radius: 16px;
    margin-top: 32px;
    padding: 0 24px 64px 24px;
    .girdMsg {
      padding: 32px 0;
      font-size: 32px;
      font-family: PingFangSC-Regular, PingFang SC;
      color: #333333;
    }
    .girdCont {
      .boxes {
        padding: 24px 0 30px 0;
        box-shadow: inset 0px -1px 0px 0px #d8dde6;
        .boxesLeft {
          font-size: 30px;
          font-family: PingFang-SC-Heavy, PingFang-SC;
          font-weight: 800;
          color: #333333;
        }
        .boxesRight {
          margin-left: 40px;
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          color: #666666;
        }
      }
    }
  }
}
</style>
