<template>
  <div class="detail">
    <div>
      <div class="item-content" v-for="(item, index) in userList" :key="index">
        <div class="title" @click="showUserType(item, index)">
          <h2>{{ item.label }}</h2>
          <img src="./img/down-icon.png" alt="" :class="item.check ? 'img-active' : ''" />
        </div>
        <div class="user-list" v-if="item.check">
          <div v-if="statisticsList.length > 0">
            <div class="user-item" v-for="(e, indexs) in statisticsList" :key="indexs">
              <!-- v-if="item.value && item.value.length" -->
              <div class="user-img">
                <img src="./img/user-img.png" alt="" />
              </div>
              <div class="user-info">
                <p class="name">{{ e.name }}</p>
                <!-- <div class="phone">
                <span>{{ idNumberInit(e.idNumber) }}</span>
                <span>{{ e.phone }}</span>
              </div> -->
              </div>
            </div>
          </div>

          <p class="text" v-else>{{ '暂无' + item.label + '信息' }}</p>
        </div>
      </div>

      <div class="footer" @click="submit">
        <div class="btn">确定选择</div>
      </div>
    </div>
  </div>

  <!-- <div class="walkObject">
    <div class="header-top">
      <u-search v-model="keyword" placeholder="请输入姓名" :show-action="false" bg-color="#F5F5F5" search-icon-color="#CCCCCC" placeholder-color="#999999" @search="handerSearch" @clear="handerClear"></u-search>
    </div>

    <div class="header-middle">
      <div class="hint">可选范围</div>

      <div class="empty-div"></div>

      <div class="Checkbox">
        <div v-if="DiyList.length > 0">
          <u-collapse event-type="close" arrowaccordion>
            <u-collapse-item v-for="(item, index) in DiyList" :title="item.menuLevel3Name" :key="index" @change="selectUser(item)">
              <u-radio-group v-model="value">
                <u-radio v-for="(item, index) in userList" :key="index" :name="item.create_user_name">
                  {{ item.create_user_name }}
                </u-radio>
              </u-radio-group>
            </u-collapse-item>
          </u-collapse>
        </div>

        <AiEmpty description="没有数据" class="emptyWrap" v-else></AiEmpty>
      </div>
    </div>

    <div class="fixedBtn">
      <div class="typeName">
        <span class="typeName-box" v-for="(item, index) in list" :key="index" v-if="item.checked == true">
          {{ item.name }}
        </span>
      </div>

      <div class="subBtn" @click="submit">确定选择</div>
    </div>

    <div style="padding: 0 20px">
      <div style="display: flex; justify-content: space-between; background: pink; padding: 10px 0" v-for="(item, index) in DiyList" :key="index">
        <div @click="showDiv">
          <span>{{ item.applicationName }}</span>
          <u-icon name="arrow-right"></u-icon>
        </div>

        <div v-if="num % 2 == 0">
          <div>1111</div>
        </div>
      </div>
    </div>
  </div> -->
</template>

<script>
import { mapState } from 'vuex'

export default {
  name: 'walkObject',
  components: {},
  props: {
    params: {},
  },
  data() {
    return {
      addressArea: '',
      statisticsList: [],
      userList: [],
      name: '',

      // DiyList: {},
      // userList: [],
      // keyword: '',
      // list: [
      //   {
      //     name: '残疾人',
      //   },
      //   {
      //     name: '精神病患者',
      //   },
      //   {
      //     name: '吸毒人员',
      //   },
      // ],
      // nameList: [],
      current: 1,
      appId: '',
      // value: '',
      menuLevel3Name: '',
      // num: 1,
      // flag: false,
    }
  },
  watch: {},
  computed: {
    ...mapState(['user']),
  },

  created() {
    this.getUserList()
    uni.$on('specialPeopleList', () => {
      this.getUserList()
    })
  },
  onShow() {
    document.title = '选择走访慰问对象'
  },
  mounted() {},
  methods: {
    submit() {
      this.userList.map((item) => {
        if (item.create_user_name == this.value) {
          this.$emit('back', { item: item, appId: this.appId, menuLevel3Name: this.menuLevel3Name })
        }
      })
    },

    getStatistic(item) {
      // this.statisticsList = []
      this.menuLevel3Name = item.value.menuLevel3Name
      this.appId = item.value.id
      this.$http.post(`/app/appapplicationinfo/list?appId=${item.value.id}&current=${this.current}&size=${999}`).then((res) => {
        if (res.code == 0) {
          this.statisticsList = res.data.records

          // for (let i in res.data) {
          //   var obj = {
          //     label: i,
          //     value: res.data[i],
          //   }
          //   this.statisticsList.push(obj)
          // }
        }
      })
    },

    getUserList() {
      this.userList = []
      this.$http.post(`/app/appapplicationinfo/queryApplicationListByType?type=0&status=1`).then((res) => {
        if (res.code == 0) {
          for (let i in res.data) {
            var obj = {
              // label: i,
              label: res.data[i].applicationName,
              value: res.data[i],
              check: false,
            }
            this.userList.push(obj)
          }
        }
      })
    },

    idNumberInit(idNumber) {
      if (!idNumber) {
        idNumber = ''
      } else {
        idNumber = idNumber.substring(0, 5) + '******' + idNumber.substring(12, 15)
      }
      return idNumber
    },

    showUserType(item, index) {
      this.getStatistic(item)
      if (this.userList[index].check) {
        this.userList[index].check = false
        console.log(1)
        this.statisticsList = []
      } else {
        this.userList.map((item) => {
          item.check = false
          this.statisticsList = []
        })
        this.userList[index].check = true
      }
    },

    radioGroupChange(e) {
      console.log(e)
    },
  },

  // methods: {
  //   showDiv() {
  //     this.num = this.num + 1
  //     this.$forceUpdate()
  //     if (this.num % 2 == 0) {
  //
  //       this.flag == true
  //       this.$forceUpdate()
  //     } else {
  //
  //       this.flag == false
  //       this.$forceUpdate()
  //     }
  //   },

  //   getDiyList() {
  //     this.$http.post('/app/appapplicationinfo/queryApplicationListByType?type=0').then((res) => {
  //       if (res.code == 0) {
  //         this.DiyList = res.data
  //       }
  //     })
  //   },

  // selectUser(item) {
  //   this.userList = []
  //   this.menuLevel3Name = item.menuLevel3Name
  //   this.appId = item.id
  //   this.$http.post(`/app/appapplicationinfo/list?appId=${'2677c070764f4779920c1a2923a8afb0'}&current=${this.current}&size=${99}`, { searchParam: this.keyword }).then((res) => {
  //     if (res.code == 0) {
  //       this.userList = res.data.records
  //     }
  //   })
  // },

  //   submit() {
  //     this.userList.map((item) => {
  //       if (item.create_user_name == this.value) {
  //         this.$emit('back', { item: item, appId: this.appId, menuLevel3Name: this.menuLevel3Name })
  //       }
  //     })
  //   },
  // },
}
</script>

<style lang="scss" scoped>
.detail {
  .tab-select {
    width: 100%;
    height: 96px;
    line-height: 96px;
    background: #3975c6;
    display: flex;
    .item {
      flex: 1;
      text-align: center;
      font-size: 28px;
      font-family: PingFangSC-Regular, PingFang SC;
      color: #cddcf0;
    }
    .active {
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      position: relative;
      color: #fff;
      span {
        width: 48px;
        height: 4px;
        background: #fff;
        position: absolute;
        bottom: 14px;
        left: 50%;
        margin-left: -24px;
      }
    }
  }

  .info-content {
    width: calc(100% - 64px);
    background: #fff;
    border-radius: 8px;
    margin: 24px 32px 0;
    .title {
      padding-left: 32px;
      line-height: 94px;
      border-bottom: 1px solid #ddd;
      font-size: 32px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333;
    }
    .num-content {
      overflow: hidden;
      .num-item {
        float: left;
        width: 33%;
        padding: 40px 0;
        text-align: center;
        h3 {
          font-size: 64px;
          font-family: DINAlternate-Bold, DINAlternate;
          font-weight: bold;
          color: #3192f4;
          line-height: 74px;
          margin-bottom: 10px;
        }
        p {
          font-size: 28px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #999;
          line-height: 40px;
        }
      }
    }
    .color-org {
      .num-item {
        h3 {
          color: #ff8700;
        }
      }
    }
  }
  .item-content {
    margin-bottom: 4px;
    .title {
      width: 100%;
      height: 108px;
      line-height: 108px;
      background: #fff;
      padding: 0 32px;
      box-sizing: border-box;
      display: flex;
      justify-content: space-between;
      h2 {
        font-size: 32px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #333;
      }
      img {
        width: 34px;
        height: 34px;
        margin-top: 38px;
        transition: all 0.3s ease-in-out;
      }
      .img-active {
        transform: rotate(180deg);
      }
    }
    .user-list {
      background-color: #fff;
      .user-item {
        padding: 24px 32px;
        display: flex;
        align-items: center;
        .user-img {
          width: 112px;
          img {
            width: 80px;
            height: 80px;
          }
        }
        .user-info {
          width: 100%;
          .name {
            font-size: 32px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #333;
            line-height: 44px;
            margin-bottom: 8px;
          }
          .phone {
            width: 100%;
            font-size: 26px;
            font-family: PingFangSC-Regular, PingFang SC;
            color: #999;
            line-height: 36px;
            display: flex;
            justify-content: space-between;
          }
        }
      }
    }
  }
  .text {
    height: 96px;
    line-height: 96px;
    color: #999;
    font-size: 28px;
    text-align: center;
  }
  .footer {
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
  }
  .btn {
    width: 100%;
    height: 112px;
    line-height: 112px;
    text-align: center;
    background: #1365dd;
    font-size: 32px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #fff;
  }
}

.walkObject {
  background: #ffffff;
  padding-bottom: 118px;

  .tab-select {
    width: 100%;
    height: 96px;
    line-height: 96px;
    background: #3975c6;
    display: flex;
    .item {
      flex: 1;
      text-align: center;
      font-size: 28px;
      font-family: PingFangSC-Regular, PingFang SC;
      color: #cddcf0;
    }
    .active {
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      position: relative;
      color: #fff;
      span {
        width: 48px;
        height: 4px;
        background: #fff;
        position: absolute;
        bottom: 14px;
        left: 50%;
        margin-left: -24px;
      }
    }
  }

  .info-content {
    width: calc(100% - 64px);
    background: #fff;
    border-radius: 8px;
    margin: 24px 32px 0;
    .title {
      padding-left: 32px;
      line-height: 94px;
      border-bottom: 1px solid #ddd;
      font-size: 32px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333;
    }
    .num-content {
      overflow: hidden;
      .num-item {
        float: left;
        width: 33%;
        padding: 40px 0;
        text-align: center;
        h3 {
          font-size: 64px;
          font-family: DINAlternate-Bold, DINAlternate;
          font-weight: bold;
          color: #3192f4;
          line-height: 74px;
          margin-bottom: 10px;
        }
        p {
          font-size: 28px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #999;
          line-height: 40px;
        }
      }
    }
    .color-org {
      .num-item {
        h3 {
          color: #ff8700;
        }
      }
    }
  }
  .item-content {
    margin-bottom: 4px;
    .title {
      width: 100%;
      height: 108px;
      line-height: 108px;
      background: #fff;
      padding: 0 32px;
      box-sizing: border-box;
      display: flex;
      justify-content: space-between;
      h2 {
        font-size: 32px;
        font-family: PingFangSC-Semibold, PingFang SC;
        font-weight: 600;
        color: #333;
      }
      img {
        width: 34px;
        height: 34px;
        margin-top: 38px;
        transition: all 0.3s ease-in-out;
      }
      .img-active {
        transform: rotate(180deg);
      }
    }
    .user-list {
      background-color: #fff;
      .user-item {
        padding: 24px 32px;
        display: flex;
        .user-img {
          width: 112px;
          img {
            width: 80px;
            height: 80px;
          }
        }
        .user-info {
          width: 100%;
          .name {
            font-size: 32px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #333;
            line-height: 44px;
            margin-bottom: 8px;
          }
          .phone {
            width: 100%;
            font-size: 26px;
            font-family: PingFangSC-Regular, PingFang SC;
            color: #999;
            line-height: 36px;
            display: flex;
            justify-content: space-between;
          }
        }
      }
    }
  }
  .text {
    height: 96px;
    line-height: 96px;
    color: #999;
    font-size: 28px;
    text-align: center;
  }
  .footer {
    width: 100%;
    position: fixed;
    bottom: 0;
    left: 0;
  }
  .btn {
    width: 100%;
    height: 112px;
    line-height: 112px;
    text-align: center;
    background: #1365dd;
    font-size: 32px;
    font-family: PingFangSC-Medium, PingFang SC;
    font-weight: 500;
    color: #fff;
  }

  .header-top {
    background: #fff;
    padding: 20px 32px;
  }

  .header-middle {
    .hint {
      padding: 0 20px 0 32px;
      height: 112px;
      line-height: 112px;
      box-shadow: 0px 1px 0px 0px #e4e5e6;
      font-size: 30px;
      font-weight: 500;
    }

    .empty-div {
      height: 16px;
      background: #f5f5f5;
    }

    .Checkbox {
      padding: 0 0px 0 30px;

      ::v-deep .u-collapse {
        .u-collapse-item {
          .u-collapse-body {
            // display: inline;
            padding-bottom: 4px;
            box-sizing: content-box;
            .u-radio-group {
              .u-radio {
                line-height: 0;
              }
            }
          }
        }
      }
    }
  }

  .fixedBtn {
    display: flex;
    justify-content: space-between;
    position: fixed;
    bottom: 0;
    width: 100%;
    box-sizing: border-box;
    padding: 0 32px;

    .subBtn {
      margin: 20px 0 18px 0;
      padding: 18px 32px;
      background: #1365dd;
      border-radius: 4px;
      font-size: 32px;
      color: #ffffff;
    }

    .typeName {
      margin: 36px 0 22px 0;

      .typeName-box {
        padding: 16px 14px;
        background: #eaeef1;
        border-radius: 8px;
        font-size: 30px;
        font-weight: 500;
        margin-left: 10px;
      }

      .typeName-box:first-child {
        margin-left: 0;
      }
    }
  }
}
</style>
