Newer
Older
KaiFengPC / src / views / publicService / fans / certification.vue
@zhangdeliang zhangdeliang on 3 Sep 4 KB update
<template>
  <!-- 排水防涝子系统 公众服务  粉丝认证-->
  <div class="publicContainer">
    <!-- 搜索区域 -->
    <el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch">
      <el-form-item label="粉丝昵称" prop="nickName">
        <el-input v-model="queryParams.nickName" placeholder="请输入" clearable @keyup.enter="handleQuery" />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <!-- 按钮区域 -->
    <el-row :gutter="10" class="mb8">
      <right-toolbar v-model:showSearch="showSearch" @queryTable="getDataList"></right-toolbar>
    </el-row>
    <!-- 表格 -->
    <el-table v-loading="tableLoading" :data="tableData" max-height="650">
      <el-table-column label="用户头像" prop="coverPhotosFileList">
        <template #default="scope">
          <el-image
            :src="scope.row.coverPhotosFileList.length > 0 ? scope.row.coverPhotosFileList[0].url : defaultImg"
            style="width: 100px; height: 100px"
          ></el-image>
        </template>
      </el-table-column>
      <el-table-column label="用户昵称" prop="nickName" />
      <el-table-column label="openID" prop="openId" />
      <el-table-column label="认证状态" prop="authStatus">
        <template #default="scope">
          {{ scope.row.authStatus == 0 ? '未认证' : scope.row.authStatus == 1 ? '已认证' : scope.row.authStatus == 2 ? '认证中' : '--' }}
        </template>
      </el-table-column>
      <el-table-column label="提交时间" prop="createTime" />
      <el-table-column label="操作" width="160" class-name="small-padding fixed-width">
        <template #default="scope">
          <el-button
            link
            type="primary"
            icon="Edit"
            @click="handleAudit(scope.row)"
            v-hasPermi="['floodSys:jing:edit']"
            v-if="scope.row.authStatus == 0"
          >
            认证
          </el-button>
          <el-button
            link
            type="warning"
            icon="Edit"
            @click="cancelAudit(scope.row)"
            v-hasPermi="['floodSys:jing:edit']"
            v-if="scope.row.authStatus == 1"
          >
            取消认证
          </el-button>
          <el-button
            link
            type="danger"
            icon="Delete"
            @click="handleDelete(scope.row)"
            v-hasPermi="['floodSys:jing:remove']"
            v-if="scope.row.authStatus != 2"
          >
            删除
          </el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getDataList"
    />
  </div>
</template>

<script setup name="粉丝认证">
import { fansList, fansDel, fansCert, fansCertCancel } from '@/api/publicService/index';
import defaultImg from '@/assets/images/login/user.png';

const { proxy } = getCurrentInstance();

const tableData = ref([]);
const tableLoading = ref(true);
const total = ref(0);
const showSearch = ref(true);

const allData = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    nickName: undefined,
  },
});
const { queryParams } = toRefs(allData);

/** 获取搜索数据列表 */
function getDataList() {
  tableLoading.value = true;
  fansList(queryParams.value).then(response => {
    tableData.value = response.data;
    total.value = response.total;
    tableLoading.value = false;
  });
}
/** 认证按钮 */
function handleAudit(row) {
  proxy.$modal
    .confirm('确定认证此人信息?')
    .then(() => {
      fansCert(row.id).then(res => {
        getDataList();
        proxy.$modal.msgSuccess('认证成功');
      });
    })
    .catch(() => {});
}
/** 取消认证按钮 */
function cancelAudit(row) {
  proxy.$modal
    .confirm('确定取消认证此人信息?')
    .then(() => {
      fansCertCancel(row.id).then(res => {
        getDataList();
        proxy.$modal.msgSuccess('取消认证成功');
      });
    })
    .catch(() => {});
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getDataList();
}
/** 重置按钮操作 */
function resetQuery() {
  proxy.resetForm('queryRef');
  handleQuery();
}
/** 删除按钮操作 */
function handleDelete(row) {
  const postIds = row.id;
  proxy.$modal
    .confirm('是否确认删除该数据项?')
    .then(function () {
      return fansDel(postIds);
    })
    .then(() => {
      getDataList();
      proxy.$modal.msgSuccess('删除成功');
    })
    .catch(() => {});
}

onMounted(() => {
  getDataList();
});
</script>