<template>
<div v-if="show">
    <basicbackground @closeClick="closeClick">
    <div id="bottom-content">
        <p class="p5">大连泊源科技有限公司测试店铺</p>
        <img :src="prizeResultData.datas[keyData.prizeUrl]" />
        <p class="p1">恭喜您获得:</p>
        <p class="p2">{{ prizeResultData.datas[keyData.prizeName] }}</p>
        <p class="p3" v-if="prizeResultData.datas[keyData.prizeType] == 1">
          京豆已放到您的账户中
          <span>京东-我的-京豆</span>
          中查看
        </p>
        <p class="p4" v-if="prizeResultData.datas[keyData.prizeType] == 3">
          <span v-if="openDeliveryStatus" class="deliveryDateDiv1">实物发货时间:{{deliveryTime}}</span>
          <span>实物奖品系统不能自动发货，请<span>填写邮寄地址</span></span>
        </p>
        <button v-lz-click="'23'" @click="buttonClick(prizeResultData.datas)">{{ prizeResultData.datas[keyData.prizeType] == 3 ? '填写邮寄地址' : '立即查看' }}</button>
      </div>
    </basicbackground>
  </div>
</template>
<script>
import basicbackground from './basicbackground.vue';
import { AddressPopComService } from '../../../util/comCreate.js';
import apis1 from "../../../util/apis1.js";
let { getDeliveryInfo } = apis1;

export default {
  components: { basicbackground },
  name: 'acquirecoupon',
  components: {
    basicbackground
  },
  data() {
    return {
      check: '立即查看',
      show1: false,
      show2: false,
      keyData: {},
      openDeliveryStatus:false, // 是否开启发货时间设置
      deliveryTime:"", // 实物发货开始时间
    };
  },
  props: [],
  created() {
    this.getDrawRuleData();
  },

  mounted() {
    this.keyData = this.prizeResultData.keyData;
    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;
    }
  },

  methods: {
    // 获取实物发货时间
    getDrawRuleData(){
      getDeliveryInfo((getDrawRuleData)=>{
        console.log(getDrawRuleData,'获取实物发货时间');
        this.openDeliveryStatus = getDrawRuleData.data.openDeliveryStatus;
        this.deliveryTime = getDrawRuleData.data.deliveryTime;
      });
    },
    buttonClick(prizeResultData) {
       document.querySelector('body').removeAttribute('style')
      // console.log(prizeResultData);
      // console.log(this.initDatas);
      // console.log(this.keyData.prizeType);
      // console.log(this.initDatas,'this.initDatas')
      if (prizeResultData[this.keyData.prizeType] == 3) {
        //填写地址
        console.log(this.initDatas,'填写地址');
        sessionStorage.setItem('addressId', this.initDatas.addressId);
        sessionStorage.setItem('prizeGrantId', this.initDatas.id);
        AddressPopComService.create(submit => {
          AddressPopComService.close();
        });
        this.submit();
      }
    },
    closeClick() {
      document.querySelector('body').removeAttribute('style')
      this.submit();
    }
  }
};
</script>
<style scoped>
img {
  height: 2.93rem;
  width: 2.38rem;
  /* position: fixed; */
  /* top: 3.5rem; */
  /* margin: auto;
  left: 0;
  right: 0; */
}
#bottom-content {
  height: 6.3rem;
  width: 5.63rem;
  background-color: white;
  border-radius: 0.2rem;
  position: fixed;
  margin: auto;
  left: 0;
  right: 0;
  top: 3.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
}
span {
  color: red;
}
#bottom-content .p1 {
  display: block;
  color: #ff9900;
  font-size: 0.26rem;
  margin-top: 0.1rem;
}
#bottom-content .p2 {
  display: block;
  /* line-height: 0rem; */
  color: #e2231a;
  font-size: 0.53rem;
  font-weight: bolder;
}
#bottom-content .p3 {
  font-size: 0.2rem;
  color: #b8b8b8;
  display: block;
}
#bottom-content .p4 {
  font-size: 0.05rem;
  color: gray;
  display: block;
  /* margin-top: 0.5rem; */
  .deliveryDateDiv1{
      font-size: 0.2rem;
      color:#333333;
    }
}
#bottom-content .p5{
  font-size: 0.1rem;
  color: #ff9900;
}
#bottom-content button {
  margin: 0 auto;
  margin-top: 0.3rem;
  width: 4.85rem;
  height: 0.93rem;
  background-color: #e2231a;
  color: white;
  font-size: 0.4rem;
  border-radius: 0.1rem;
  border: 1px solid red;
}

</style>
