<template>
  <div>
    <el-table 
    v-loading="loading" :data="list" style="width: 100%">
      <el-table-column prop="avatarLink" label="头像" width="80">
        <template slot-scope="scope">
          <img :src="getAvatar(scope.row)" class="avatar" style="width: 40px; height: 40px; border-radius: 50%"/>
        </template>
      </el-table-column>
      <el-table-column prop="nickName" label="昵称" min-width="120">
      </el-table-column>
      <el-table-column prop="userName" label="用户名" min-width="120">
      </el-table-column>
      <el-table-column prop="phonenumber" label="电话" min-width="180"></el-table-column>
    </el-table>
    <pagination
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
  
</template>

<script>
import { pagelistNextUser } from '@/api/system/user.js';
export default {
  name: 'BrokerList',
  props: {
    parentId: {
      type: [String, Number],
      default: ''
    }
  },
  data() {
    return {
      loading: false,
      list: [],
      total: 0,
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: this.parentId,
        userType: 'jj'
      },
    }
  },
  created() {
    this.getList();
  },
  methods: {
    getList() {
      this.loading = true;
      pagelistNextUser(this.queryParams).then(response => {
        this.list = response.rows || [];
        this.total = response.total;
        this.loading = false;
      }).catch(e => {
        this.loading = false;
      });
    },
    getAvatar(row) {
      if (!row.avatarLink) {
        return require("@/assets/images/profile.jpg");
      }
      if (row.avatarLink.indexOf('http') === 0) {
        return row.avatarLink;
      }
      return process.env.VUE_APP_BASE_API + row.avatarLink;
    },
  }
}
</script>

<style>

</style>