<template>
  <div class="mine">
    <div class="condition">
      <el-input placeholder="请输入内容" class="search" v-model="searchText">
        <i slot="prefix" class="el-input__icon el-icon-search"></i>
      </el-input>
      <el-button type="primary" class="searchButton" @click="getUserList()"
        >搜索</el-button
      >
      <div class="silenceUser">
        <div class="title">显示沉默付费用户</div>
        <el-switch
          v-model="silence"
          active-color="#fa7d22"
          inactive-color="#e7e7e7"
          @change="showSilence"
        >
        </el-switch>
      </div>
      <div class="faceUser">
        <div class="title">显示未面诊付费用户</div>
        <el-switch
          v-model="face"
          active-color="#fa7d22"
          inactive-color="#e7e7e7"
          @change="showFace"
        >
        </el-switch>
      </div>
      <div class="filter">
        <div class="title">筛选</div>
        <i @click="openFilterPop" class="el-icon-s-operation"></i>
      </div>
      <!-- 筛选条件弹窗 -->
      <select-pop :visible.sync='dialogVisible'></select-pop>
    </div>

    <div class="user-list">
      <el-table
        ref="multipleTable"
        :data="tableData"
        tooltip-effect="dark"
        height="500"
        style="width: 100%; border-radius: 8px"
        @row-click="handleSelectionChange"
      >
        <el-table-column label="头像" width="120">
          <template slot-scope="scope">
            <div class="head-img">
              <img :src="scope.row.avatar_url" alt="" />
            </div>
          </template>
        </el-table-column>
        <el-table-column prop="nickname" label="昵称" width="120">
        </el-table-column>
        <el-table-column prop="id" label="用户ID" width="120"></el-table-column>
        <el-table-column prop="mobile" label="联系电话" show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="create_time"
          label="注册时间"
          show-overflow-tooltip
        >
        </el-table-column>
      </el-table>

      <div class="pagin">
        <el-pagination
          background
          layout="prev, pager, next"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page.sync="currentPage1"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
import api from "../../server/home";
import selectPop from './selectPop/index.vue'
export default {
  components: {selectPop},
  data() {
    return {
      searchText: "",
      dates: "",
      coupon: "",
      couponList: [
        {
          value: "选项1",
          label: "黄金糕",
        },
        {
          value: "选项2",
          label: "双皮奶",
        },
      ],
      tableData: [],
      currentPage1: 1,
      multipleSelection: "",
      total: 0,
      face: false, //未面诊用户开关
      silence: false, //沉默用户开关
      dialogVisible:false // 控制筛选弹框
    };
  },
  computed: {},
  watch: {},

  methods: {
    // 筛选沉默用户
    showSilence(e){
      console.log(e);
    },
    // 筛选未面诊用户
    showFace(e){
      console.log(e);
    },
    // 打开筛选条件弹框
    openFilterPop() {
      this.dialogVisible = true;
    },
    // 获取订单列表
    getUserList() {
      let params = {
        page: this.currentPage1,
        limit: this.limit,
        keywords: this.searchText,
      };
      api.getUserList(params).then((res) => {
        if (res.code == 200) {
          // 将用户手机号中间四位变成****
          res.data.list.map((item) => {
            item.mobile =
              item.mobile.substring(0, 3) + "****" + item.mobile.substring(7);
          });
          this.tableData = res.data.list;
          this.total = res.data.total;
        }
      });
    },

    handleCurrentChange(e) {
      this.currentPage1 = e;
      this.getUserList();
    },

    handleSizeChange(val) {},
    handleSelectionChange(row, column, event) {
      this.$router.push({
        path: "/customerMan/details",
        query: {
          id: row.id,
        },
      });
    },
  },

  created() {
    this.getUserList();
  },

  mounted() {},
};
</script>

<style lang='less' scoped>
.mine {
  .condition {
    display: flex;
    .coupon-select {
      width: 174px;
      margin-left: 18px;
    }
    .search {
      width: 152px;
      margin-left: 18px;
    }

    .searchButton {
      margin-left: 18px;
      width: 68px;
      background: #fa7d22;
      border-radius: 2px;
      border-color: #fa7d22;
    }
    .silenceUser {
      display: flex;
      margin-left: 53px;
      align-items: center;
      .title {
        line-height: 40px;
        margin-right: 16px;
      }
    }
    .faceUser {
      display: flex;
      margin-left: 53px;
      align-items: center;
      .title {
        line-height: 40px;
        margin-right: 16px;
      }
    }
    .filter {
      display: flex;
      align-items: center;
      margin-left: 53px;
      .title {
        margin-right: 17px;
      }
      i {
        font-size: 17px;
      }
    }
  }
  .user-list {
    margin-top: 18px;
    padding: 0 12px;
    width: 100%;
    background: #ffffff;
    box-shadow: 0px 2px 4px 0px rgba(184, 191, 198, 0.2);
    border-radius: 8px;
    .head-img {
      width: 36px;
      height: 36px;
      border-radius: 50%;

      img {
        width: 100%;
        height: 100%;
      }
    }
    .pagin {
      padding: 20px 0;
      .el-pagination {
        text-align: center;
      }
    }
    /deep/ .el-table th > .cell {
      font-size: 14px !important;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 20px;
    }
    /deep/ .el-table td,
    .el-table th.is-leaf {
      border-bottom: none;
    }
  }
}
</style>
