<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item :label="$t('business.userManager.userVerification.account')" prop="account" label-width="auto">
        <el-input
          v-model="queryParams.account"
          :placeholder="$t('business.userManager.userVerification.accountPlaceholder')"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item :label="$t('business.userManager.userVerification.name')" prop="fullName">
        <el-input
          v-model="queryParams.fullName"
          :placeholder="$t('business.userManager.userVerification.namePlaceholder')"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item :label="$t('business.userManager.userVerification.idCard')" prop="idCardNumber" label-width="auto">
        <el-input
          v-model="queryParams.idCardNumber"
          :placeholder="$t('business.userManager.userVerification.idCardPlaceholder')"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">{{
            $t('common.button.search')
          }}
        </el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">{{ $t('common.button.reset') }}</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['business:userVerification:export']"
        >{{ $t('common.button.export') }}
        </el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="userVerificationList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center"/>
      <el-table-column :label="$t('business.userManager.userVerification.account')" align="center" prop="userAccount"/>
      <el-table-column :label="$t('business.userManager.userVerification.name')" align="center" prop="userInfoName"/>
      <el-table-column :label="$t('business.userManager.userVerification.idCard')" align="center" prop="idCard"/>
      <el-table-column :label="$t('business.userManager.userVerification.biometrics')" align="center" prop="status">
        <template slot-scope="scope">
          <el-tag type="danger" v-if="scope.row.biometrics == '0'">
            {{ $t('business.userManager.userVerification.biometricsUnverified') }}
          </el-tag>
          <el-tag type="success" v-if="scope.row.biometrics == '1'">
            {{ $t('business.userManager.userVerification.biometricsVerified') }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column :label="$t('business.userManager.userVerification.status')" align="center"
                       prop="status">
        <template slot-scope="scope">
          <el-tag type="primary" v-if="scope.row.status == '0'  || scope.row.status == null">
            {{ $t('business.userManager.userVerification.statusUnverified') }}
          </el-tag>
          <el-tag type="warning" v-if="scope.row.status == '1'">
            {{ $t('business.userManager.userVerification.statusPending') }}
          </el-tag>
          <el-tag type="success" v-if="scope.row.status == '2'">
            {{ $t('business.userManager.userVerification.statusVerified') }}
          </el-tag>
          <el-tag type="danger" v-if="scope.row.status == '3'">
            {{ $t('business.userManager.userVerification.statusFailed') }}
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column :label="$t('business.userManager.userVerification.certificateExpirationDate')" align="center"
                       prop="expirationTime" width="180">
      </el-table-column>
      <el-table-column :label="$t('business.userManager.userVerification.verificationTime')" align="center"
                       prop="authenticationDate" width="180">
      </el-table-column>
      <el-table-column :label="$t('business.userManager.userVerification.contactAddress')" align="center"
                       prop="commonContactAddressShow" width="180">
      </el-table-column>
      <el-table-column :label="$t('business.userManager.userVerification.failureReason')" align="center"
                       prop="failureReason"/>
      <el-table-column :label="$t('common.tableMsg.operation')" align="center" width="200"
                       class-name="small-padding fixed-width">
        <template slot-scope="scope">
          <el-button v-if="(scope.row.status == null || scope.row.status == 0 || scope.row.status == 3)"
                     size="mini"
                     type="text"
                     icon="el-icon-document-add"
                     @click="handleAdd(scope.row)"
          >{{ $t('business.userManager.userVerification.verify') }}
          </el-button>
          <el-button v-if="(scope.row.status == 2)"
                     size="mini"
                     type="text"
                     icon="el-icon-view"
                     @click="handleDetail(scope.row)"
          >{{ $t('common.button.detail') }}
          </el-button>
          <el-button v-if="(scope.row.status == 1)"
                     size="mini"
                     type="text"
                     icon="el-icon-view"
                     @click="handleAudit(scope.row)"
          >{{ $t('business.userManager.userVerification.audit') }}
          </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="700px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="auto">
        <el-form-item :label="$t('business.userManager.userVerification.name')" prop="fullName">
          <el-input v-model="form.fullName" :placeholder="$t('business.userManager.userVerification.namePlaceholder')"/>
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.idCard')" prop="idCardNumber">
          <el-input v-model="form.idCardNumber"
                    :placeholder="$t('business.userManager.userVerification.idCardPlaceholder')"/>
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.certificateStartDate')" prop="dateOfIssue">
          <el-date-picker clearable
                          v-model="form.dateOfIssue"
                          type="date"
                          format="dd/MM/yyyy"
                          value-format="dd/MM/yyyy"
                          :placeholder="$t('business.userManager.userVerification.dateOfIssueRequired')">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.certificateEndDate')" prop="expirationTime">
          <el-date-picker clearable
                          v-model="form.expirationTime"
                          type="date"
                          format="dd/MM/yyyy"
                          value-format="dd/MM/yyyy"
                          :placeholder="$t('business.userManager.userVerification.expirationTimeRequired')">
          </el-date-picker>
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.contactAddress')" prop="commonContactAddress">
          <el-cascader
            v-model="form.commonContactAddress"
            :options="options_addr"
            @change="handleChange"></el-cascader>
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userInfo.detailAddr')" prop="commonContactAddressDetail">
          <el-input v-model="form.commonContactAddressDetail" :placeholder="$t('business.userManager.userInfo.addrPlaceholder')" />
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.verifiedType')" prop="gender">
          <el-radio-group v-model="form.licenseType">
            <el-radio :label="1">{{ $t('business.userManager.userVerification.idCardVerification') }}</el-radio>
            <el-radio :label="0">{{ $t('business.userManager.userVerification.license') }}</el-radio>
          </el-radio-group>
        </el-form-item>
        <el-form-item v-if="form.licenseType == '1'" :label="$t('business.userManager.userVerification.idCardFront')" prop="idCardFrontImagePath">
          <el-upload
            class="upload-demo"
            :action="uploadUrl"
            :on-success="handleSuccess_idCardFrontImagePath"
            :limit="1"
            :accept="'image/jpg,image/png'"
            :file-list="fileList"
            list-type="picture">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传JPG/PNG文件，且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item v-if="form.licenseType == '1'" :label="$t('business.userManager.userVerification.idCardBack')" prop="idCardBackImagePath">
          <el-upload
            class="upload-demo"
            :action="uploadUrl"
            :on-success="handleSuccess_idCardBackImagePath"
            :limit="1"
            :accept="'image/jpg,image/png'"
            :file-list="fileList"
            list-type="picture">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传JPG/PNG文件，且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item v-if="form.licenseType == '1'" :label="$t('business.userManager.userVerification.idCardHolding')" prop="userWithIdCardImagePath">
          <el-upload
            class="upload-demo"
            :action="uploadUrl"
            :on-success="handleSuccess_userWithIdCardImagePath"
            :limit="1"
            :accept="'image/jpg,image/png'"
            :file-list="fileList"
            list-type="picture">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传JPG/PNG文件，且不超过5M</div>
          </el-upload>
        </el-form-item>
        <el-form-item v-if="form.licenseType == '0'" :label="$t('business.userManager.userVerification.license')" prop="passportImagePath">
          <el-upload
            class="upload-demo"
            :action="uploadUrl"
            :on-success="handleSuccess_passportImagePath"
            :limit="1"
            :accept="'image/jpg,image/png'"
            :file-list="fileList"
            list-type="picture">
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">只能上传JPG/PNG文件，且不超过5M</div>
          </el-upload>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="primary" @click="submitForm">{{
            $t('common.button.confirm')
          }}
        </el-button>
        <el-button @click="cancel">{{ $t('common.button.cancel') }}</el-button>
      </div>
    </el-dialog>

    <!--  实名审核  -->
    <el-dialog :title="title" :visible.sync="auditOpen" width="700px" append-to-body>
      <el-form ref="auditForm" :model="auditForm" :rules="rules" label-width="auto">
        <el-form-item :label="$t('business.userManager.userVerification.verifyName')">
          {{ auditForm.fullName }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.verifyIdCard')">
          {{ auditForm.idCardNumber }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.certificateStartDate')">
          {{ auditForm.dateOfIssue }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.certificateEndDate')">
          {{ auditForm.expirationTime }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.contactAddress')">
          {{ auditForm.commonContactAddressShow }}
        </el-form-item>
        <el-form-item v-if="auditForm.licenseType ==1" :label="$t('business.userManager.userVerification.idCardFront')">
          <el-image style="width: 90px; height: 30px" :src="auditForm.idCardFrontImagePath"
            :preview-src-list="[auditForm.idCardFrontImagePath]" />
        </el-form-item>
        <el-form-item v-if="auditForm.licenseType ==1" :label="$t('business.userManager.userVerification.idCardBack')">
          <el-image style="width: 90px; height: 30px" :src="auditForm.idCardBackImagePath"
            :preview-src-list="[auditForm.idCardBackImagePath]" />
        </el-form-item>
        <el-form-item v-if="auditForm.licenseType ==1" :label="$t('business.userManager.userVerification.idCardHolding')">
          <el-image style="width: 90px; height: 30px" :src="auditForm.userWithIdCardImagePath"
            :preview-src-list="[auditForm.userWithIdCardImagePath]" />
        </el-form-item>
        <el-form-item v-if="auditForm.licenseType == 0" :label="$t('business.userManager.userVerification.license')">
          <el-image style="width: 90px; height: 30px" :src="auditForm.passportImagePath"
            :preview-src-list="[auditForm.passportImagePath]" />
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.failureReason')" prop="failureReason">
          <el-input v-model="auditForm.failureReason"
                    :placeholder="$t('business.userManager.userVerification.failureReasonPlaceholder')"/>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :loading="buttonLoading" type="success" @click="submitPass">
          {{ $t('business.userManager.userVerification.pass') }}
        </el-button>
        <el-button :loading="buttonLoading" type="danger" @click="submitRefuse">
          {{ $t('business.userManager.userVerification.refuse') }}
        </el-button>
        <el-button @click="cancel">{{ $t('common.button.cancel') }}</el-button>
      </div>
    </el-dialog>
    <!-- 实名认证详情 -->
    <el-dialog :title="title" :visible.sync="detailOpen" width="700px" append-to-body>
      <el-form ref="form" :model="form" label-width="auto">
        <el-form-item :label="$t('business.userManager.userVerification.name')">
          {{ form.fullName }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.idCard')">
          {{ form.idCard }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.certificateStartDate')">
          {{ form.dateOfIssue }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.certificateEndDate')">
          {{ form.expirationTime }}
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.contactAddress')">
          {{ form.commonContactAddressShow }}
        </el-form-item>
        <el-form-item v-if="form.licenseType == 1" :label="$t('business.userManager.userVerification.idCardFront')">
          <el-image style="width: 90px; height: 30px" :src="form.idCardFrontImagePath"
            :preview-src-list="[form.idCardFrontImagePath]" />
        </el-form-item>
        <el-form-item v-if="form.licenseType == 1" :label="$t('business.userManager.userVerification.idCardBack')">
          <el-image style="width: 90px; height: 30px" :src="form.idCardBackImagePath"
            :preview-src-list="[form.idCardBackImagePath]" />
        </el-form-item>
        <el-form-item v-if="form.licenseType == 1" :label="$t('business.userManager.userVerification.idCardHolding')">
          <el-image style="width: 90px; height: 30px" :src="form.userWithIdCardImagePath"
            :preview-src-list="[form.userWithIdCardImagePath]" />
        </el-form-item>
        <el-form-item v-if="form.licenseType == 0" :label="$t('business.userManager.userVerification.license')">
          <el-image style="width: 90px; height: 30px" :src="form.passportImagePath"
            :preview-src-list="[form.passportImagePath]" />
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.biometrics')">
          <el-tag type="danger" v-if="form.biometrics == '0'">
            {{ $t('business.userManager.userVerification.biometricsUnverified') }}
          </el-tag>
          <el-tag type="success" v-if="form.biometrics == '1'">
            {{ $t('business.userManager.userVerification.biometricsVerified') }}
          </el-tag>
        </el-form-item>
        <el-form-item :label="$t('business.userManager.userVerification.verificationTime')">
          {{ form.authenticationDate }}
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="cancel">{{ $t('common.button.close') }}</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  listUserVerification,
  getUserVerification,
  delUserVerification,
  addUserVerification,
  updateUserVerification,
  userVerificationAudit,
  getAddress
} from "@/api/business/userVerification";

export default {
  name: "UserVerification",
  data() {
    return {
      // 按钮loading
      buttonLoading: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      //地址选择列表
      options_addr:[],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 实名认证表格数据
      userVerificationList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 是否显示详情弹出层
      detailOpen: false,
      // 是否显示详情弹出层
      auditOpen: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        userId: undefined,
        fullName: undefined,
        idCardNumber: undefined,
        gender: undefined,
        nationality: undefined,
        birthDate: undefined,
        idCardFrontImagePath: undefined,
        idCardBackImagePath: undefined,
        userWithIdCardImagePath: undefined,
        biometrics: undefined,
        status: undefined,
        authenticationDate: undefined,
        failureReason: undefined,
      },
      // 表单参数
      form: {},
      //审核参数
      auditForm: {},
      // 文件上传列表
      fileList: [],
      // 表单校验
      rules: {
        idCardNumber: [
          {
            required: true,
            pattern: /^\d+$/,
            message: this.$t('business.userManager.userVerification.idCardDigitOnly'),
            trigger: "blur"
          }
        ],
        fullName: [
          {required: true, message: this.$t('business.userManager.userVerification.nameRequired'), trigger: "blur"}
        ],
        expirationTime: [
          {required: true, message: this.$t('business.userManager.userVerification.expirationTimeRequired'), trigger: "blur"}
        ],
        dateOfIssue: [
          {required: true, message: this.$t('business.userManager.userVerification.dateOfIssueRequired'), trigger: "blur"}
        ],
        commonContactAddress: [
          {
            required: true,
            message: this.$t('business.userManager.userInfo.addrRequired'),
            trigger: "blur"
          }
        ],
        commonContactAddressDetail: [
          {
            required: true,
            message: this.$t('business.userManager.userInfo.addrRequired'),
            trigger: "blur"
          }
        ],
        idCardFrontImagePath: [
          {
            required: true,
            message: this.$t('business.userManager.userVerification.idCardFrontRequired'),
            trigger: "blur"
          }
        ],
        idCardBackImagePath: [
          {
            required: true,
            message: this.$t('business.userManager.userVerification.idCardBackRequired'),
            trigger: "blur"
          }
        ],
        userWithIdCardImagePath: [
          {
            required: true,
            message: this.$t('business.userManager.userVerification.idCardHoldingRequired'),
            trigger: "blur"
          }
        ],
        failureReason: [
          {
            required: true,
            message: this.$t('business.userManager.userVerification.failureReasonRequired'),
            trigger: "blur"
          }
        ],
      }
    };
  },
  created() {
    this.getList();
    this.getAddress();
  },
  computed: {
    // 计算属性：动态生成上传URL
    uploadUrl() {
      return `${process.env.VUE_APP_BASE_API}/commonFile/upload`;
    },
    getImgUrl(){
      return "http://app.lfpaylaos.com/file/";
    }
  },
  methods: {
    /** 查询实名认证列表 */
    getList() {
      this.loading = true;
      const languageMap = {
        'zh': 1,
        'en': 2,
        'la': 3
      };
      this.queryParams.language = languageMap[this.$i18n.locale] || null;
      listUserVerification(this.queryParams).then(response => {
        this.userVerificationList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.detailOpen = false;
      this.auditOpen = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: undefined,
        userId: undefined,
        fullName: undefined,
        idCardNumber: undefined,
        gender: undefined,
        nationality: undefined,
        birthDate: undefined,
        idCardFrontImagePath: undefined,
        idCardBackImagePath: undefined,
        userWithIdCardImagePath: undefined,
        biometrics: undefined,
        status: undefined,
        authenticationDate: undefined,
        failureReason: undefined,
        createTime: undefined,
        updateTime: undefined,
        createBy: undefined,
        updateBy: undefined,
        delFlag: undefined,
        licenseType: 1
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.id)
      this.single = selection.length !== 1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd(row) {
      this.reset();
      if (row.id != null) {
        this.form = row;
        // 处理地址回显
        const addrValue = this.form.commonContactAddress	;
        if (addrValue) {
          const addrArray = addrValue.split(',');
          const provinceValue = addrArray[0];
          const cityValue = addrArray[1];

          const province = this.options_addr.find(item => item.value === provinceValue);
          if (province) {
            if (cityValue) {
              const city = province.children.find(item => item.value === cityValue);
              if (city) {
                this.form.commonContactAddress	 = [provinceValue, cityValue];
                console.log(this.form);
              }
            } else {
              this.form.commonContactAddress	 = [provinceValue];
            }
          }
        }
        this.form.idCardFrontImagePath = undefined;
        this.form.idCardBackImagePath = undefined;
        this.form.userWithIdCardImagePath = undefined;
        this.form.passportImagePath = undefined;
        this.open = true;
        this.title = this.$t("business.userManager.userVerification.verification");
      } else {
        this.form.userId = row.userId;
        this.open = true;
        this.title = this.$t("business.userManager.userVerification.verification");
      }
    },
    /** 详情按钮操作 */
    handleDetail(row) {
      this.reset();
      this.form = row;
      this.detailOpen = true;
    },
    /** 审核按钮操作 */
    handleAudit(row) {
      this.reset();
      this.auditForm = row;
      this.auditOpen = true;
      this.title = this.$t("business.userManager.userVerification.auditVerification");
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.loading = true;
      this.reset();
      const id = row.id || this.ids
      getUserVerification(id).then(response => {
        this.loading = false;
        this.form = response.data;
        this.open = true;
        this.title = this.$t("business.userManager.userVerification.editVerification");
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          this.form.commonContactAddress = this.form.commonContactAddress + "," + this.form.commonContactAddressDetail;
          this.buttonLoading = true;
          if (this.form.id != null) {
            updateUserVerification(this.form).then(response => {
              this.$modal.msgSuccess(this.$t('business.userManager.userVerification.submitSuccess'));
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          } else {
            addUserVerification(this.form).then(response => {
              this.$modal.msgSuccess(this.$t('business.userManager.userVerification.submitSuccess'));
              this.open = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal.confirm(this.$t('common.promptMsg.deleteConfirm')).then(() => {
        this.loading = true;
        return delUserVerification(ids);
      }).then(() => {
        this.loading = false;
        this.getList();
        this.$modal.msgSuccess(this.$t('common.promptMsg.deleteSuccess'));
      }).catch(() => {
      }).finally(() => {
        this.loading = false;
      });
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download('business/userVerification/export', {
        ...this.queryParams
      }, `userVerification_${new Date().getTime()}.xlsx`)
    },
    /** 审核拒绝*/
    submitRefuse() {
      this.rules.failureReason = [
        {
          required: true,
          message: this.$t('business.userManager.userVerification.failureReasonRequired'),
          trigger: 'blur'
        }
      ];
      this.$refs["auditForm"].validate(valid => {
        if (valid) {
          this.$modal.confirm(this.$t('business.userManager.userVerification.confirmRefuse')).then(() => {
            this.buttonLoading = true;
            this.auditForm.status = "3";
            userVerificationAudit(this.auditForm).then(response => {
              this.$modal.msgSuccess(this.$t('business.userManager.userVerification.refuseSuccess'));
              this.auditOpen = false;
              this.getList();
            }).finally(() => {
              this.buttonLoading = false;
            });
          })
        }
      });
    },
    /** 审核通过*/
    submitPass() {
      this.$refs["auditForm"].clearValidate("failureReason");
      this.$modal.confirm(this.$t('business.userManager.userVerification.confirmPass')).then(() => {
        this.buttonLoading = true;
        this.auditForm.status = "2";
        userVerificationAudit(this.auditForm).then(response => {
          this.$modal.msgSuccess(this.$t('business.userManager.userVerification.passSuccess'));
          this.auditOpen = false;
          this.getList();
        }).finally(() => {
          this.buttonLoading = false;
        });
      })
    },
    //身份证正面上传成功
    handleSuccess_idCardFrontImagePath(response) {
      if (response.code === 200) {
        this.form.idCardFrontImagePath = this.getImgUrl + response.data;  // 保存 URL 到表单
      }
    },
    //身份证反面上传成功
    handleSuccess_idCardBackImagePath(response) {
      if (response.code === 200) {
        this.form.idCardBackImagePath = this.getImgUrl + response.data;  // 保存 URL 到表单
      }
    },
    //身份证手持上传成功
    handleSuccess_userWithIdCardImagePath(response) {
      if (response.code === 200) {
        this.form.userWithIdCardImagePath = this.getImgUrl + response.data;  // 保存 URL 到表单
      }
    },
    //护照照片上传成功
    handleSuccess_passportImagePath(response) {
      if (response.code === 200) {
        this.form.passportImagePath = this.getImgUrl + response.data;  // 保存 URL 到表单
      }
    },
    /** 获取地址列表 */
    getAddress() {
      this.loading = true;
      getAddress(this.$i18n.locale).then(response => {
        this.options_addr = response.data;
      });
    },
    /** 地址联动事件 **/
    handleChange(value) {
      this.form.addr = value;
    }
  }
};
</script>
