<template>
  <div class="prizeMaskDiv" v-if="show">
    <!-- <div class="context1" :style="styleData.prizeContext">
      <img :src="prizeResultData.datas[keyData.prizeUrl]" />
      <div class="top-content">
        <div>恭喜您获得</div>
        <div class="p2Class" :style="styleData.p2" v-if="prizeResultData.datas[keyData.prizeType] != 10">
          {{ prizeResultData.datas[keyData.prizeName] }}
        </div>

        <div class="p2Class" :style="styleData.p2" v-else>
          {{ prizeResultData.datas[keyData.prizeName]
            }}{{ prizeResultData.datas.miane }}
        </div>
        <div v-if="parentData.grantType == '1'" style="margin-top: 0.1rem;">注：奖品将于{{ parentData.receiveDay }}日后到账，退款后领奖资格会被取消，届时奖品将发放失败</div>
      </div>

      <div class="bottom-content">
        <div class="btnRightnot3Class" :style="styleData.btnRightnot3Class"
          v-if="prizeResultData.datas[keyData.prizeType] != 3" @click="getPrizeClick(prizeResultData.datas)">
        </div>

        <div class="btnRight3Class" :style="styleData.btnRight3Class" v-lz-click="'23'"
          v-else-if="prizeResultData.datas[keyData.prizeType] == 3" @click="buttonClick(prizeResultData.datas)">
        </div>
      </div>
      <div class="close-btn" :style="styleData.closeBtn" @click="closeClick"></div>
    </div> -->
  </div>
</template>
<script>
import {
  GiftPopComService,
  OrderAddressPop10098Service
} from "../../../util/comCreate.js";
import apis1 from "../../../util/apis1.js";
import store from "../../../store/store";
// import { fillInInformationData, AddressPopComService10998 } from '../../../util/hdzxtcomCreate.js';

import {
  goToShopPage,
  exchangePrize,
} from "../../../util/tools.js";
import { prizeShare } from "../../../js/share.js";
let { myprize, storeGoodsPoint } = apis1;
export default {
  name: "hdzxtacquirething10998",
  data() {
    return {
      // timer:new Dtae().getTime(),
      p1text: "恭喜您获得:",
      check: "立即查看",
      p3text: "京豆已放到您的账户中，",
      p4text: "京东-我的-京豆",
      p5text: "中查看",
      p6text: "实物奖品需填写收货地址方可领取",
      show1: false,
      show2: false,
      keyData: {},
      jsonData: {}, //专享价的数据
      cardDate: {},
      isShowShare: true,
      //面额
      mianeArray: [
        {
          name: 2,
          value: "1",
        },
        {
          name: 3,
          value: "5",
        },
        {
          name: 4,
          value: "20",
        },
        {
          name: 5,
          value: "50",
        },
        {
          name: 6,
          value: "100",
        },
        {
          name: 7,
          value: "年卡",
        },
        {
          name: 8,
          value: "月卡",
        },
        {
          name: 12,
          value: "季卡",
        },
        {
          name: 13,
          value: "半年卡",
        },
        {
          name: 14,
          value: "年卡",
        },
      ],
    };
  },
  props: [],
  created() { },

  mounted() {
    this.initMethod();
    console.log(JSON.stringify(this.prizeResultData), 'aaaaaaaaaaaaaaa')

    this.keyData = this.prizeResultData.keyData;
    console.log(this.prizeResultData, "****prizeResultData******");
    console.log(this.initDatas, "initDatas");
    console.log(this.styleData, "styleData");
    if (this.initDatas.itemId) {
      for (var i = 0; i < this.mianeArray.length; i++) {
        // console.log(this.initDatas.itemId,'1111111111')
        if (this.initDatas.itemId == this.mianeArray[i].name) {
          // console.log(this.mianeArray[i].value,'2222222222')
          this.prizeResultData.datas.miane = this.mianeArray[i].value;
        }
      }
    }

    // console.log(this.initDatas.prizeJson);
    if (this.initDatas.prizeJson) {
      let jsonData = JSON.parse(this.initDatas.prizeJson);
      this.jsonData = jsonData;
      console.log(this.jsonData, "jkjkjkjk");
    }

    switch (this.prizeResultData[this.keyData.prizeType]) {
      case "1":
        this.show1 = true;
        this.show2 = false;
        break;
      case "2":
        this.show1 = false;
        this.show2 = false;
        break;
      case "4":
        this.show1 = false;
        this.show2 = false;
        break;
      case "3":
        this.show2 = true;
        this.show1 = false;
        this.check = "填写邮寄地址";
        break;
    }
    // this.timer = new Date().getTime();
    if (sessionStorage.getItem('shopId') == '1000435043') {
      this.isShowShare = false
    }
    // this.doFrontBuryPoint({ code: this.prizeTypeCheckPonit(prizeResultData.datas[keyData.prizeType]), value: '', event: 'click' })
  },

  methods: {
    initMethod() {
      myprize((prizedata) => {
        if (!prizedata.data[0].logisticsJson) {
        } else {
          this.cardDate = JSON.parse(prizedata.data[0].logisticsJson);
        }

        console.log(prizedata, "prizedata");
        console.log(this.cardDate);
        // sessionStorage.setItem("addressId", prizedata.data[0].addressId);
        // sessionStorage.setItem("prizeGrantId", prizedata.data[0].prizeGrantId);
      });
    },
    //立即分享
    shareClick() {
      console.log("立即分享");
      prizeShare(false, this, (callBackData) => {
        console.log(callBackData, "callBackData");
      });
    },
    buttonClick(prizeResultData) {
      document.querySelector("body").removeAttribute("style");
      // console.log(this.initDatas[this.keyData.couponType]);
      // console.log(this.initDatas[this.keyData.discountType]);
      // console.log(this.keyData);
      if (prizeResultData[this.keyData.prizeType] == 3) {
        //填写地址
        console.log(this.initDatas, "填写地址222");
        sessionStorage.setItem("addressId", this.initDatas.addressId);
        sessionStorage.setItem("prizeGrantId", this.initDatas.id);
        var datas = {
          isEditAddress: true,
          isAlLookAddress: false,
        };
        if (this.parentData.grantType == '1') {
          OrderAddressPop10098Service.create(this.styleData, (submit) => {
            OrderAddressPop10098Service.close();
          });
        } else {
          AddressPopComService10998.create(datas, this.styleData, (submit) => {
            AddressPopComService10998.close();
          });
        }
        this.submit('link');
      } else {
        //查看
        let shopId = store.state.shopId;
        goToShopPage(shopId);
        // this.submit();
      }
    },
    //立即兑换plus会员卡，爱奇艺会员卡
    exchangeClick(prizeResultData) {
      console.log("立即兑换");
      exchangePrize();
    },

    //搜狐会员立即领取
    getPrizeClick(prizeResultData) {
      console.log("立即领取-------");
      if (prizeResultData.prizeType == '12') {
        fillInInformationData.create(this.initDatas, this.styleData, submit => {
          fillInInformationData.close();
          if (submit) {
            itemDta.logisticsJson = JSON.stringify(submit);
          }
        });
      }
      this.submit('link');
    },

    //立即购买商品
    buyGood(prizeResultData) {
      storeGoodsPoint(5)
    },

    //礼品卡如何兑换
    exchange() {
      this.initMethod();
      this.submit('link');
      document.querySelector("body").removeAttribute("style");
      GiftPopComService.create(this.cardDate, (submit) => {
        GiftPopComService.close();
      });
    },

    closeClick() {
      document.querySelector("body").removeAttribute("style");
      this.submit();
    },
  },
};
</script>
<style scoped lang="scss">
.prizeMaskDiv {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10;
}
.context1 {
  position: absolute;
  left: 50%;
  top: 2.73rem;
  width: 6.48rem;
  height: 7.34rem;
  background: url("//img10.360buyimg.com/imgzone/jfs/t1/107758/7/32062/93623/64e2d8dcF63bce004/e3f0284edb26d117.png")
    no-repeat;
  background-size: 100% 100%;
  transform: translateX(-50%);
  padding: 1.67rem 0.3rem 0.3rem 0.3rem;
  color: #fcdfc5;
  font-size: 0.24rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  img {
    width: 3.3rem;
    height: 3.3rem;
  }
  .top-content {
    text-align: center;
  }
  .bottom-content {
    position: absolute;
    bottom: -0.15rem;
    left: 50%;
    transform: translateX(-50%);
  }
}
.close-btn {
  position: absolute;
  width: 0.45rem;
  height: 0.45rem;
  background: url("//img10.360buyimg.com/imgzone/jfs/t1/183690/31/37249/1097/64e2d8dcFb8273014/2bd869caeaf31168.png")
    no-repeat;
  background-size: 100% 100%;
}
.btnRight3Class {
  background-size: 100% 100% !important;
}
</style>
