<template>
  <div class="goods_Collage">
    <div class="BG">
      <!-- <div class="BG_txt">活动时间：1月10日-1月22日</div> -->
    </div>
    <div class="wrapper_1200">
      <div class="collage_list" v-if="groupList.length">
        <div
          class="item"
          v-for="(item, index) in groupList"
          :key="index"
          @click="goDetail(item.goods_id)"
        >
          <div class="pictrue">
            <img v-lazy="imgUrl + item.sku_image" v-if="item.sku_image" />
            <img src="~assets/images/no_goods.jpg" alt v-else />
          </div>
          <div style="padding: 0 15px">
            <div class="name">{{ item.sku_name }}</div>
            <div class="txtBox">
              <div>产地：{{ item.address }}</div>
              <div>参团人数：{{ item.pintuan_num }}</div>
            </div>
            <div class="txtBox">
              <div>库存：{{ item.stock }}</div>
              <div>销量：{{ item.sale_num }}</div>
            </div>
            <div class="stock" v-if="userInfo.show_price">
              <p>
                拼团价：
                <span>￥{{ item.pintuan_price }}</span>
              </p>
              <div class="originalPrice">原价¥{{ item.price }}</div>
            </div>
          </div>
        </div>
      </div>
      <div v-if="!groupList.length" class="nothing">
        <img src="@/assets/images/noGoods.png" />
        暂无拼团商品，去看点别的吧
      </div>
    </div>
  </div>
</template>

<script>
import Setting from "~/setting";
import Guess from "@/components/guess.vue";
export default {
  auth: false,
  components: { Guess },
  data() {
    return {
      imgUrl: Setting.uplodBaseURL,
      isSignin: localStorage.getItem("token") ? true : false,
      userInfo: {},
      groupList: [],
    };
  },
  created() {
    // 已登录
    if (this.isSignin) {
      this.userInfo = JSON.parse(localStorage.getItem("userInfo"));
    }
    this.init();
  },
  methods: {
    init() {
      this.$axios
        .post(`/goodssku/pintuangoodsList`)
        .then((res) => {
          this.groupList = res.data.list;
          console.log(this.groupList);
        })
        .catch((err) => {
          this.$message.error(err);
        });
    },
    goDetail(id) {
      this.$router.push({
        path: `/activityDetail`,
        query: {
          id,
          isSeckill: false,
          isCollage: true,
          isSetMeal: false,
        },
      });
    },
  },
};
</script>
<style lang="scss" scoped>
.goods_Collage {
  .BG {
    width: 1920;
    height: 220px;
    background: url("../assets/images/group.png") no-repeat;
    background-size: 100% 100%;
    margin: 0 auto;
    margin-bottom: 20px;
    .BG_txt {
      width: 260px;
      height: 43px;
      font-size: 16px;
      font-family: PingFangSC-Semibold, PingFang SC;
      font-weight: 600;
      color: #f23226;
      line-height: 22px;
      margin: 0 auto;
      padding-top: 140px;
      transform: rotate(-5.5deg);
    }
  }
  .collage_list {
    width: 1200px;
    min-height: 400px;
    margin: 20px auto;
    display: flex;
    flex-wrap: wrap;
    .item {
      width: 260px;
      height: 350px;
      background-color: #fff;
      margin: 10px 20px;
      cursor: pointer;
      margin-bottom: 20px;
      box-shadow: 0px 0px 10px 0px rgba(102, 102, 102, 0.2);
      border-radius: 8px;
      overflow: hidden;
      box-sizing: border-box;

      &:hover {
        box-shadow: 0 3px 20px rgba(0, 0, 0, 0.06);
      }
      .pictrue {
        width: 100%;
        height: 202px;
        position: relative;
        img {
          width: 100%;
          height: 100%;
        }
      }
      .collage_name {
        font-size: 18px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: var(--themeColor);
        line-height: 28px;
        margin-top: 10px;
      }
      .name {
        font-size: 16px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #222222;
        line-height: 28px;
      }
      .txtBox {
        margin-top: 10px;
        display: flex;
        justify-content: space-between;

        div {
          font-size: 13px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #666666;
          line-height: 20px;
          margin-right: 20px;
        }
      }
      .stock {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 15px;
        img {
          width: 24px;
          height: 24px;
        }
        p {
          font-size: 12px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #999;
          span {
            font-size: 18px;
            font-family: PingFangSC-Medium, PingFang SC;
            font-weight: 500;
            color: #ff1d1d;

            line-height: 25px;
          }
        }
        .originalPrice {
          color: #999999;
          text-decoration: line-through;
        }
      }
    }
  }
  .nothing {
    padding-top: 100px;
    padding-bottom: 150px;
    font-size: 16px;
    text-align: center;
    color: #969696;

    img {
      margin: 0 auto;
    }
  }
}
</style>
