<template>
  <div class="gotoShopNewDivAll" ref="shareQuertionBtn" @click="styleClick('click', 'shareQuertionBtn')"
    @mousemove="styleClick('mousemove', 'shareQuertionBtn')" @mouseout="styleClick('mouseout')"
    :class="isWebClick ? 'collect-fd2' : 'collect-fd'">
    <div>
      <div :style="styleData.shareQuertionBtn3" v-if="
        dataList.taskShareWaresVO &&
        dataList.taskShareWaresVO.completeCount >=
          dataList.taskShareWaresVO.maxNum * dataList.taskShareWaresVO.finishNum
      ">
      </div>
      <div v-else @click="handlefuhuo(null)">
        <div :style="dataList.shareStatus == 0 ? styleData.shareQuertionBtn0 : styleData.shareQuertionBtn1"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { goToShopPage } from '../../../util/tools.js';
import store from '../../../store/store.js';
import { allShare } from "../../../js/share.js";
import { prizeShare } from '../../../js/share.js';
import apis1 from '../../../util/apis1.js';
import bus from "../../../util/bus.js";

// import sharebg from '../assets/images/share.png'
let { initPage, storeGoodsPoint, shareTask, followShopTask, followShop, getKnowData } = apis1;
export default {
  props: ['datas', 'styleData', 'keyData', 'isTemplate', 'templateData', 'isWebClick', 'modifyContent'],
  data() {
    return {
      styleDataOld: {},
      dataList: {
        shareStatus:0
      },
      fuhuka: '',
    };
  },
    computed: {
    contractFile() {
      return store.state.fenxiang;
    },
  },
  watch: {
    contractFile: {
      immediate: true,
      handler: function (newval) {
        if (newval) {
          // if (this.dataList.shareStatus != 0) {
          //   shareTask(this.dataList.taskShareWaresVO.taskId, "", (data) => {
          //     bus.$emit("fuhuka", this.fuhuka);
          //     store.commit("setFenXiang", false);
          //     this.initData();
          //   });
          // }
        }
      },
    },
  },
  created() {
    //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
    this.initData()
  },
  methods: {
    initData() {
      if(this.isTemplate){
        var datasAll = this.templateData;
        if(datasAll){
           if(datasAll.basicTask.taskList[0].taskType == '12'){
            this.dataList.shareStatus = 1

          } else {
             this.dataList.shareStatus = 0

          }

        }

     
      } else{
        getKnowData((data) => {
        bus.$emit("data", data.data);
        console.log(data,this.dataList.shareStatus == 0, "data");
        this.dataList = data.data;
        this.fuhuka = data.data.reviveCount;
        bus.$emit("fuhuka", this.fuhuka);
        console.log(this.dataList,'this.dataList')
      });
      }
      
    },
    styleClick(type, refName) {
      if (this.isWebClick) {
        //传值给B端
        let byValue = {
          modifyContent: this.modifyContent,
          refName: refName,
          styleData: this.styleData,
          c_this: this,
          styleDataOld: this.styleDataOld
        };
        this.$emit('opertaionCom', type, byValue);
      }
    },
    handlefuhuo() {
       
      // 复活卡次数
      if (this.isTemplate) {
        // this.$toast("活动预览，仅供查看");
        return;
      }
      let actStatus = sessionStorage.getItem("actStatus");
      if (actStatus == 2) {
        this.$toast("活动已结束");
        return;
      }
      if (actStatus == 1) {
        this.$toast("活动尚未开始");
        return;
      }
      console.log(this.dataList);
      if (this.dataList.shareStatus == 0) {
        var url = "";
        url = location.href;
        console.log(url + "url");
        allShare(this.isTemplate, this, (callBackData) => {
          console.log(callBackData, "callBackData" + url);
        });
      } else {
        var url = "";
        url = location.href;
        console.log(url + "url");
        bus.$emit("shareTask", 1);
        allShare(this.isTemplate, this, (callBackData) => {
          console.log(callBackData, "callBackData" + url);
        });
      }
      this.$store.commit("setResurrection", this.fuhuka);
    },
  }
};
</script>

<style lang="scss" scoped="scoped">
.gotoShopNewDivAll {
  // position: sticky;
  // bottom: 0;
  width: 100%;
  z-index: 10;
}
.collect-fd {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  z-index: 10;
}
.collect-fd2 {
  height: 0.88rem;
}
</style>
