<template>
  <div
    :style="styleData[keyData.cartStepDivAllC]"
    ref="cartStepContainer"
    @click="styleClick('click', 'cartStepContainer')"
    @mousemove="styleClick('mousemove', 'cartStepContainer')"
    @mouseout="styleClick('mouseout')"
  >
    <div :style="styleData[keyData.cartStepContainer]"></div>
    <div :style="styleData.cartStepContainer1">
      <div :style="styleData.back1">
        <div :style="styleData.time">{{ addSkuDate1 }}-{{ addSkuDate2 }}</div>
        <div :style="styleData.img1"></div>
        <div :style="styleData.wenan">加购商品</div>
      </div>
      <div :style="styleData.back1">
        <div :style="styleData.time">{{ priceDate2 }}</div>
        <div :style="styleData.img2"></div>
        <div :style="styleData.wenan">抽奖</div>
      </div>
      <div :style="styleData.back1">
        <div :style="styleData.time">获奖者</div>
        <div :style="styleData.img3"></div>
        <div :style="styleData.wenan">领取丰厚大奖</div>
      </div>
    </div>
  </div>
</template>

<script>
import dateUtil from "../../../util/dateUtil";
import apis1 from "../../../util/apis1.js";
export default {
  props: [
    "datas",
    "keyData",
    "styleData",
    "isTemplate",
    "templateData",
    "isWebClick",
    "modifyContent",
  ],
  data() {
    return {
      shoppingCard2: [],
      addSkuDate1: "",
      addSkuDate2: "",
      priceDate2: "",
      userSkuCount: "",
      skuNumber: "",
      shareUserId: "", //用户id取得
    };
  },
  mounted() {},
  created() {
    //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
    this.publicData.$on("cartGoodsJinli", (addCardCount, refName) => {
      if (addCardCount === 9999) {
        this.userSkuCount = this.userSkuCount + 1;
      } else {
        this.userSkuCount = addCardCount;
      }
    });
    this.initData();
  },
  methods: {
    styleClick(type, refName) {
      if (this.isWebClick) {
        //传值给B端
        let byValue = {
          modifyContent: this.modifyContent,
          refName: refName,
          styleData: this.styleData,
          isCustomSwitching: this.isCustomSwitching, //有tab切换时
          c_this: this,
          styleDataOld: this.styleDataOld,
        };
        this.$emit("opertaionCom", type, byValue);
      }
    },
    initData() {
      var datasAll = this.templateData;
      if (this.isTemplate == true) {
        this.$toast("活动预览，仅供查看");
        if (datasAll) {
          this.addSkuDate1 = dateUtil.formatTime(
            datasAll.addSku.addSkuStartTime,
            "MM.dd"
          );
          this.addSkuDate2 = dateUtil.formatTime(
            datasAll.addSku.addSkuEndTime,
            "MM.dd"
          );
          this.priceDate2 = dateUtil.formatTime(
            datasAll.addSku.priceTime,
            "MM.dd hh:mm"
          );
          this.userSkuCount = 0;
          this.skuNumber = datasAll.goodsData.exposedGoods.length;
        } else {
          this.addSkuDate1 = "02.02";
          this.addSkuDate2 = "02.20";
          this.priceDate2 = "02.05";
          this.userSkuCount = 0;
          this.skuNumber = 8;
        }
      } else {
        this.getShoppingCard2();
      }
    },
    getShoppingCard2() {
      let shoppingCard2 = apis1[this.datas.shoppingCard2];
      shoppingCard2((data) => {
        var that = this;
        that.shoppingCard2 = data.data;
        that.addSkuDate1 = data.data.addSkuDate1;
        that.addSkuDate2 = data.data.addSkuDate2;
        that.priceDate2 = data.data.priceDate2;
        that.userSkuCount = data.data.userSkuCount;
        that.skuNumber = data.data.skuNumber;
      });
    },
  },
  filters: {
    twostar: function (value) {
      if (!value) {
        return "";
      }
      return value.substr(0, 1) + "**" + value.substr(-1, 1);
    },
    //时间转换
    dateTime(val) {
      if (val) {
        return dateUtil.formatTime(val, "yyyy-MM-dd hh:mm");
      }
      return val;
    },
  },
};
</script>
