<template>
  <div class="goods-bottom-container">
    <div v-if="showGroupDesc" class="group-desc">
      <cr-image width="14px" src="@/assets/images/groupIcon.png" />
      <span class="red-text">[正在拼团]</span>
      <span class="normal-text">拼团成功即可退款0元拿，拼团失败立即退款</span>
    </div>
    <div v-if="type === 'shoppingCar'" class="goods-bottom">
      <div class="goods-bottom-icon" @click="goHome">
        <span class="iconfont icon-home" />
        <span>首页</span>
      </div>
      <!-- <navigator v-if="type === 'shoppingCar'" url="/pages/cart/cart" class="goods-bottom-icon">
        <text class="iconfont icon-cart-card" />
        <text>购物车</text>
      </navigator>
      <button class="goods-bottom-car">加入购物车</button> -->
      <button class="goods-bottom-buy" :class="{ disabled: disabled }" @click="buy">
        {{ shopBtnName }}
      </button>
    </div>
    <div v-if="type === 'submitOrder'" class="goods-bottom">
      <div class="goods-bottom-text">
        <div class="Gb-text-top">
          <span>合计：</span>
          <span>¥</span>
          <span>{{ info.totalPayFee || '0.00' }}</span>
        </div>
      </div>
      <button class="goods-bottom-buy confirm-order-btn" @click="buy">提交订单</button>
    </div>
  </div>
</template>
<script>
export default {
  name: 'BottomNav',
  props: {
    showGroupDesc: {
      type: Boolean,
      default: true
    },
    type: {
      type: String,
      default: 'shopCar' // shoppingCar 购物车；settlement 结算;submitOrder 确认订单
    },
    shopBtnName: {
      type: String,
      default: '立即购买' // shoppingCar 购物车；settlement 结算;submitOrder 确认订单
    },
    info: {
      type: Object,
      default() {
        return {};
      }
    },
    disabled: {
      type: Boolean,
      default: false
    },
    goodsId: {
      type: String,
      default: ''
    }
  },
  methods: {
    buy() {
      this.$emit('buy');
    },
    goHome() {
      setTimeout(() => {
        this.$router.push({ name: 'home' });
      }, 500);
    }
  }
};
</script>
<style lang="less" scoped>
.goods-bottom-container {
  position: fixed;
  left: 0;
  bottom: 0;
  width: 100%;
  .group-desc {
    display: flex;
    align-items: center;
    width: 100%;
    height: 30px;
    background: @white;
    padding: 0 @padding-xs;
    .text-12();
    .red-text {
      margin: 0 @padding-unit;
      color: @red;
    }
    .normal-text {
      color: @black;
    }
  }
}
.goods-bottom {
  display: flex;
  justify-content: space-evenly;
  align-items: center;
  width: 100%;
  height: 30px;
  padding-bottom: calc(10px + constant(safe-area-inset-bottom));
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  padding-top: 10px;
  padding-left: 0;
  padding-right: 0;
  background: @white;
  border-top: 1px solid #f7f7f7;
  &-radio {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding-top: 8px;
    width: 140px;
    radio {
      transform: scale(0.7);
    }
    span {
      font-size: 24px;
      color: #999999;
    }
  }
  &-text {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex: 1;
    margin: 0 20px;
    .Gb-text-top {
      display: flex;
      align-items: center;
      span {
        &:nth-child(1) {
          padding-top: 4px;
          .text-12();
          color: #333333;
        }
        &:nth-child(2) {
          padding-top: 4px;
          .text-12();
          color: #ec3333;
        }
        &:nth-child(3) {
          .text-18();
          font-weight: bold;
          color: #ec3333;
        }
      }
    }
    .Gb-text-bottom {
      .text-12();
      color: #999999;
    }
  }
  &-icon {
    display: flex;
    align-items: center;
    flex-direction: column;
    span {
      &:first-child {
        .text-20();
      }
      &:last-child {
        .text-10();
        color: #999999;
      }
    }
  }
  &-car {
    border: @border-sm solid @border-color-search;
    background: @white;
    color: @font-color-search;
  }
  &-buy {
    color: @white;
    background-image: @background-primary;
  }
  button {
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 305px;
    height: 40px;
    font-size: 17px;
    font-weight: bold;
    border-radius: 20px;
    &.disabled {
      opacity: 0.7;
    }
  }
}
.confirm-order-btn {
  outline: none;
  width: 130px !important;
  margin-right: 10px !important;
}
</style>
