<template>
  <div v-if="show">
    <basicPop>
      <div class="follow">
        <div class="draw-rule" v-lz-click="'27'" @click="backDrawPage"></div>
        <div class="draw-panel-follow">
          <div class="giveContent">
            <table>
              <tr>
                <td class="tHead">参与条件：</td>
                <td class="tText">
                  <span class="color-cus">{{ title }}</span>
                </td>
              </tr>
              <tr>
                <td>抽奖次数：</td>
                <td>
                  <span v-if="data.activeLimit.limitType == 1"
                    >分享<span class="color-cus">{{ data.finishNum }}</span
                    >次，赠送<span class="color-cus">{{ data.sendNum }}</span
                    >次抽奖机会，活动期间最多赠送<span class="color-cus">{{
                      data.activeLimit.limitNum
                    }}</span
                    >次抽奖机会</span
                  >
                  <span v-if="data.activeLimit.limitType == 0"
                    >分享<span class="color-cus">{{ data.finishNum }}</span
                    >次，赠送<span class="color-cus">{{ data.sendNum }}</span
                    >次抽奖机会，活动期间不限制赠送次抽奖机会</span
                  >
                </td>
              </tr>
            </table>
          </div>
          <div class="mySharedContent">
            已分享
            <span id="hasShareTimes" class="num">{{ data.shareCount }} </span
            >次，获得 <span class="num">{{ data.prieCount }}</span
            >次抽奖机会
          </div>
          <div class="f-tac" style="margin-top: 0.6rem">
            <div class="attr-btn" v-lz-click="'2'" @click="share"></div>
          </div>
        </div>
        <div class="box"></div>
      </div>
    </basicPop>
  </div>
</template>
<script>
import apis1 from "../../../util/apis1.js";
import basicPop from "./basicPop.vue";
import { allShareByurl } from "../../../js/share.js";
import { allShare } from "../../../js/share.js";
let { shareTask } = apis1;

export default {
  props: ["isTemplate", "datas", "styleData", "keyData", "templateData"],
  components: {
    basicPop,
  },
  data() {
    return {
      sum: 0,
    };
  },
  created() {
    document
      .querySelector("body")
      .setAttribute(
        "style",
        "position:#fixed;top:0;height:100%;overflow:hidden"
      );
    this.sum = this.data.prieCount;
    console.log(this.title, "asd");
  },
  methods: {
    backDrawPage() {
      console.log("this.submit()");
      document.querySelector("body").removeAttribute("style");
      this.submit(this.data.prieCount - this.sum);
    },

    share() {
      var skuid = "";
      if (this.title == "分享指定商品") {
        skuid = this.data.skuInfoVO[0].skuId;
      }
      shareTask(this.data.taskId, skuid, (data) => {});
      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;
      }

      var url = "";
      if (this.title == "分享指定商品") {
        url =
          "https://item.m.jd.com/product/" +
          this.data.skuInfoVO[0].skuId +
          ".html?wjfrom=ISV_2180A2AFA5B2452F9061C01C053C4756_WX&wjwxpubid=wxd9fd3549c5fdb283&wjunionid=&wjopenid=";
       allShareByurl(url, this.isTemplate, this, (callBackData) => {
        console.log(callBackData, "callBackData" + url);
        });
      } else if (this.title == "分享指定店铺") {
        url = "https://shop.m.jd.com/?shopId=" + this.data.shopId;
        allShareByurl(url, this.isTemplate, this, (callBackData) => {
          console.log(callBackData, "callBackData" + url);
        });
      } else {
        url = location.href;
        allShare(this.isTemplate, this,(callBackData)=>{
          console.log(callBackData,'callBackData');
        });
      }
      console.log(url + "url");

    },
  },
};
</script>
<style lang="scss" scoped="scoped">
.follow {
  max-width: 750px;
  margin-left: auto;
  margin-right: auto;
  min-height: 100%;
  background: url("https://img10.360buyimg.com/imgzone/jfs/t13237/328/1793356963/70474/eae64eee/5a7c711aNc44c4aff.jpg")
    no-repeat;
  background-size: 100%;
  padding-top: 2.9rem;
  background-color: #ff4b4b;
}
.draw-panel-follow .giveContent {
  height: 2rem;
  font-size: 0.25rem;
  padding: 0.1rem;
}
.mySharedContent {
  margin-top: 2.2rem;
  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;
  position: absolute;
}
.color-cus {
  color: #f56264;
}
img {
  border: 0;
  max-width: 100%;
}
.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 {
  padding: 0.3rem;
  margin-bottom: 0.9rem;
}
.draw-collect-list li {
  float: left;
  width: 49%;
  margin-bottom: 2%;
  background: #fff;
}
.draw-panel-follow {
  position: relative;
  z-index: 4;
  width: 6.5rem;
  margin: 0 auto;
  margin-top: 0.2rem;
}
.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;
}
.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: ".";
}
.f-tac {
  text-align: center;
}
.attr-btn {
  background-image: url(https://img10.360buyimg.com/imgzone/jfs/t18961/172/462837908/28516/665700f4/5a7c711aN0ef4b176.png);
  background-size: 100%;
  background-repeat: no-repeat;
  height: 2rem;
}
.box {
  position: relative;
  background-color: #ff4b4b;
  margin-top: 3.2rem;
  height: 1rem;
}
.tHead {
  width: 1.5rem;
  color: #222222;
}
</style>