<template>
  <div v-if="show">
    <basicPop>
      <div class="follow">
        <div class="draw-rule" @click="backDrawPage"></div>
        <div class="draw-panel-follow">
          <div class="giveContent">
            <table>
              <tbody>
                <tr>
                  <td class="tHead">参与条件：</td>
                  <td class="tText">
                    <span><span class="color-cus">关注指定商品</span></span>
                  </td>
                </tr>
                <tr>
                  <td>抽奖次数：</td>
                  <td>
                    <span>关注</span
                    ><span class="color-cus">{{ data.finishNum }}</span>
                    个商品，赠送
                    <span class="color-cus">
                      {{ data.sendNum }}
                    </span>
                    <span v-if="data.activeLimit.limitType == 1">
                      次抽奖机会，活动期间最多赠送
                      <span class="color-cus">
                        {{ data.activeLimit.limitNum }}
                      </span>
                      次抽奖机会
                    </span>
                    <span v-if="data.activeLimit.limitType == 0">
                      次抽奖机会，活动期间不限制赠送次抽奖机会
                    </span>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <div class="mySharedContent">
            已关注 <span class="num">{{ data.shareCount }}</span
            >个商品，获得 <span class="num">{{ data.prieCount }}</span
            >次抽奖机会
          </div>

          <div>
            <ul class="draw-collect-list f-cb">
              <li v-for="(item, index) in data.skuInfoVO" :key="index">
                <div class="pic" @click="goToBuy(item)">
                  <a href="javascript:;">
                    <img alt="" :src="item.skuImg" style="width: 100%"
                  /></a>

                  <div class="title">{{ item.skuName }}</div>
                  <div class="detail f-cb">
                    <div class="price">￥{{ item.skuPrice }}</div>
                  </div>
                </div>
                <div
                  v-if="item.status == 0"
                  class="attention"
                  @click="follow(item)"
                >
                  点我关注
                </div>
                <div
                  v-if="item.status == 1"
                  class="attention"
                  style="background: rgb(204, 204, 204)"
                >
                  已关注
                </div>
              </li>
            </ul>
          </div>
        </div>
        <div class="box"></div>
      </div>
    </basicPop>
  </div>
</template>
<script>
import apis1 from "../../../util/apis1.js";
let { followSkuTask,niudanjiSkuTask,storeGoodsPoint } = apis1;
import { newToSkuPage } from "../../../util/tools.js";
import basicPop from "./basicPop.vue";
export default {
  props: ["isTemplate", "datas", "styleData", "keyData", "templateData"],
  components: {
    basicPop,
  },
  data() {
    return {
      sum: 0,
    };
  },
  created() {
    console.log("asd");
    document
      .querySelector("body")
      .setAttribute(
        "style",
        "position:#fixed;top:0;height:100%;overflow:hidden"
      );
    this.sum = this.data.prieCount;
  },
  methods: {
    backDrawPage() {
      document.querySelector("body").removeAttribute("style");
      this.submit(this.data.prieCount - this.sum);
    },
    follow(item) {
      console.log(item.skuId + "ccccccc");
      followSkuTask(this.data.taskId, item.skuId, (data) => {
        item.status = 1;
        this.data.shareCount = this.data.shareCount + 1;
        var count =
          Math.floor(this.data.shareCount / this.data.finishNum) *
          this.data.sendNum;

        if (this.data.activeLimit.limitType == 1) {
          if (count > this.data.activeLimit.limitNum) {
            this.data.prieCount = this.data.activeLimit.limitNum;
          } else {
            this.data.prieCount = count;
          }
        } else {
          this.data.prieCount = count;
        }
      });
    },
    goToBuy(sku) {
      console.log(sku);
      storeGoodsPoint(5)
      newToSkuPage(sku);
    },
  },
};
</script>
<style lang="scss" scoped="scoped">
.follow {
  max-width: 750px;
  margin-left: auto;
  margin-right: auto;
  min-height: 100%;
  background: #ff4b4b
    url(https://img10.360buyimg.com/imgzone/jfs/t18481/132/470253269/70814/2b3d87a0/5a7c711aN13f83f49.jpg)
    no-repeat;
  background-size: 100%;
  padding-top: 0.2rem;
}
.draw-panel-follow {
  // position: relative;
  z-index: 4;
  width: 6.5rem;
  margin: 0 auto;
  margin-top: 2.6rem;
}
.box {
  position: relative;
  background-color: #ff4b4b;
  margin-top: 3.2rem;
  height: 1rem;
}
.draw-panel-follow .giveContent {
  height: 2rem;
  font-size: 0.25rem;
  padding: 0.1rem;
}
.mySharedContent {
  margin-top: 0.8rem;
  margin-bottom: 0.3rem;
  color: #fff;
  color: #febf1a;
  text-align: center;
  font-size: 0.3rem;
}
.giveContent table {
  font-size: 0.25rem;
  border-collapse: separate;
  border-spacing: 0 0.15rem;
}
.draw-rule {
  margin-left: 0.3rem;
  top: 0.4rem;
  width: 1.2rem;
  height: 0.5rem;
  background-image: url(https://img10.360buyimg.com/imgzone/jfs/t17563/71/464197912/2669/9b732e4b/5a7c711aN7a2683a4.png);
  background-size: 100%;
  background-repeat: no-repeat;
  z-index: 10;
}
.color-cus {
  color: #f56264;
}
img {
  border: 0;
  max-width: 100%;
}
.draw-collect-list {
  padding: 0.3rem;
  margin-bottom: 0.9rem;
}
.draw-collect-list li {
  float: left;
  width: 49%;
  margin-bottom: 2%;
  background: #fff;
}
.draw-collect-list {
  padding: 0.3rem;
  margin-bottom: 0.9rem;
}
.draw-collect-list li .title {
  height: 0.7rem;
  line-height: 0.35rem;
  padding: 0 0.1rem;
  margin-top: 0.1rem;
  font-size: 0.26rem;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.draw-collect-list li .detail .price {
  color: #f23c3c;
}
.draw-collect-list li .attention {
  margin: 0.08rem;
  height: 0.74rem;
  line-height: 0.74rem;
  font-size: 0.36rem;
  background: #ffea01;
  color: #fe2437;
  text-align: center;
}
.draw-collect-list li .detail {
  padding: 0.1rem;
  font-size: 0.28rem;
}
.draw-collect-list li:nth-child(even) {
  margin-left: 2%;
}
.f-cb:after {
  display: block;
  clear: both;
  visibility: hidden;
  height: 0;
  overflow: hidden;
  content: ".";
}
.tHead {
  width: 1.5rem;
  color: #222222;
}
</style>