<template>
  <div>
    <div :style="styleData.getWishCardStyle" class="getWishCard">
      <ul>
        <!-- <li :class="[automatic == 0 ? completed : participate]"></li> -->
        <li :class="{ completed: !automatic, participate : automatic}"></li>
        <li :class="{ completed: !daily, participate : daily}"></li>
        <li :class="{ completed: !share, participate : share}" v-lz-click="'2'" @click="setShareButton"></li>
      </ul>
    </div>
  </div>
</template>

<script>

import apis1 from "../../../util/apis1.js";
let { getTaskWishCard, setShare,getTaskWishCardShare } = apis1;
import { callShare4MiniProgram } from '../../../util/share';
import { getUrlQueryValueByKey } from '../../../util/tools.js';
import store from '../../../store/store.js'; 
export default {
    props: ["styleData", "datas", "keyData", "isTemplate", "templateData",'getTaskresp','wishStartTime'],
  data() {
    return {
      automatic:0,//自动领取任务
      daily:0,//每日登陆领取任务
      share:0,//分享任务
    };
  },
  // 父beforeCreated ->父created ->父beforeMounted ->子beforeCreated ->子created ->子beforeMounted ->子mounted -> 父mounted
  mounted() {
   this.initDatas()
    console.log(this.wishStartTime,11111111111111111111111)
  },
  methods: {
    initDatas(){
        if(this.isTemplate){
          if(this.templateData){
            
          }else{
              this.automatic = 0;
              this.daily = 0;
              this.share = 0
          }

        }else{
             getTaskWishCard((data) => {
      this.automatic = data.data.automatic;
      this.daily = data.data.daily;
      this.share = data.data.share
    });
        }
    },
    //按钮点击
    setShareButton() {
      let actStatus = sessionStorage.getItem('actStatus');

      if (!this.isTemplate) {
        if (actStatus == 2) {
          // Toast
          this.$toast('活动已结束');
          return;
        }
        if (actStatus == 1) {
          this.$toast('活动尚未开始');
          // Toast('活动尚未开始');
          return;
        }
        if (actStatus == 3) {
          // Toast('活动正在惊醒中');
          // this.share = 1

          if( new Date().getTime()<this.wishStartTime){
             this.$toast('未到许愿时间');
          return;
          }else{
              getTaskWishCardShare((data)=>{

          setShare(data => {
            var cur_url = location.href;
            var shareUserId = getUrlQueryValueByKey('shareUserId', cur_url);
            var aUrl = cur_url.substring(0, cur_url.indexOf('shareUserId') + 1);
            console.log(shareUserId, 'shareUserId');
            if (shareUserId) {
              var invitionUrl = aUrl + '&shareUserId=' + data.data.shareUserId;
              // console.log('asdasdasd');
            } else {
              var invitionUrl = location.href + data.data.shareUserId;
              // console.log('233333333');
            }

            if (store.state.clientType == '01') {
              var title = store.state.shareTitle;
              var content = store.state.shareTitle;
              var logoUrl = store.state.shareImage;
              var mpIconUrl = store.state.shareImage;

              var isHeader = false; //false 头部分享 true 按钮分享
              var url = invitionUrl;
              var shopid = store.state.shopId;
              var userpin = store.state.userPin;
              var jdactivityid = store.state.jdActivityId; //'1356071125718585346'//store.state.activityId

              callShare4MiniProgram(
                title,
                content,
                url,
                logoUrl,
                callBack => {
                  console.log('测试分享');
                },
                isHeader,
                mpIconUrl,
                shopid,
                userpin,
                jdactivityid
              );
            } else {
             // this.show = true;
             // this.url = invitionUrl.replace('index/', '');
            
            
            }

            getTaskWishCard((data)=>{

            })
          });
          // return;

        })
          }
        
          
          
        }
      } else {
        this.$toast('活动预览，仅供查看');
      }
    },
  },
};
</script>

<style lang="scss">
.getWishCard ul{
    width: 7.45rem;
  height: 5.5rem;
  // background-image: image('//img10.360buyimg.com/imgzone/jfs/t1/167980/8/17668/158898/6074f947Efd219af2/231411c0b47623bf.png');
  display: flex;
  justify-content: space-around;
  background-image: url(//img10.360buyimg.com/imgzone/jfs/t1/167980/8/17668/158898/6074f947Efd219af2/231411c0b47623bf.png);
  background-size:100% ;
  position: relative;
}
.getWishCard ul .completed{
  width: 1.88rem;
  height: .49rem;
  background-image: url(//img10.360buyimg.com/imgzone/jfs/t1/174774/34/3789/8518/6074f946Ec41241ed/eb2838721b7ed830.png);
  background-size: 100%;
  top: 4.5rem; 
  position: absolute;
}
.getWishCard ul .participate{
  width: 1.88rem;
  height: .49rem;
  background-image: url(//img10.360buyimg.com/imgzone/jfs/t1/167129/25/18325/4322/6074f946Efe82828c/b20323fa4658b552.png);
  background-size: 100%;
  top: 4.5rem; 
  position: absolute;
}
.getWishCard ul li:nth-child(1){
  left: .58rem;
}
.getWishCard ul li:nth-child(2){
  left: 2.8rem;
}
.getWishCard ul li:nth-child(3){
  left: 5rem;
}
</style>
