<template>
  <Page :show-operation="false" title="车主实名查询">
    <div class="page-user-search">
      <div class="container">
        <div class="content">
          <div v-if="list.length > 0" class="identify-list">
            <div v-for="(item, key) in list" :key="key" class="identify-item">
              <!-- card title -->
              <div class="identify-title">
                <!-- 左边认证状态 -->
                <div class="identify-status">
                  <!-- <img :src="identifyStatus[item.status].leftIcon" alt="" class="status-ico"> -->
                  <div :class="'status-circle-' + identifyStatus[item.cardStatus].leftIcon" class="status-circle"/>
                  <span :style="'color:' + identifyStatus[item.cardStatus].textColor" class="">{{ identifyStatus[item.cardStatus].leftText }}{{ item.cardStatus == 2 && item.auditReason ? `：${item.auditReason}` : '' }}</span>
                  <span class="identify-desc">{{ identifyStatus[item.cardStatus].leftDesc }}</span>
                </div>
                <!-- 右边按钮 -->
                <div v-if="identifyStatus[item.cardStatus].rightBtn" class="identify-bind" @click="toBind(identifyStatus[item.cardStatus].rightUrl, item)">
                  <img :src="identifyStatus[item.cardStatus].rightIcon" alt="" class="bind-ico">
                  <span>{{ identifyStatus[item.cardStatus].rightText }}</span>
                </div>
              </div>
              <div class="identify-info">
                <span class="identify-text1">VIN码</span>
                <span class="identify-text2">{{ item.vin }}</span>
              </div>
              <div class="identify-info">
                <span class="identify-text1">ICCID</span>
                <span class="identify-text2">{{ item.iccid }}</span>
              </div>
              <div class="identify-info">
                <span class="identify-text1">申请时间</span>
                <span class="identify-text2">{{ item.createTime }}</span>
              </div>
            </div>
          </div>
          <div v-else class="page-rnr-main-card">
            <van-empty :image="require('@/assets/search/empty.png')" description="未查询到认证信息" />
          </div>
        </div>
      </div>
    </div>
  </Page>
</template>

<script>
import { identifyStatus } from './config'
import { rnrRecord } from '@/api/user'
import LogOut from '@/components/LogOut'
import Page from '@/components/Page'

export default {
  name: 'User',
  components: {
    Page,
    LogOut
  },
  data() {
    return {
      identifyStatus,
      params: {
        currPage: 1,
        pageSize: 100
      },
      logo: this.$store.getters.logo,
      list: []
    }
  },
  activated() {
    // 获取认证记录
    this.getRnrRecord()
  },
  methods: {
    // 获取认证记录
    getRnrRecord() {
      rnrRecord(this.params).then(res => {
        this.list = res.list
      })
    },
    // 去解绑
    toBind(urlName, item) {
      this.$router.push({
        name: urlName,
        params: {
          iccid: item.iccid,
          rnrId: item.rnrId,
          vin: item.vin
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.page-user-search {
  .container {
    position: relative;
    padding: 0 32px;

    .bg {
      position: absolute;
      top: 29px;
      right: 0;
      width: 468px;
      height: 664px;
    }
    .content {
      .logo {
        width: auto;
        height: 48px;
        margin-top: 56px;
      }
      .title {
        margin-top: 112px;
        width: 347px;
        height: 47px;
        display: block;
      }
      .line {
        width: 163px;
        height: 3px;
        margin: 38px 0 36px;
        background-image: linear-gradient(90deg, #2C38D2 0%, #61A2F9 50%, #fff 100%);
      }
      .text {
        width: 380px;
        font-size: 26px;
        line-height: 36px;
        color: #596B97;
        font-weight: 400;
        margin-bottom: 67px;
      }
      .ml15 {
        margin-left: 15px;
      }
      .identify-list {
        .identify-item {
          width: 624px;
          padding: 32px 32px 8px;
          background: #FFFFFF;
          box-shadow: 0px 2px 12px 0px rgba(75,106,181,0.05);
          border-radius: 24px;
          margin: 0 auto 24px;
          .identify-title {
            display: flex;
            flex-direction: row;
            justify-content: space-between;
            margin-bottom: 17px;
          }
          .identify-status {
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            align-items: center;
            .status-ico {
              width: 20px;
              height: 20px;
              margin-right: 10px;
            }
            .status-circle {
              width: 12px;
              height: 12px;
              border-radius: 12px;
              margin-right: 16px;
              position: relative;
              top: -3px;
            }
            .status-circle-ing {
              background: #352FD1;
              box-shadow: 0px 1px 10px 1px #352FD1;
            }
            .status-circle-no {
              background: #39D3EA;
              box-shadow: 0px 1px 10px 1px #39D3EA;
            }
            .status-circle-failed {
              background: #F16E6F;
              box-shadow: 0px 1px 10px 1px #F16E6F;
            }
            .status-circle-success {
              background: #7DD164;
              box-shadow: 0px 1px 10px 1px #7DD164;
            }
            span {
              display: block;
              font-size: 24px;
              font-weight: 400;
              line-height: 33px;

            }
            .identify-desc {
              font-size: 24px;
              color: #D1D1D1;
              font-weight: 400;
              margin-left: 23px;
              line-height: 33px;
            }
          }
          .identify-bind {
            display: flex;
            flex-direction: row;
            justify-content: flex-start;
            font-size: 28px;
            line-height: 40px;
            color: #0761F3;
            text-align: center;
            font-weight: 500;
            align-items: center;
            .bind-ico {
              width: 26px;
              height: 26px;
              margin-right: 8px;
            }
          }
        }
        .identify-info {
          margin-bottom: 24px;
          .identify-text1 {
            font-size: 32px;
            color: #000000;
            font-weight: 400;
            line-height: 45px;
            width: 155px;
            display: inline-block;
          }
          .identify-text2 {
            font-size: 32px;
            color: #272727;
            font-weight: 400;
            line-height: 45px;
            opacity: 0.5;
          }
        }
      }
    }
  }
}
</style>

<style lang="scss">
.page-user-search {
  .van-empty {
    .van-empty__image {
      width: 354px;
      height: 264px;
    }
    .van-empty__description {
      color: #242424;
      font-size: 32px;
      font-weight: 400;
      text-align: center;
      opacity: 0.4;
      margin-top: 28px;
    }
  }
}
</style>
