<template>
<div class="blind-sku-page">
  <div class="blind-sku-scroll">
   <div class="blind-sku-scroll-box flex-default">
      <div class="blind-card" v-for="(prop, index) in skus" :key="index" @click="showDetail(prop)">
        <img class="thumb" :src="prop.thumb" alt=""/>
        <div class="name">{{prop.skuProps?prop.skuProps[0].propVal:" "}}</div>
        <div class="num">丨限量{{prop.circulation}}份丨</div>
        <img src="@/assets/img/hide-box.png" class="hide-box" alt="" v-show="prop.isHide" >
      </div>
   </div>
  </div>
  <div class="blind-buy">
      <img @click="handleConfirm" v-if="isHasStock" src="@/assets/img/buy.png" class="buy-btn" alt="">
      <img v-else src="@/assets/img/sell-out.png" class="buy-btn" alt="">
  </div>
  <van-popup v-model="showPopup" round >
    <div class="blind-large-con">
      <div class="blind-large-card">
        <img class="thumb" :src="selectBlind.thumb" alt="" />
        <div class="name">{{selectBlind.skuProps?selectBlind.skuProps[0].propVal:" "}}</div>
        <div class="num">丨限量{{selectBlind.circulation}}份丨</div>
      </div>
      <div class="close-img flex-center" @click="showPopup=false">
        <van-icon name="cross"  color="#ffffff" size="12px"/>
      </div>
    </div>
    
  </van-popup>
  </div>
</template>
<script>
import { Icon } from 'vant';
export default {
  props: {
    value: {
      type: Boolean,
      default: false,
    },
    // 规格列表
    skuList: {
      type: Array,
      defualt: () => [],
    },
    // 规格详情
    skuMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
    skus: {
       type: Array,
      defualt: () => [],
    },
    // isHasStock: Boolean
  },
  components:{
    [Icon.name]: Icon,
  },
  data() {
    return {
      showPopup: false,
      selectBlind:{}
    }
  },
  computed: {
    isHasStock() {
      return this.skus && this.skus.some((item) => {
        return item.stock
      })
    }
  },
  methods: {
    showDetail(prop) {
      this.showPopup = true
      this.selectBlind = prop
    },
    handleConfirm() {
      this.$emit("buy");
    }
  },
  mounted() {
    
  }
};
</script>
<style lang="less" scoped>
.blind-sku-page {
  .van-popup--center.van-popup--round{
    border-radius: 0px;
  }
  .van-popup{
    background: transparent;
  }
}
.blind-sku-scroll {
  margin: auto;
  width: 343px;
  height: 178px;
  padding: 42px 12px 20px;
  background: url("~@/assets/img/blind-box-sku.png") no-repeat;
  background-size: 100%;
  &-box {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
  }
}
.blind-card {
  width: 92px;
  min-width: 92px;
  height: 116px;
  background: #ffffff;
  border-radius: 6px;
  text-align: center;
  padding: 10px 3px;
  margin-left: 12px;
  position: relative;
  .thumb {
    width: 56px;
    height: 56px;
  }
  .name {
      color: #2C66F5;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
  }
  .num {
    height: 40px;
  }
  .text {
    transform: translateY(2px);
  }
  .hide-box {
    position: absolute;
    width: 40px;
    height: 18px;
    left:0;
    top:0;
  }
}
.blind-buy {
    text-align: center;
    margin-top: 36px;
    .buy-btn {
        width:191px ;
        height: 75px;
    }
}
.blind-large-con{
  .blind-large-card {
    width:227px ;
    height: 296px;
    text-align: center;
    padding:20px 18px;
    background: #ffffff;
    border-radius: 4px;
    > .thumb {
      width: 120px;
      height: 167px;
      margin-bottom: 32px;
      object-fit: cover;
    }
    .name {
        color: #030711;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        height: 24px;
        margin-bottom: 10px;
        font-size: 14px;
        font-weight: 500;
    }
    .num {
      color: #999999;
    }
    
  }
  .close-img{
    margin: 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #333333;
    margin-top: 65px;
  }
}

</style>