<template>
  <div class="Organization">
    <div class="title">网格人员</div>
    <div class="user-content" v-for="(item, index) in dataInfo.parentGirdMembers" :key="index">
      <div>
        <!-- <image :src="item.photo" alt="" mode="aspectFill" v-if="item.photo" /> -->
        <img :src="item.photo" alt="" v-if="item.photo">
        <img src="./components/img/big-user.png" alt="" v-else>
      </div>
      <div class="right">
        <div class="name">
          <AiOpenData v-if="item.wxUserId" type="userName" :openid="item.wxUserId" />
        </div>
        <div class="gird">{{item.checkType == 2 ? '网格长' : '网格员'}}</div>
        <p>{{item.girdName}}</p>
      </div>
    </div>
    <div class="user-content user-item" v-for="(item, index) in dataInfo.girdMembers" :key="index">
     <div>
        <!-- <image :src="item.photo" alt="" mode="aspectFill" v-if="item.photo" /> -->
        <img :src="item.photo" alt="" v-if="item.photo">
        <img src="./components/img/big-user.png" alt="" v-else>
      </div>
      <div class="right">
        <div class="name">
          <AiOpenData v-if="item.wxUserId" type="userName" :openid="item.wxUserId" />
          <span class="gird">{{item.checkType == 2 ? '网格长' : '网格员'}}</span>
          <span class="num" v-if="item.checkType == 1">家庭数({{item.residentNumber}})</span>
        </div>
        <div class="gird-name">
          <span class="text">{{item.girdName}}</span>
          <span class="family-btn" @click="toFamily(item)" v-if="item.checkType == 1">责任家庭 ></span>
        </div>
      </div>
    </div>
    <AiEmpty description="暂无数据" class="emptyWrap" v-if="dataInfo.parentGirdMembers && !dataInfo.parentGirdMembers.length && !dataInfo.girdMembers.length"></AiEmpty>
    <div class="pad-b112"></div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userGird: {},
      dataInfo: {},
    }
  },
  props: ['params'],
  onShow() {
    document.title = '网格管理'
    this.getGirdUserList()
  },
  mounted() {
    this.userGird = this.params
    this.getGirdUserList()
    uni.$on('goback', (res) => {
      this.userGird = res
      this.getGirdUserList()
    }) 
  },
  methods: {
    getGirdUserList() {
      this.$http.post(`/app/appgirdmemberinfo/listGirdMemberByGirdId?girdId=${this.userGird.id}`).then((res) => {
        if (res.code == 0) {
          this.dataInfo = res.data
        }
      })
    },
    linkTo(url) {
      uni.navigateTo({url})
    },
    viewUser(userId) {
      wx.invoke('openUserProfile', {
        "type": 1, //1表示该userid是企业成员，2表示该userid是外部联系人
        "userid": userId //可以是企业成员，也可以是外部联系人
          }, function(res) {
          if(res.err_msg != "openUserProfile:ok") {
              //错误处理
          }
      });
    },
    toFamily(item) {
      uni.navigateTo({url: `./FamilyList?id=${item.id}&girdId=${this.userGird.id}`})
    }
  },
}
</script>

<style lang="scss" scoped>
.Organization {
  background-color: #f5f5f5;
  .title{
    font-size: 38px;
    font-family: PingFangSC-Semibold, PingFang SC;
    font-weight: 600;
    color: #333;
    line-height: 52px;
    padding-left: 32px;
    margin-bottom: 32px;
  }
  .user-content{
    width: calc(100% - 64px);
    margin: 0 0 32px 32px;
    background-color: #fff;
    padding: 32px;
    box-sizing: border-box;
    display: flex;
    img{
      width: 200px;
      height: 200px;
      margin-right: 32px;
    }
    image{
      width: 200px;
      height: 200px;
      margin-right: 32px;
    }
    .right{
      width: 100%;
      .name{
        font-size: 32px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333;
        line-height: 44px;
        margin-bottom: 12px;
      }
      .gird{
        display: inline-block;
        line-height: 44px;
        background: #E8EFFF;
        border-radius: 8px;
        padding: 0 8px;
        font-size: 26px;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #26F;
        margin-bottom: 12px;
      }
      p{
        font-size: 26px;
        font-family: PingFangSC-Regular, PingFang SC;
        color: #666;
        line-height: 36px;
      }
    }
  }
  .user-item{
    img{
      width: 96px;
      height: 96px;
      border-radius: 50%;
    }
    image{
      width: 96px;
      height: 96px;
      border-radius: 50%;
    }
    .gird{
      display: inline-block;
      margin-left: 16px;
      margin-bottom: 0!important;
    }
    .name{
      margin-bottom: 8px!important;
    }
  }
  .family-btn{
    font-size: 26px;
    font-family: PingFangSC-Regular, PingFang SC;
    color: #3975C6;
    line-height: 36px;
    float: right;
  }
  .num{
    font-size: 26px;
    font-family: PingFangSC-Regular, PingFang SC;
    line-height: 36px;
    float: right;
  }
  .pad-b112{
    padding-bottom: 112px;
  }
}
</style>
