<template>
  <view class="template-card tn-safe-area-inset-bottom">
    <!-- 顶部自定义导航 -->
    <!-- <tn-nav-bar fixed alpha customBack>
      <view slot="back" class='tn-custom-nav-bar__back'
        @click="goBack">
        <text class='icon tn-icon-left'></text>
        <text class='icon tn-icon-home-capsule-fill'></text>
      </view>
    </tn-nav-bar> -->

    <!-- 顶部自定义导航 -->
    <tn-nav-bar fixed :isBack="false" :bottomShadow="false" backgroundColor="#FFFFFF">
      <view class="custom-nav tn-flex tn-flex-col-center tn-flex-row-left">
        <!-- 图标logo -->
        <view class="custom-nav__back">
          <view class="logo-pic tn-shadow-blur"
            style="background-image:url('https://resource.tuniaokj.com/images/blogger/blogger_beibei.jpg')">
            <view class="logo-image">
            </view>
          </view>
          <!-- <view class="tn-icon-left"></view> -->
        </view>
        <!-- 搜索框 -->
        <view class="custom-nav__search tn-flex tn-flex-col-center tn-flex-row-center ">
          <view
            class="custom-nav__search__box tn-flex tn-flex-col-center tn-flex-row-left tn-color-gray--dark tn-bg-gray--light">
            <view class="custom-nav__search__icon tn-icon-search"></view>
            <view class="custom-nav__search__text tn-padding-left-xs">开启美好的一天</view>
          </view>
        </view>
      </view>
    </tn-nav-bar>

    <!-- 内容 -->
    <view :style="{paddingTop: vuex_custom_bar_height + 'px'}">

      <!-- 广告 -->
      <view class="swiper tn-padding" :style="{height: swiperContainerHeight + 'px'}">
        <tn-stack-swiper :list="list" direction="vertical" height="100%" :switchRate="10" :scaleRate="0.05" :translateRate="8"></tn-stack-swiper>
      </view>

    </view>


    <!-- 底部tabbar start-->
    <view class="tabbar footerfixed">
      <view class="action">
        <view class="bar-icon">
          <!-- <view class="tn-icon-home-smile">
          </view> -->
          <image class="" src='https://resource.tuniaokj.com/images/tabbar/shop-home.png'></image>
        </view>
        <view class="tn-color-black">门店</view>
      </view>
      <view class="action">
        <view class="bar-icon">
          <!-- <view class="tn-icon-watercup tn-color-gray">
          </view> -->
          <image class="" src='https://resource.tuniaokj.com/images/tabbar/shop-buy.png'></image>
        </view>
        <view class="tn-color-gray">点餐</view>
      </view>
      <view class="action">
        <view class="bar-icon">
          <!-- <view class="tn-icon-shop tn-color-gray">
          </view> -->
          <image class="" src='https://resource.tuniaokj.com/images/tabbar/shop-shop.png'></image>
        </view>
        <view class="tn-color-gray">商城</view>
      </view>
      <view class="action">
        <view class="bar-icon">
          <!-- <view class="tn-icon-ticket tn-color-gray">
          </view> -->
          <image class="" src='https://resource.tuniaokj.com/images/tabbar/shop-list.png'></image>
        </view>
        <view class="tn-color-gray">订单</view>
      </view>
      <view class="action">
        <view class="bar-icon">
          <!-- <view class="tn-icon-my tn-color-gray">
          </view> -->
          <image class="" src='https://resource.tuniaokj.com/images/tabbar/shop-my.png'></image>
        </view>
        <view class="tn-color-gray">我的</view>
      </view>
    </view>

    <!-- 回到首页悬浮按钮-->
    <nav-index-button></nav-index-button>

  </view>
</template>

<script>
  import NavIndexButton from '@/libs/components/nav-index-button.vue'
  export default {
    name: 'VipTemplateCard',
    components: {
      NavIndexButton
    },
    data() {
      return {
        // swiper容器高度
        swiperContainerHeight: 0,
        list: [{
            image: 'https://resource.tuniaokj.com/images/bless/bless-1.jpg'
          },
          {
            image: 'https://resource.tuniaokj.com/images/bless/bless-2.jpg'
          },
          {
            image: 'https://resource.tuniaokj.com/images/bless/bless-3.jpg'
          },
          {
            image: 'https://resource.tuniaokj.com/images/bless/bless-4.jpg'
          }
        ],
        autoplay: false
      }
    },
    onReady() {
      this.$nextTick(() => {
        this.initSwiperContainer()
      })
    },
    onShow() {
      this.autoplay = true
    },
    onHide() {
      this.autoplay = false
    },
    methods: {
      // 初始化轮播图容器
      initSwiperContainer() {
        // 获取底部tabbar信息
        this._tGetRect('.tabbar').then((res) => {
          if (!res.height) {
            setTimeout(() => {
              this.initSwiperContainer()
            }, 10)
            return
          }
          // 获取系统信息
          const systemInfo = uni.getSystemInfoSync()
          this.swiperContainerHeight = systemInfo.safeArea.height - res.height - 10
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  @import '@/static/css/templatePage/custom_nav_bar.scss';

  /* 自定义导航栏内容 start */
  .custom-nav {
    height: 100%;

    &__back {
      margin: auto 5rpx;
      font-size: 40rpx;
      margin-right: 10rpx;
      margin-left: 30rpx;
      flex-basis: 5%;
    }

    &__search {
      flex-basis: 60%;
      width: 100%;
      height: 100%;

      &__box {
        width: 100%;
        height: 70%;
        padding: 10rpx 0;
        margin: 0 30rpx;
        border-radius: 60rpx 60rpx 0 60rpx;
        font-size: 24rpx;
      }

      &__icon {
        padding-right: 10rpx;
        margin-left: 20rpx;
        font-size: 30rpx;
      }

      &__text {
        color: #AAAAAA;
      }
    }
  }

  .logo-image {
    width: 60rpx;
    height: 60rpx;
    position: relative;
    margin-top: -15rpx;
  }

  .logo-pic {
    background-size: cover;
    background-repeat: no-repeat;
    // background-attachment:fixed;
    background-position: top;
    border-radius: 50%;
  }

  /* 自定义导航栏内容 end */
  
  /* 轮播图 start */
  .swiper {
    border-radius: 10rpx;
    overflow: hidden;
  }
  /* 轮播图 end */

  /* 间隔线 start*/
  .tn-strip-bottom {
    width: 100%;
    border-bottom: 20rpx solid rgba(241, 241, 241, 0.8);
  }

  /* 间隔线 end*/

  /* 底部tabbar start*/
  .footerfixed {
    position: fixed;
    width: 100%;
    bottom: 0;
    z-index: 999;
    background-color: #FFFFFF;
    box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
  }

  .tabbar {
    display: flex;
    align-items: center;
    min-height: 110rpx;
    justify-content: space-between;
    padding: 0;
    height: calc(110rpx + env(safe-area-inset-bottom) / 2);
    padding-bottom: calc(env(safe-area-inset-bottom) / 2);
  }

  .tabbar .action {
    font-size: 22rpx;
    position: relative;
    flex: 1;
    text-align: center;
    padding: 0;
    display: block;
    height: auto;
    line-height: 1;
    margin: 0;
    overflow: initial;
  }

  .tabbar .action .bar-icon {
    width: 100rpx;
    position: relative;
    display: block;
    height: auto;
    margin: 0 auto 10rpx;
    text-align: center;
    font-size: 42rpx;
  }

  .tabbar .action .bar-icon image {
    width: 50rpx;
    height: 50rpx;
    display: inline-block;
  }
</style>
