<template>
  <div class="signPrizeDiv" :style="styleData[keyData.signPrizeDiv]">
    <div class="signDiv" :style="styleData[keyData.signDiv]" @click="operClick(1)" v-lz-click="'18'">
      <img :style="styleData[keyData.imageSignStyle]" :src="datas[keyData.signIcon]" v-if="isShowImg"/>
      <span v-if="datas.signTitle">{{ datas.signTitle }}</span>
    </div>
    <div class="prizeDiv" :style="styleData[keyData.prizeDiv]" @click="operClick(2)" v-if="isShow">
      <img :style="styleData[keyData.imagePrizeStyle]" :src="datas[keyData.prizeIcon]" v-if="isShowImg2"/>
      <span v-if="datas.prizeText">{{ datas.prizeText }}</span>
      <template v-else>
        <span v-if="styleData[keyData.prizeDiv]">我的奖品</span>
      </template>
    </div>
    <div class="luckDrawRecord" :style="styleData[keyData.luckDrawRecordDiv]" @click="operClick(3)" v-if="isShowLuckDrawRecord">
      <template>
        游戏记录
      </template>
    </div>
  </div>
</template>

<script>
import { MyPrizePopComService, AcRulePopComService,LuckDrawRecordPopComService } from '../../../util/comCreate.js';
export default {
  props: ['datas', 'styleData', 'keyData', 'isTemplate', 'templateData'],
  data() {
    return {
      isShowImg:true, // 活动规则是 按钮图片 false 不显示图片
      isShow: true,
      isShowImg2:false,
      isEditAddress:true,//是否可以编辑地址 默认可以编辑地址
      isAlLookAddress:false,//是否可以一直查看地址 默认不可以一直查看
      isShowLuckDrawRecord :false,// 积分猜大小 游戏记录
      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() {
    console.log(this.datas,'datas1111111111111')
    
    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: {
    initData() {
      var datas = this.templateData;
      if (this.isTemplate == true) {
        this.templateData = datas;
      }
      this.isShow = this.datas.isShowPrize;
      // this.publicData.$emit("isNotyFiceWinnerReorrd",true,this.isTemplate)
    },

    //type 1 签到规则 2 我的奖品 3、积分抽奖记录
    operClick(type) {
      switch (type) {
        case 1:
          // this.$emit('operClick', 1);
          console.log('签到规则1', this.acRulePopComData);
          console.log('签到规则2', this.templateData);
          AcRulePopComService.create(this.acRulePopComData, this.isTemplate, this.templateData, prizeRecordDetilClick => {
            AcRulePopComService.close();
          });
          break;
        case 2:
          let actStatus = sessionStorage.getItem('actStatus');
          if (actStatus == 1) {
            this.$toast('活动尚未开始');
            return;
          }
          // this.$emit('operClick', 2);

          this.myPrizePopComData.datas.isEditAddress = this.isEditAddress
          this.myPrizePopComData.datas.isAlLookAddress = this.isAlLookAddress
          console.log('我的奖品', this.myPrizePopComData);
          MyPrizePopComService.create(this.myPrizePopComData, this.isTemplate, prizeRecordDetilClick => {
            MyPrizePopComService.close();
          });
          break;
        case 3:
           let actStatus1 = sessionStorage.getItem('actStatus');
          if (actStatus1 == 1) {
            this.$toast('活动尚未开始');
            return;
          }
          LuckDrawRecordPopComService.create(this.myPrizePopComData, this.isTemplate, prizeRecordDetilClick => {
            LuckDrawRecordPopComService.close();
          });
          break;
      }
    }
  }
};
</script>

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