<template>
  <div class="padding-20">
    <div class="search-box">
      <el-form
        ref="form"
        :inline="true"
        :model="searchForm"
        clearable
        class="mt-10">
        <el-form-item label="用户手机:">
          <el-input v-model="searchForm.user_phone" placeholder="请输入用户手机" clearable></el-input>
        </el-form-item>
        <el-form-item label="注册时间:">
          <el-date-picker
            :editable="false"
            v-model="time"
            @change="timearr => {timearr ? (searchForm.register_start_time = timearr[0] + ' 00:00:00', searchForm.register_end_time = timearr[1] + ' 23:59:59') : searchForm.register_start_time = searchForm.register_end_time = undefined}"
            type="daterange"
            value-format="yyyy-MM-dd"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
          ></el-date-picker>
        </el-form-item>
        <el-form-item class="ml-10">
          <el-button icon="el-icon-search" type="primary" @click="searchSubmit">查询</el-button>
        </el-form-item>
      </el-form>
    </div>
    <el-table :data="tableData"
              stripe
              v-loading="tableLoading"
              fit class="marginT-10 order-table"
              border
              :max-height="vheight">
      <el-table-column label="ID" prop="id" width="80"></el-table-column>
      <el-table-column label="头像">
        <template slot-scope="scope">
          <el-image style="width: 100px; height: 100px"
                    :src="scope.row.user_head_url"
                    :preview-src-list="[scope.row.user_head_url]">
          </el-image>
        </template>
      </el-table-column>
      <el-table-column label="昵称" prop="user_name" width="160"></el-table-column>
      <el-table-column label="手机号" prop="user_phone" width="120"></el-table-column>
      <el-table-column label="生日" prop="user_birthday"></el-table-column>
      <el-table-column label="性别" prop="user_sex"></el-table-column>
      <el-table-column label="注册时间" prop="created_at" width="160"></el-table-column>
      <el-table-column label="最近一次登录时间" prop="user_login_at" width="160"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button type="text" v-permission="'ums_customer_check'"
                     @click="$router.push({name: 'FmsCheck', query: {user_id: scope.row.id }})">消费记录
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      class="marginT-20"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :hide-on-single-page="true"
      :current-page="page"
      :page-size="page_size"
      :page-sizes="[10, 20, 100, 200, 300, 400]"
      background
      layout="total, sizes, prev, pager, next, jumper"
      :total="totalCount"/>
  </div>
</template>

<script>
import page from '@/mixin/page'

export default {
  mixins: [page],
  data () {
    return {
      time: [],
      searchForm: {
        user_type: '0' // 用户类型(0用户1艺人2吧台3老板)
      },
      tableData: [],
      tableUrl: '/v1/user/member/List'
    }
  },
  mounted () {
    this.init()
  }
}
</script>

<style lang="scss" scoped>
</style>
