<template>
  <div class="page md:flex md:justify-between">
    <div class="page-title">机构认证</div>
    <div class="page-top">
      <div class="swiper">
        <SimpleSwiper :imageList="clubInfo.bannerList"></SimpleSwiper>
        <img
          class="auth-card"
          :src="authCardImage"
          @click="onShowAuthCard"
          v-if="!showAuthCard"
        />
      </div>
    </div>
    <div class="page-content">
      <div class="bg-container">
        <!-- 机构信息 -->
        <div class="club-info">
          <div class="section flex justify-between items-center">
            <div class="info">
              <div class="name" v-text="clubInfo.authParty"></div>
              <div class="mobile" @click="callMobile(clubInfo.mobile)">
                {{ clubInfo.mobile | formatEmpty }}
              </div>
              <div class="address" v-text="address"></div>
            </div>
            <div class="logo"><img :src="clubInfo.logo" /></div>
          </div>
          <div class="section flex justify-between items-center mt-6">
            <div class="navigation" @click="onMapNav">导航</div>
            <div
              class="distance"
              v-if="clubInfo.distance && clubInfo.distance < 99999"
              v-text="'距你' + clubInfo.distance + 'km'"
            ></div>
          </div>
        </div>
        <!-- 机构授权信息 -->
        <div class="auth">
          <div class="auth-icon"></div>
          <div class="auth-info">
            <span class="font-bold">{{ supplierInfo.shopName }}</span>
            <span class="font-bold">授予</span>
            <span class="font-bold">{{ clubInfo.authParty }}</span>
            <span class="flag">正品拥有</span>
          </div>
        </div>
      </div>
      <!-- 分割 -->
      <div class="divider"></div>
      <div class="device-list">
        <div class="title">已认证设备</div>
        <div class="list">
          <div
            class="device flex justify-between items-center"
            v-for="item in clubInfo.productList"
            :key="item.productId"
          >
            <div class="info">
              <div class="name" v-text="item.productName"></div>
              <div class="code">SN码：{{ item.snCode | formatSnCode }}</div>
            </div>
            <div class="detail" @click="toDetail(item)">查看认证</div>
          </div>
        </div>
      </div>
      <SimpleEmpty
        v-if="isEmpty"
        name="icon-empty-device.png"
        description="暂无已认证设备"
      ></SimpleEmpty>
    </div>

    <SimpleMapNav
      ref="mapNav"
      @click="navigation"
      color="#f3920d"
    ></SimpleMapNav>

    <!-- 授权牌弹窗 -->
    <div class="mask" v-if="showAuthCard" @click="onHideAuthCard"></div>
    <transition
      enter-active-class="animate__zoomIn"
      leave-active-class="animate__zoomOut"
    >
      <div class="auth-card-content animate__animated" v-if="showAuthCard">
        <div class="auth-card-popup">
          <span class="el-icon-circle-close" @click="onHideAuthCard"></span>
          <img :src="authCardImage" />
        </div>
      </div>
    </transition>
  </div>
</template>

<script>
import clubDetailMixin from '@/mixins/clubDetail'
export default {
  layout: 'app-ross',
  mixins: [clubDetailMixin],
}
</script>

<style scoped lang="scss">
.mask {
  width: 100vw;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 8;
  background: rgba(0, 0, 0, 0.5);
}

// pc 端
@media screen and (min-width: 768px) {
  .page {
    position: relative;
    width: 1200px;
    height: 612px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 80px;
    background-color: #fff;
    box-sizing: border-box;
    padding: 16px;
    padding-right: 0;
  }

  .auth-card-content {
    width: 100vw;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9;
    .auth-card-popup {
      position: relative;
      width: 622px;

      img {
        display: block;
        width: 100%;
        height: auto;
      }

      .el-icon-circle-close {
        position: absolute;
        top: -50px;
        right: 0;
        font-size: 32px;
        color: #fff;
        cursor: pointer;
      }
    }
  }

  .page-title {
    position: absolute;
    font-size: 24px;
    color: #333;
    top: -50px;
    left: 0;
  }

  .page-top {
    margin-right: 24px;
    .swiper {
      position: relative;
      width: 580px;
      height: 580px;
      background: #f7f7f7;
      ::v-deep {
        img {
          width: 580px;
          height: 580px;
        }
      }

      .auth-card {
        position: absolute;
        width: auto;
        height: 110px;
        display: block;
        bottom: 24px;
        left: 24px;
        z-index: 2;
        cursor: pointer;
      }
    }
  }

  .page-content {
    width: 580px;
    overflow-y: auto;

    &::-webkit-scrollbar {
      width: 8px;
      // background-color: #eeeeee;
    }

    &::-webkit-scrollbar-thumb {
      border-radius: 4px;
      background-color: #eeeeee;
    }

    .bg-container {
      background: url(~assets/theme-images/ross/h5-club-info-bg.png) center
        no-repeat;
      background-size: 100%;
      box-sizing: border-box;
      background-position-y: 20px;
      background-color: #f3920d;
      padding-bottom: 24px;
    }

    .auth {
      width: 524px;
      box-sizing: border-box;
      background: #fef5e8;
      margin: 0 auto;
      margin-top: 8px;
      padding: 12px 16px;
      border-radius: 2px;

      .auth-icon {
        height: 28px;
        background: url(~assets/theme-images/ross/h5-icon-auth.png) no-repeat
          left center;
        background-size: auto 28px;
      }

      .auth-info {
        font-size: 0;
        margin-top: 10px;
        span {
          font-size: 20px;
          line-height: 1.6;
          color: #f3920d;

          &.font-bold {
            font-weight: bold;
          }
        }
      }
    }

    .club-info {
      padding: 32px 24px;
      width: 564px;
      min-height: 264px;

      .info {
        width: 360px;
        .name {
          font-size: 24px;
          color: #fff;
          font-weight: bold;
          margin-bottom: 34px;
        }
        .mobile,
        .address {
          position: relative;
          padding-left: 28px;
          margin-top: 16px;
          line-height: 24px;
          font-size: 16px;
          color: #fff;

          &::after {
            content: '';
            display: block;
            width: 24px;
            height: 24px;
            position: absolute;
            left: 0;
            top: 0;
            background-size: 20px;
            background-repeat: no-repeat;
            background-position: center;
          }
        }
        .mobile {
          cursor: pointer;
          &::after {
            @include themify($themes) {
              background-image: themed('pc-icon-mobile');
            }
          }
        }
        .address {
          &::after {
            @include themify($themes) {
              background-image: themed('h5-icon-address');
            }
          }
        }
      }

      .logo {
        position: relative;
        width: 114px;
        height: 114px;
        border-radius: 50% 50% 0 50%;
        overflow: hidden;
        background: #fff;
        display: flex;

        &::after {
          position: absolute;
          bottom: 0;
          right: 0;
          content: '';
          display: block;
          width: 23px;
          height: 23px;
          background: url(~assets/theme-images/ross/pc-icon-avatar-v.png)
            no-repeat center;
          background-size: 23px;
        }
      }
      .navigation {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 72px;
        height: 32px;
        border-radius: 4px;

        font-size: 16px;
        color: #f3920d;
        border: 1px solid #fff;
        background-color: #fff;
        cursor: pointer;

        &::after {
          content: '';
          display: block;
          width: 16px;
          height: 16px;
          margin-left: 4px;
          @include themify($themes) {
            background: themed('pc-icon-navigation') no-repeat center;
          }
          background-size: 16px;
        }
      }
      .distance {
        font-size: 14px;
        color: #fff;
      }
    }

    .device-list {
      .title {
        position: relative;
        font-size: 20px;
        font-weight: bold;
        color: #282828;
        line-height: 30px;
        padding-left: 32px;
        margin-top: 46px;
        margin-bottom: 24px;

        &::before {
          content: '';
          display: block;
          width: 30px;
          height: 30px;
          background: url(~assets/theme-images/ross/pc-icon-device-list.png)
            no-repeat center;
          position: absolute;
          left: 0;
          top: 0;
        }
      }

      .list {
        padding-right: 16px;
      }

      .device {
        padding: 20px 16px;
        box-sizing: border-box;
        background: #f3f5f6;
        margin-top: 16px;

        &:first-child {
          margin-top: 0;
        }

        .info {
          width: 80%;
          .name {
            font-size: 18px;
            color: #282828;
          }
          .code {
            margin-top: 12px;
            font-size: 14px;
            color: #666;
          }
        }
        .detail {
          display: flex;
          justify-content: center;
          align-items: center;
          width: 80px;
          height: 32px;
          border-radius: 4px;
          font-size: 14px;
          color: #ffffff;
          cursor: pointer;
          @include themify($themes) {
            background: themed('color');
          }
        }
      }
    }
  }
}

// 移动 端
@media screen and (max-width: 768px) {
  .page-title {
    display: none;
  }

  .auth-card-content {
    width: 100vw;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9;
    .auth-card-popup {
      position: relative;
      width: 86vw;

      img {
        display: block;
        width: 100%;
        height: auto;
      }

      .el-icon-circle-close {
        position: absolute;
        top: -8vw;
        right: 0;
        font-size: 7vw;
        color: #fff;
        cursor: pointer;
      }
    }
  }

  .page-top {
    .swiper {
      position: relative;
      height: 100vw;

      background: #f7f7f7;
      ::v-deep {
        img {
          height: 100vw;
        }
      }

      .auth-card {
        position: absolute;
        width: auto;
        height: 20.6vw;
        display: block;
        bottom: 4vw;
        left: 4vw;
        z-index: 2;
      }
    }
  }

  .page-content {
    .bg-container {
      background: url(~assets/theme-images/ross/h5-club-info-bg.png) center
        no-repeat;
      background-size: 100vw;
      box-sizing: border-box;
      background-position-y: 4vw;
      background-color: #f3920d;
      padding-bottom: 5vw;
    }

    .auth {
      width: 92vw;
      box-sizing: border-box;
      background: #fef5e8;
      margin: 0 auto;
      margin-top: 3.2vw;
      padding: 4vw 3.5vw;
      border-radius: 0.8vw;

      .auth-icon {
        height: 6.2vw;
        background: url(~assets/theme-images/ross/h5-icon-auth.png) no-repeat
          left center;
        background-size: auto 6.2vw;
      }

      .auth-info {
        font-size: 0;
        margin-top: 2.2vw;
        span {
          font-size: 3.6vw;
          line-height: 5.8vw;
          color: #f3920d;

          &.font-bold {
            font-weight: bold;
          }
        }
      }
    }
    .club-info {
      padding: 4vw;
      width: 100vw;
      min-height: 43.4vw;

      .info {
        width: 67vw;
        .name {
          font-size: 4.8vw;
          color: #fff;
          font-weight: bold;
          margin-bottom: 4vw;
        }
        .mobile,
        .address {
          position: relative;
          padding-left: 5vw;
          margin-top: 1.6vw;
          line-height: 5vw;
          font-size: 3.2vw;
          color: #fff;

          &::after {
            content: '';
            display: block;
            width: 4vw;
            height: 5vw;
            position: absolute;
            left: 0;
            top: 0;
            background-size: 4vw 4vw;
            background-repeat: no-repeat;
            background-position: center;
          }
        }
        .mobile {
          &::after {
            @include themify($themes) {
              background-image: themed('h5-icon-mobile');
            }
          }
        }
        .address {
          &::after {
            @include themify($themes) {
              background-image: themed('h5-icon-address');
            }
          }
        }
      }

      .logo {
        position: relative;
        width: 18vw;
        height: 18vw;
        border-radius: 9vw 9vw 0 9vw;
        overflow: hidden;
        background: #fff;
        display: flex;

        &::after {
          position: absolute;
          bottom: 0;
          right: 0;
          content: '';
          display: block;
          width: 3.6vw;
          height: 3.6vw;
          background: url(~assets/theme-images/ross/h5-icon-avatar-v.png)
            no-repeat center;
          background-size: 3.6vw;
        }
      }
      .navigation {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 14.4vw;
        height: 6.4vw;
        border-radius: 0.4vw;
        font-size: 3.2vw;
        color: #f3920d;
        border: 1px solid #fff;
        background-color: #fff;

        &::after {
          content: '';
          display: block;
          width: 3.6vw;
          height: 3.6vw;
          margin-left: 0.4vw;
          @include themify($themes) {
            background: themed('h5-icon-navigation') no-repeat center;
            background-size: 3.6vw;
          }
        }
      }
      .distance {
        font-size: 3vw;
        color: #fff;
      }
    }

    .device-list {
      padding: 0 4vw;
      .title {
        position: relative;
        padding-left: 6.8vw;
        margin-top: 9.6vw;
        margin-bottom: 4vw;
        font-size: 4vw;
        font-weight: bold;
        color: #101010;

        &::before {
          content: '';
          display: block;
          width: 4.4vw;
          height: 4.4vw;
          background: url(~assets/theme-images/ross/h5-icon-device-list.png)
            no-repeat center;
          position: absolute;
          left: 0;
          top: 0;
        }
      }
      .device {
        padding: 4.4vw 3.2vw;
        background: #f3f5f6;
        margin-bottom: 3.2vw;
        .info {
          width: 74%;
          .name {
            font-size: 3.6vw;
            color: #282828;
          }
          .code {
            margin-top: 3.2vw;
            font-size: 3vw;
            color: #666;
          }
        }
        .detail {
          display: flex;
          justify-content: center;
          align-items: center;
          width: 15.8vw;
          height: 6.4vw;
          border-radius: 0.4vw;
          font-size: 3vw;
          color: #ffffff;
          @include themify($themes) {
            background: themed('color');
          }
        }
      }
    }
  }
}
</style>
