<template>
  <div class="brand" style="padding-top: 25px; margin-bottom: -20px;">
    <div class="brand-content-list">
      <ul class="list-unstyled list-inline">
        <li class="store-box"  v-if="storeInfo.qualifications || storeInfo.qualifications.length !== 0" v-for="(store, index) in storeInfo.qualifications.slice(0,5)">
          <div><img :src="store.resourceUrl.indexOf('.pdf')>0?'/images/store/common/pdf.jpg':store.resourceUrl"/></div>
          <a @click="showImg(store.resourceUrl)"><div class="Open"><i class="fa fa-search"></i>&nbsp;&nbsp;查看</div></a>
        </li>
        <li class="active-empty" v-if="!storeInfo.qualifications || storeInfo.qualifications.length == 0">
          <div class="text-center">
            <div class="col-xs-offset-3 col-xs-2">
              <img src="/images/brandList/empty-cart.jpg">
            </div>
            <div class="col-xs-4 txt-info">
              <p class="grey f16"> 暂无资质证明</p>
               <i class="iconfont" v-if="emptyShow === false">&#xe610;</i>&nbsp;<a href="/" v-if="emptyShow === false">返回首页</a>
               <img v-if="emptyShow === true" src="/images/brandList/upload.png">&nbsp;<a v-if="emptyShow === true" href="/vendor#/store/maintain" target="_blank">马上去上传</a>
            </div>
          </div>
        </li>
      </ul>
    </div>
    <div class="shadow"><img src="/images/store/common/shadow.png"></div>
    <!--查看大图 begin-->
    <div id="image-box" v-if="isShow">
      <div class="x-floating-wrap"></div>
      <div class="x-floating">
        <div id="item-content">
          <div class="x-close-wrap" @click="isShow = false"><a href="javascript:void(0);">&times;</a></div>
          <div class="img"><img :src="qualifications.url"/></div>
        </div>
      </div>
    </div>
    <!--查看大图 end-->
  </div>
</template>
<script>
  export default {
    name: 'qualification-certificate',
    data () {
      return {
        qualifications: {
          url: '',
          type: ''
        },
        type: 0,
        isShow: false
      }
    },
    computed: {
      storeInfo () {
        return this.$store.state.shop.storeInfo.store.data
      },
      user() {
        return this.$store.state.option.user
      },
      storeStatus () {
        return this.$store.state.option.storeStatus.data
      },
      emptyShow () {
        let loggedStatus = false
        if (this.user.logged && this.user.data.enterprise.uu) {
          if (this.storeStatus.uuid === this.storeInfo.uuid) {
            loggedStatus = true
          } else {
            loggedStatus = false
          }
        } else {
          loggedStatus = false
        }
        return loggedStatus
      }
    },
    methods: {
      showImg (imgUrl) {
        if (imgUrl.indexOf('.pdf') === -1) {
          this.qualifications.url = imgUrl
          this.isShow = true
        } else {
          window.open(imgUrl)
        }
      }
    },
    filters: {
      introduceFilter: function (title) {
        if (title === '') {
          return title
        }
        let len = 0
        let index = 0
        for (let i = 0; i < title.length; i++) {
          if (index === 0 && title.charAt(i).charCodeAt(0) > 255) {
            len = len + 2
          } else {
            len++
          }
          if (len > 240) {
            index = i
            break
          }
        }
        if (index > 0) {
          return title.substring(0, index) + '...'
        } else {
          return title
        }
      }
    }
  }
</script>
<style  lang="scss" scoped>
  /*查看大图*/
  #image-box .x-floating-wrap,.image-box .x-floating-wrap {
    position: fixed;
    z-index: 99998;
    background: #000;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0.5;
  }
  #image-box,.image-box{
    display:table; overflow:hidden; margin-left:50px; _position:relative;  width: 1200px;height: 700px;
    position: fixed;
    top: 50%;
    margin-top: -350px;
    left: 50%;
    margin-left: -600px;
    z-index: 2000;
  }
  #image-box .x-floating,.image-box .x-floating {
    vertical-align:middle !important;
    display:table-cell;
    text-align:center;
    _position:absolute;
    _top:50%; _left:50%;
    top: inherit !important;
    left: inherit !important;
  }
  #image-box .x-floating img ,.image-box .x-floating img {
    margin: auto auto;
    max-width: 970px !important;
    max-height: 600px !important;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
  }
  #image-box .x-floating-wrap,.image-box .x-floating-wrap{
    z-index: 1000000 !important;
  }
  #item-content{
    color:#fff; display:inline-block; _position:relative; _top:-50%; _left:-50%;
    position: relative;
    z-index: 10000000;
  }
  #item-content div.x-close-wrap{
    position: absolute;
    right: -15px;
    line-height: 30px;
    top: -13px;
    color: #fff;
    width: 35px;
    height: 35px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 100%;
    opacity: 1;
    margin: 0;
    z-index: 100000;
    min-height: initial;
    text-align: center;
  }
  #item-content div.x-close-wrap a{
    position: relative;
    left: 0;
    bottom: 0;
    font-size: 34px;
    color: #fff;
  }
  #item-content div.x-close-wrap a:hover{
    color: #fff !important;
  }
  #item-content div.x-close-wrap:hover{
    cursor: pointer;
    opacity: .9;
  }
  #item-content div.x-close-wrap img{
    width: 30px !important;
    height: 30px !important;
  }
  #item-content .img{
    position: relative;
    z-index: 10;
  }
  /*查看大图结束*/
  .brand-content-list{
    width: 1190px;
    background: #fff;
    margin: 0 auto;
    margin-top: -50px;
    padding-left: 18px;
    .list-inline {
      width: 100%;
      height: 264px;
      margin: 0 auto;
      .store-box {
        width: 158px;
        height: 200px;
        text-align: center;
        vertical-align: middle;
        margin: 32px 0px 0px 40px;
        position: relative;
        &:hover{
          div:last-child {
            display: block;
          }
        }
        &:first-child {
          margin-left:112px;
        }
        div:first-child {
          img {
            margin-left: -3px;
            width: 156px;
            height: 200px;
            border: 1px solid #edf0f4;
          }
        }
        div:last-child {
          width: 176px;
          height: 218px;
          line-height: 218px;
          background: #6b6b6b;
          opacity: 0.5;
          position: absolute;
          top: -9px;
          left: -9px;
          display: none;
          color: #fff;
          span{
            color: #fff;
            &:first-child{
              margin-top: 30px;
            }
          }
        }
      }
      .active-empty{
        width: 100%;
        .text-center{
          text-align: center;
          margin-top: 30px;
        }
        .text-center  .col-xs-2  img{
          margin: 65px 0 85px 205px;
          vertical-align: middle;
        }
        .text-center .txt-info{
          font-size: 14px;
          margin: 60px 0px 0px -50px;
        }
        .text-center  .col-xs-4  p{
          color: #999;
          margin: 13px 0px 10px -6px;
        }
        .text-center  .txt-info i{
          color: #5078cb;
        }
        .text-center  .txt-info a{
          font-size: 14px;
          color: #5078cb;
        }
        .text-center  .col-xs-5 img{
          margin-left: -235px;
        }
      }
    }
  }
  .shadow{
    width: 1190px;
    margin: 0 auto;
    img{
      position: relative;
      top: -10px;
    }
  }
</style>
