<template>
  <div class="subPage">
    <div class="system-table-search">
      <div class="flex-h">
        <div class="flex-item flex-h"></div>
        <tableSearch value="请输入用户手机号" @exportSearchKey="searchList"></tableSearch>
      </div>
      <div class="moreFilter"></div>
    </div>
    <div class="system-table-box">
      <el-table
        :data="currentList"
        stripe
        style="width: 100%">
        <el-table-column
          prop="Name"
          label="姓名">
        </el-table-column>
        <el-table-column
          prop="Phone"
          label="手机号">
        </el-table-column>
        <el-table-column
          prop="CustomerName"
          label="微信昵称">
        </el-table-column>
        <el-table-column
          prop="RecommendName"
          label="推荐人">
        </el-table-column>
        <el-table-column
          prop="Points"
          label="积分">
        </el-table-column>
        <el-table-column
          prop="OpenId"
          label="openId">
        </el-table-column>
        <el-table-column
          label="创建时间">
          <template slot-scope="scope">
            <label>{{FormatDate(scope.row.CreateDate)}}</label>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <el-pagination
      @current-change="handleCurrentChange"
      :current-page.sync="postData.page"
      :page-size="postData.pagesize"
      layout="prev, pager, next, jumper"
      :total="total">
    </el-pagination>
  </div>
</template>

<script>
import tableSearch from '@/components/tableSearch/index'

export default {
  name: '',
  data () {
    return {
      total: 0,
      postData: { // 表格搜索条件
        phone: '', // 手机号
        page: 1, // 当前页码
        pagesize: 10, // 请求数据量
      },
      currentList: [],
    }
  },
  components: {
    tableSearch,
  },
  mounted () {
    this.$nextTick(function () {
      this.getList()
    })
  },
  methods: {
    FormatDate (date) {
      return this.toolClass.dateFormat(date)
    },
    handleCurrentChange (val) {
      this.getList()
    },
    searchList (key) { // 搜索列表
      this.postData.phone = key
      this.postData.page = 1
      this.getList()
    },
    getList () {
      this.$ajax(this.$api.dataStatistics.getCustomerList.url, {
        method: this.$api.dataStatistics.getCustomerList.method,
        queryData: this.postData
      }).then(res => {
        this.currentList = res.list
        this.postData.page = res.page
        this.total = res.pagenum
      })
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss" scoped>
@import "page.scss";
</style>
