<template>
  <div
    class="signPrizeDiv"
    :style="styleData[keyData.signPrizeDiv]"
    ref="signPrize4"
    @click.stop="styleClick('click', 'signPrize4')"
    @mousemove.stop="styleClick('mousemove', 'signPrize4')"
    @mouseout.stop="styleClick('mouseout')"
  >
    <div v-if="isWebClick">
      <div
        class="signDiv"
        :style="styleData[keyData.signDiv]"
      >
        <img
          :style="styleData[keyData.imageSignStyle]"
          :src="styleData.imageSignStyle.imageUrl"
          v-if="isShowImg"
        />
        <span v-if="datas.signTitle">{{ datas.signTitle }}</span>
      </div>
      <div
        class="prizeDiv"
        :style="styleData[keyData.prizeDiv]"
        v-if="isShow"
      >
        <img
          :style="styleData[keyData.imagePrizeStyle]"
          :src="styleData.imagePrizeStyle.imageUrl"
          v-if="isShowImg2"
        />
        <div v-if="datas.prizeText">
          {{ datas.prizeText }}
        </div>
        <template v-else>
          <span v-if="styleData[keyData.prizeDiv]">我的奖品</span>
        </template>
      </div>
    </div>
    <div v-else>
      <div
        class="signDiv"
        :style="styleData[keyData.signDiv]"
        v-lz-click="'18'"
        @click="operClick(1)"
      >
        <img
          :style="styleData[keyData.imageSignStyle]"
          :src="styleData.imageSignStyle.imageUrl"
          v-if="isShowImg"
        />
        <span v-if="datas.signTitle">{{ datas.signTitle }}</span>
      </div>
      <div
        class="prizeDiv"
        :style="styleData[keyData.prizeDiv]"
        v-lz-click="'19'"
        v-if="isShow"
      >
        <img
          :style="styleData[keyData.imagePrizeStyle]"
          :src="styleData.imagePrizeStyle.imageUrl"
          v-if="isShowImg2"
        />
        <div v-if="datas.prizeText" @click="operClick(2)">
          {{ datas.prizeText }}
        </div>
        <template v-else>
          <span v-if="styleData[keyData.prizeDiv]">我的奖品</span>
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import { AcRulePopComService } from "../../../util/comCreate.js";
import { goToActive } from "../../../util/tools";
export default {
  props: [
    "datas",
    "styleData",
    "keyData",
    "isTemplate",
    "templateData",
    "modifyContent",
    "isWebClick",
  ],
  data() {
    return {
      isShowImg: true, // 活动规则是 按钮图片 false 不显示图片
      isShow: true,
      isShowImg2: false,
      isEditAddress: true, //是否可以编辑地址 默认可以编辑地址
      isAlLookAddress: false, //是否可以一直查看地址 默认不可以一直查看
      isShowLuckDrawRecord: false, // 积分猜大小 游戏记录
      hbHref: "",
      styleDataOld:{},
      myPrizePopComData: {
        styleData: {},
        datas: {},
        keyData: {
          prizeType: "prizeType",
          prizeUrl: "showImg",
          prizeName: "prizeName",
          prizeDate: "dayTime",
          prizeStatus: "activityType",
          realName: "realName",
          recevierPhone: "mobile",
          logisticsJson: "logisticsJson",
          nickName: "nickName",
        },
      },
      acRulePopComData: {
        styleData: {},
        datas: {},
        keyData: {},
      },
    };
  },

  created() {
    //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
    this.isShow = this.datas.isShowPrize;
    this.isShowImg = this.datas.isShowImg == false ? false : true;
    this.isShowImg2 = this.datas.isShowImg2 == false ? false : true;
    this.isEditAddress = this.datas.isEditAddress == false ? false : true;
    this.isAlLookAddress = this.datas.isAlLookAddress == true ? true : false;
    this.isShowLuckDrawRecord =
      this.datas.isShowLuckDrawRecord == true ? true : false;
    this.publicData.$on("showMyPrize", (datas) => {
      if (datas == true) {
        //显示我的奖品组件
        this.isShow = true;
        if (this.isTemplate == true) {
          this.initData(this.templateData);
        } else {
          this.initData();
        }
      } else {
        this.isShow = false;
      }
    });
    this.initData();
  },

  methods: {
    //点击可修改位置的方法
    styleClick(type, refName) {
      if (this.isWebClick) {
        //传值给B端
        let byValue = {
          modifyContent: this.modifyContent,
          refName: refName,
          styleData: this.styleData,
          styleDataOld: this.styleDataOld,
          c_this: this,
        };
        this.$emit("opertaionCom", type, byValue);
      }
    },
    initData() {
      var datas = this.templateData;
      if (this.isTemplate == true) {
        this.templateData = datas;
      }
      this.isShow = this.datas.isShowPrize;
    },

    //type 1 签到规则 2 我的奖品 3、积分抽奖记录
    operClick(type) {
      switch (type) {
        case 1:
          AcRulePopComService.create(
            this.acRulePopComData,
            this.isTemplate,
            this.templateData,
            (prizeRecordDetilClick) => {
              AcRulePopComService.close();
            }
          );
          break;

        case 2:
          if (this.isTemplate == true) {
            this.$toast("活动预览，仅供查看");
            return;
          }
          this.hbHref = "https://wqs.jd.com/my/redpacket.shtml?sceneval=2";
          goToActive(this.hbHref);
          break;
      }
    },
  },
};
</script>

<style lang="scss"></style>
