<template>
  <view class="work-container">
    <view class="header">
      <u-search placeholder="请输入客户名称" :clearabled="true" @clear="searchDept" @custom="searchDept" v-model="search.userName" @search="searchDept"></u-search>
    </view>
    <view style="margin-top: 10px">
      <uni-list :border="true">
        <!-- 显示圆形头像 -->
        <view v-for="item in userList">

          <uni-list-chat v-if="item.avatar != ''"  :avatar-circle="true" :title="item.nickName" :avatar="item.avatar" :note="item.phonenumber" :time="item.createTime" ></uni-list-chat>
          <uni-list-chat  v-else :avatar-circle="true" :title="item.nickName" avatar="/static/images/device/user.png" :note="item.phonenumber" :time="item.createTime" ></uni-list-chat>

        </view>


      </uni-list>
    </view>
  </view>
</template>

<script>
import authObj from '@/plugins/auth.js';
import {getDeptList,getUserListByDept} from '@/api/user/user';
import UText from "../../uni_modules/uview-ui/components/u-text/u-text";
export default {
  components: {UText},
  data() {
      return {
        userList:[],
        search:{
          userName:""
        },
        deptId:0,
      }
    },
  onLoad(opt){
    this.deptId = opt.deptId;
    this.getUser();
  },
    methods: {
      searchDept(){
        this.getUser();
      },
      change(item){
        console.log(item)
      },
      getUser(){
        let id = this.deptId;
        getUserListByDept(id,this.search.userName).then(res=>{
          this.userList = res.rows;
          for(const user of this.userList){
          }
        });
      },
    }
  }
</script>

<style lang="scss">
  /* #ifndef APP-NVUE */
  .u-collapse-content{
    display: flex;
    flex-direction: column;
  }
  page {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    background-color: #fff;
    min-height: 100%;
    height: auto;
  }

  view {
    font-size: 14px;
    line-height: inherit;
  }

  /* #endif */

  .text {
    text-align: center;
    font-size: 26rpx;
    margin-top: 10rpx;
  }

  .grid-item-box {
    flex: 1;
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 15px 0;
  }

  .uni-margin-wrap {
    width: 690rpx;
    width: 100%;
    ;
  }

  .swiper {
    height: 300rpx;
  }

  .swiper-box {
    height: 150px;
  }

  .swiper-item {
    /* #ifndef APP-NVUE */
    display: flex;
    /* #endif */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: #fff;
    height: 300rpx;
    line-height: 300rpx;
  }

  @media screen and (min-width: 500px) {
    .uni-swiper-dot-box {
      width: 400px;
      /* #ifndef APP-NVUE */
      margin: 0 auto;
      /* #endif */
      margin-top: 8px;
    }

    .image {
      width: 100%;
    }
  }
</style>
