<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item>
        <el-form-item label="昵称" prop="nickName">
          <el-input
            v-model="queryParams.nickName"
            placeholder="请输入博主姓名"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="memberList" >
      <el-table-column label="昵称" align="center" prop="nickName" />
      <el-table-column label="会员" align="center" prop="cardNames" />
      <el-table-column label="联系方式" align="center" prop="tel" />
      <el-table-column label="剩余积分" align="center" prop="bPoints" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="detail(scope.row)"
            v-hasPermi="['member:member:edit']"
          >查看</el-button>
          <el-button
            size="mini"
            type="text"
            @click="update(scope.row)"
            v-hasPermi="['member:member:remove']"
          >冻结</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改会员对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="联系方式" prop="tel">
          <el-input v-model="form.tel" placeholder="请输入联系方式" />
        </el-form-item>
        <el-form-item label="博主-本月通告发布剩余额度" prop="tRemaining">
          <el-input v-model="form.tRemaining" placeholder="请输入博主-本月通告发布剩余额度" />
        </el-form-item>
        <el-form-item label="博主-个人累计已发布通告数量" prop="tTotalNum">
          <el-input v-model="form.tTotalNum" placeholder="请输入博主-个人累计已发布通告数量" />
        </el-form-item>
        <el-form-item label="博主-个人粉丝数量" prop="tFansNum">
          <el-input v-model="form.tFansNum" placeholder="请输入博主-个人粉丝数量" />
        </el-form-item>
        <el-form-item label="博主-是否开启报名免打扰(0否|1开启)" prop="tOpenDisturb">
          <el-input v-model="form.tOpenDisturb" placeholder="请输入博主-是否开启报名免打扰(0否|1开启)" />
        </el-form-item>
        <el-form-item label="博主-收款码姓名" prop="tRecipientName">
          <el-input v-model="form.tRecipientName" placeholder="请输入博主-收款码姓名" />
        </el-form-item>
        <el-form-item label="博主-收款码图片地址" prop="tRecipientImage">
          <image-upload v-model="form.tRecipientImage"/>
        </el-form-item>
        <el-form-item label="博主-剩余积分" prop="bPoints">
          <el-input v-model="form.bPoints" placeholder="请输入博主-剩余积分" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listMember, getMember, delMember, addMember, updateMember } from "@/api/member/member";

export default {
  name: "Blogger",
  dicts: ['dl_identity_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 会员表格数据
      memberList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userType: '01',
        identityType: null,
        nickName:null
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
  },
  methods: {
    /** 查询会员列表 */
    getList() {
      this.loading = true;
      listMember(this.queryParams).then(response => {
        this.memberList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        userType: null,
        identityType: null,
        userId: null,
        tel: null,
        tRemaining: null,
        tTotalNum: null,
        tFansNum: null,
        tOpenDisturb: null,
        tRecipientName: null,
        tRecipientImage: null,
        bPoints: null,
        creator: null,
        createTime: null,
        updater: null,
        updateTime: null,
        delFlag: null
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },


    /** 修改按钮操作 */
    detail(row) {
      this.reset();
      // const id = row.id || this.ids
      // getMember(id).then(response => {
      //   this.form = response.data;
      //   this.open = true;
      //   this.title = "修改会员";
      // });
    },

    update(){

    },



  }
};
</script>
