<template>
  <el-dialog title="单身认证信息" :close-on-click-modal="false" :visible.sync="open" width="500px" append-to-body>
    <p>本人姓名: <span class="font-value">{{singleJson.name}}</span>，
    性别:<span class="font-value">{{singleJson.gender}}</span>，
    民族:<span class="font-value">{{singleJson.nation}}</span>，
    出生年月: {{singleJson.birthday}}，
    身份证号: <span class="font-value">{{singleJson.idCard}}</span>，
    住址:<span class="font-value">{{singleJson.residenceName}}</span>，
    婚姻状况: <span class="font-value">{{singleJson.marriage}}</span>
    </p>
    <p>本人上述声明完全真实，如有虚假，愿承担全部的法律及经济责任。</p>
    <p>见证方:江西木白文化科技有限公司</p>
    <p style="display: flex; align-items: center;">声明人:<img style="width: 79px;height: 50px;margin-left: 5px;" :src="singleJson.signatureImage" alt="签名"></p>
    <div slot="footer" class="dialog-footer">
      <el-button v-if="auditStatus === 1" :loading="buttonLoading" type="primary" @click="submitSuccess">通过</el-button>
      <el-button v-if="auditStatus === 1" :loading="buttonLoading" type="danger" @click="submitFail">不通过</el-button>
      <el-button @click="open = false">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { userAuthAuditFail, userAuthAuditSuccess } from '@/api/xq/userAuthAudit'

export default {
  name: "UserInfo",
  data() {
    return {
      open:false,
      buttonLoading: false,
      auditStatus: undefined,
      singleJson: {},
      id: undefined,
    };
  },
  created() {

  },
  methods: {
    init(row){
      this.open = true;
      this.id = row.id
      this.auditStatus = row.auditStatus
      this.singleJson = JSON.parse(row.authOther)
    },
    submitSuccess(){
      this.$modal.confirm('是否确认审核通过用户单身认证？').then(() => {
        this.buttonLoading = true
        return userAuthAuditSuccess({ 'ids': this.id })
      }).then(() => {
        this.buttonLoading = false
        this.$modal.msgSuccess('操作成功')
        this.open = false
        this.$emit('refreshDataList')
      }).catch(() => {
      }).finally(() => {
        this.buttonLoading = false
      })
    },
    submitFail(){
      this.$prompt('请输入失败原因', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        inputPattern: /^.+$/,
        inputErrorMessage: '失败原因必填',
        inputType: 'textarea'
      }).then(({ value }) => {
        this.buttonLoading = true
        return userAuthAuditFail({
          'auditRemark': value,
          'id': this.id
        })
      }).then(() => {
        this.buttonLoading = false
        this.$modal.msgSuccess('操作成功')
        this.open = false
        this.$emit('refreshDataList')
      }).catch(() => {
      }).finally(() => {
        this.buttonLoading = false
      })
    }
  }
};
</script>
<style lang="scss" scoped>
.el-row {
  margin-bottom: -15px;
  display: flex;
  flex-wrap: wrap
}
.font-value {
  font-weight: bold;
  margin-left: 5px;
}
</style>
