<template>
  <div>
    <div >
      <el-tabs v-model="xiangTab">
        <el-tab-pane label="商家信息" name="first">
          <div style="margin-top: 30px;" class="editcss">
            <TitleWithCircle title="基础信息" />
            <div style="padding: 20px;margin-top: 10px;">
              <el-form :model="info" ref="ruleForm" label-width="140px" class="demo-ruleForm">
                <el-row :gutter="20">
                  <el-col :span="9">
                    <el-form-item label="姓名" prop="name">
                      <div class="duiqi">{{info.name}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9">
                    <el-form-item label="手机号" prop="phone">
                      <div class="duiqi">{{info.phone}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-row :gutter="20">
                  <el-col :span="9">
                    <el-form-item label="证件类型" prop="idCardType">
                      <div class="duiqi">{{info.idCardType}}</div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9">
                    <el-form-item label="身份证号码" prop="idCardNumber">
                      <div class="duiqi">{{info.idCardNumber}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>
                <el-form-item label="身份证照片（正）" prop="idCardFrontImage">
                  <!-- <div style="margin-top: 10px;">
                    <el-image style="width: 200px;" :src="$baseURL+info.idCardFrontImage" fit="contain"></el-image>
                  </div> -->
                  <div style="display: flex;">
                    <allimg v-if="item" :src="item" fit="contain"  v-for="item in info.idCardFrontImage.split(',')" style="width: 112px;height: 112px;border: 1px dotted #dcdfe6;border-radius: 2px;overflow: hidden;margin: 0 10px 10px 0;"/>
                  </div>
                </el-form-item>
                <el-form-item label="身份证照片（反）" prop="idCardBackImage">
                  <!-- <div style="margin-top: 10px;">
                    <el-image style="width: 200px;" :src="$baseURL+info.idCardBackImage" fit="contain"></el-image>
                  </div> -->
                  <div style="display: flex;">
                    <allimg v-if="item" :src="item" fit="contain"  v-for="item in info.idCardBackImage.split(',')" style="width: 112px;height: 112px;border: 1px dotted #dcdfe6;border-radius: 2px;overflow: hidden;margin: 0 10px 10px 0;"/>
                  </div>
                </el-form-item>
              </el-form>
            </div>
            <!-- <TitleWithCircle title="审核信息" />
            <div style="padding: 20px;margin-top: 10px;">
              <el-form :model="info" ref="ruleForm" label-width="140px" class="demo-ruleForm">
                <el-row :gutter="20">
                  <el-col :span="9">
                    <el-form-item label="审核状态" prop="name">
                      <div class="duiqi">
                        <span v-if="info.checkState == '1'">待审核</span>
                        <span v-else-if="info.checkState == '2'">同意</span>
                        <span v-else-if="info.checkState == '3'">拒绝</span>
                      </div>
                    </el-form-item>
                  </el-col>
                  <el-col :span="9" v-if="info.checkState != '1' && info.checkOpinion">
                    <el-form-item label="审核意见" prop="phone">
                      <div class="duiqi">{{info.checkOpinion}}</div>
                    </el-form-item>
                  </el-col>
                </el-row>
              </el-form>
            </div> -->
            <!-- <div style="padding: 20px;margin-top: 10px;">
              <el-table :data="list"
                :header-cell-style="{fontSize: '14px',color:'#0009',fontWeight: 'normal',backgroundColor:'#F2F3F5'}">

                <el-table-column label="审核时间">
                  <template slot-scope="scope">
                    {{scope.row.contractChangeReason}}

                  </template>
                </el-table-column>
                <el-table-column label="审核结果">
                  <template slot-scope="scope">
                    {{scope.row.updateDate}}

                  </template>
                </el-table-column>
                <el-table-column label="驳回意见">
                  <template slot-scope="scope">
                    {{scope.row.updateDate}}

                  </template>
                </el-table-column>
              </el-table>

            </div> -->
          </div>
        </el-tab-pane>
      </el-tabs>
    </div>
    <div v-if="info.checkState == '1' && issp == '2'">
      <TitleWithCircle title="审核情况"/>
      <div style="padding: 20px;">
        <el-form :model="info" label-width="100px" class="demo-ruleForm">
          <el-form-item label="状态" style="align-items: center;">
            <el-radio v-model="radio" label="2">通过</el-radio>
            <el-radio v-model="radio" label="3">不通过</el-radio>
          </el-form-item>
          <el-form-item label="审核意见">
            <el-input maxlength="200" show-word-limit rows="4" v-model="checkOpinion" placeholder="请输入审核意见"
              type="textarea" />
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div v-if="info.checkState == '2' || info.checkState == '3'">
      <TitleWithCircle title="审核结果"/>
      <div style="padding: 20px;">
        <el-form :model="info" label-width="100px" class="demo-ruleForm" >
          <el-form-item label="状态">
            <div class="duiqi">{{info.checkState=='2'?'已通过':info.checkState=='3'?'不通过':'无'}}</div>
          </el-form-item>
          <el-form-item label="审核意见">
            <div class="duiqi">{{info.checkOpinion || '无'}}</div>
          </el-form-item>
        </el-form>
      </div>
    </div>
    <div>
      <el-button v-if="info.checkState == '1' && issp == '2'" @click="minSev"
      style="background-color: #3F9B6A;color: #fff;">确定</el-button>
      <el-button class="buttonHover"
        style="color: #606266;border: 1px solid #dddfe5;background-color: #fff;margin-top: 20px;"
        @click="changetype">返回</el-button>
    </div>
  </div>
</template>

<script>
  import {
    cerePlatformMerchantedit
  } from '@/api/newly.js'
  import TitleWithCircle from '@/components/top/index';
  import allimg from '@/components/chakan/allimg.vue';
  export default {
    components: {
      TitleWithCircle,
      allimg
    },
    props: {
      info: {
        type: Object,
        default: function() {
          return {}; // 返回一个空数组作为默认值
        },
      },
      issp: {
        type: String,
        default: function() {
          return '1';
        },
      },
    },
    data() {
      return {
        checkOpinion:'',
        radio: '2',
        xiangTab: 'first',
        list: [],
      }
    },
    created() {
    },
    computed: {

    },
    methods: {
      minSev() {
        let that = this
        console.error(this.info)
        // return
        cerePlatformMerchantedit({
          ...this.info,
          'checkState': this.radio,
          checkOpinion: this.checkOpinion?this.checkOpinion:null
        }).then(res => {
          console.error(res)
          if (res.code == 200) {
            this.$message({
              message: '处理成功',
              type: 'success'
            })
            that.setmsg()
            this.info.checkState = this.radio
            this.$emit('removeonaction', '1')
          } else {
            this.$message({
              message: '处理失败',
              type: 'error'
            })
          }
        })
      },
     async setmsg() {
        let info = {
          type:'通知消息',
          phone:this.info.phone,
          content:{
            type:'1',
            title:this.radio=='2'?'商家审核已通过':this.radio=='3'?'商家审核已驳回':'商家',
            content:this.checkOpinion
          },
        }
        await this.$setmsg(info);
      },
      changetype(){
        this.xiangTab= 'first'
        this.$emit('removeonaction', '1')
      },
    }
  }
</script>
<style>
  .el-form-item__label {
    color: #a2a2a2;
  }
  
  .greens {
    color: #3F9B6A;
  }
</style>
