<template>
  <div v-if="show" class="snapdragon">
    <basicbackground @closeClick="closeClick">
      <p class="text1" v-html="text1"></p>
      <p class="text2" v-html="text2"></p>
      <button v-lz-click="'4'" @click="buttonClick(prizeResultData.datas)">进店逛逛</button>
    </basicbackground>
  </div>
</template>
<script>
import api1 from '../../../util/apis1.js'
let {storeGoodsPoint} = api1
import basicbackground from './basicbackgroundErr.vue';
import {AddressPopComService} from '../../../util/comCreate.js';
import store from '../../../store/store';
import {goToShopPage} from '../../../util/tools.js';

export default {
  name: 'acquirecoupon',
  components: {basicbackground},
  data() {
    return {
      icons: {
        // 京豆
        '1': '//img10.360buyimg.com/imgzone/jfs/t1/180602/34/3961/56630/609dd693E52fa9522/5ecfb13e7edcb96c.png',
        // 优惠券，折扣
        '2': '//img10.360buyimg.com/imgzone/jfs/t1/183386/30/3981/54253/609dd693Ebf0084b3/2046696efcb9954a.png',
        // 实物
        '3': '',
        // 其他(暂时按积分处理)
        '4': '//img10.360buyimg.com/imgzone/jfs/t1/188025/6/3033/59458/609dd693Ef325c08d/af5b57ed06140ef1.png',
      },
      keyData: {},
      datas: {},
      prizeValue: '',
      prizeType: '',
      prizeName: '',
      couponType: '',
      iconSrc: '',
      needAddress: ''
    };
  },
  props: [],
  created() {
    this.needAddress = sessionStorage.getItem('needAddress');
    this.datas = this.prizeResultData.datas;
    this.prizeName = this.datas[this.keyData.prizeName];
    this.iconSrc = this.datas[this.keyData.prizeUrl] || this.icons[this.prizeType];
  },
  mounted() {
  },
  computed:{
    text1(){
      if(this.initDatas.canSend == 4){
        return '今日奖品已发完'
      }
      if(this.initDatas.canSend == 5){
        return '活动奖品已发完'
      }
      if(this.initDatas.canSend == 6){
        return '奖品库存有限'
      }
      if(this.initDatas.canSend == 7){
        return '很抱歉'
      }
      if(this.initDatas.canSend == 8){
        return '活动人气火爆'
      }
      if(this.initDatas.canSend == 9){
        return '活动人气爆棚'
      }
      return '很抱歉'
    },
    text2(){
      if(this.initDatas.canSend == 4){
        return '明日早点来参加活动哦～'
      }
      if(this.initDatas.canSend == 5){
        return '请关注店铺其他活动吧～'
      }
      if(this.initDatas.canSend == 6){
        return '数量有限先到先得，请再看看店铺其他活动吧～'
      }
      if(this.initDatas.canSend == 7){
        return '奖品与您擦肩而过了哟，关注下其他活动吧~'
      }
      if(this.initDatas.canSend == 8){
        return '系统全力加载中，奖品数量有限<br>以【我的奖品】实际中奖为准'
      }
      if(this.initDatas.canSend == 9){
        let activityTypes = sessionStorage.getItem('activityType')
        let returnText = ''
        if(activityTypes == '10023' || activityTypes == '10040'){
          returnText = '请稍后返回活动重新签到~'
        }else if(activityTypes == '10024'){
          returnText = '请稍后返回活动重新加购~'
        }else if(activityTypes == '10069'){
          returnText = '请稍后返回活动重新关注店铺~'
        }else if(activityTypes == '10053'){
          returnText = '请稍后返回活动重新关注商品~'
        }else if(activityTypes == '10081'){
          returnText = '请稍后返回活动重新提交问卷~'
        }else{
          returnText = '请稍后返回活动重新参与~'
        }
        return returnText
      }
      return '奖品与您擦肩而过了哟，关注下其他活动吧~'
    }
  },
  methods: {
    buttonClick(prizeResultData) {
      document.querySelector('body').removeAttribute('style')
      if (this.prizeType === 3 && this.needAddress == '1') {
        //填写地址
        sessionStorage.setItem('addressId', this.initDatas.addressId);
        sessionStorage.setItem('prizeGrantId', this.initDatas.id);
        var datas = {
          isEditAddress: true,
          isAlLookAddress: false
        }
        AddressPopComService.create(datas, submit => {
          AddressPopComService.close();
        });
        this.submit();
      } else {
        //查看
        let shopId = store.state.shopId;
        storeGoodsPoint(4)
        goToShopPage(shopId);
        this.submit();
      }
    },
    closeClick() {
      console.log(888);
      document.querySelector('body').removeAttribute('style')
      this.submit();
    },
  },
};
</script>
<style lang="scss" scoped>
.text1{
  font-size: 0.4rem;
  margin-top: 2.9rem;
}
.text2{
  margin-top: 0.2rem;
  font-size: 0.25rem;
  line-height: .4rem;
}
.snapdragon {
  text-align: center;

  .icon {
    width: 2rem;
    //height: 1.84rem;
    //margin: 0.47rem;
  }

  .couponType {
    display: none;
    font-size: small;
  }

  button {
    border-radius: 0.94rem !important;
    margin: 0 auto;
    display: block;
    width: 80%;
    height: 0.94rem;
    background-color: #AC0000;
    border-radius: 0.1rem;
    font-size: 0.35rem;
    color: #ffffff;
    margin-top: 0.5rem;
  }

}
</style>
