<template>
  <view class="shopcart" @click.stop="goShopCart">
    <span v-if="shopcartCount" class="count">{{ shopcartCount }}</span>
    <svg-icon icon-class="shopcart" class="shopcart" />
  </view>
</template>
<script>
import localStorage from '@/service/localStorage.service';
export default {
  props: {
    shopcartCount: {
      type: [Number, String],
      default: ''
    }
  },
  created() {
    // this.$store.dispatch('shopCart/queryCartCount');
  },
  methods: {
    goShopCart() {
      setTimeout(() => {
        localStorage.get('vccToken')
          ? this.$router.push({ name: 'Cart' })
          : this.$router.push({ name: 'Login', query: { backUrl: '/shopCart' } });
      }, 500);
    }
  }
};
</script>
<style lang="less" scoped>
.shopcart {
  position: fixed;
  bottom: 126px;
  right: 10px;
  width: 42px;
  height: 42px;
  .count {
    position: absolute;
    right: -5px;
    top: -5px;
    z-index: 2;
    background: #ff1616;
    font-size: 14px;
    color: #f8f8f8;
    text-align: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    text-align: center;
    line-height: 20px;
  }
}
</style>
