
import React, { useState, useEffect } from 'react';
import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select } from 'antd';
import { FormattedMessage } from 'umi-plugin-react/locale';
import channels from './channelList.less';
import router from 'umi/router';
import apis from '../../services/apis';
import request from '../../utils/request'

const { Option } = Select;
function handleChange(value) {
  console.log(`selected ${value}`);
}
const columns = [
  {
    title: '头像',
    dataIndex: 'img',
    key: 'img',
    align: 'center',

    render: (text, record) => <img src={record.avatarurl} className={channels.touxiang} />,
  },
  {
    title: '用户姓名',
    dataIndex: 'name',
    key: 'name',
    align: 'center',
  },
  {
    title: '电话',
    dataIndex: 'tel',
    key: 'tel',
    align: 'center',
  },
  {
    title: '性别',
    dataIndex: 'sex',
    key: 'sex',
    align: 'center',
    render: (text, record) => <a style={ { color: '#66B3FF' } } >{ record.sex === 1 ? '男' : '女' }</a>,
  },
];
const header = props => {
  // eslint-disable-next-line react-hooks/rules-of-hooks
  const [data, setData] = useState({ channelNmae: [], result: [] })
  // eslint-disable-next-line react-hooks/rules-of-hooks
  useEffect(() => {
    getListInvite({ id: props.location.query.id, pageNum: 1, pageSize: 10 })
  }, [])

  // function getListInvite(params) {
  //   request({
  //     url: 'api/admin/channel/InviteClientsList',
  //     method: 'GET',
  //     params: { ...params },
  // // eslint-disable-next-line no-shadow
  // }).then(data => {
  //     console.log(data)
  //     setData(data)
  // })
  // }

  function getListInvite(params) {
    request({ ...apis.channelList.getListInvite, params: { ...params } }).then((data) => {
      setData(data)
  }).catch((err) => {
      console.log(err)
      message.info(err.msg || err.message)
  })
  }

  // 分页
  function onChange(pageNumber) {
    // eslint-disable-next-line react-hooks/rules-of-hooks
    getListInvite({ pageNum: pageNumber, pageSize: 9 })
  }
  return (
    <>
      <div className={channels.searchBox}>
      </div>
      <Table dataSource={data.records} rowKey="InviteClient" columns={columns} pagination={{ pageSize: 10, total: data.total, onChange }} />
  </>
  )
}


export default header
