<template>
  <div  ref="bargainShare"
    @click="styleClick('click', 'bargainShare')"
    @mousemove="styleClick('mousemove', 'bargainShare')"
    @mouseout="styleClick('mouseout')" v-if="!isHelper" class="setShareDiv" :style="styleData[keyData.shareDivStyle]">
    <div v-if="isWebClick" :style="styleData[keyData.shareStyle]"></div>
    <div v-else :style="styleData[keyData.shareStyle]" v-lz-click="'2'" @click="setShareButton"></div>

  </div>
</template>

<script>
import Vue from 'vue';
import { allShare } from '../../../js/share.js';

import { Popup } from 'vant';
Vue.use(Popup);
import store from '../../../store/store.js';
export default {
  components: {},
  props: ['styleData', 'keyData', 'isTemplate', "isWebClick", "modifyContent"],
  data() {
    return {
      isHelper: false, //是否是助力者进入
      dataAll: {
        shopName: ''
      },
      url: '',
      stime: '',
      etime: '',
      styleDataOld:{},
      dtimestamp: '', //当前时间
      isCustomSwitching: 1
      // submit:'',
    };
  },
  mounted() {
     //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
    this.isHelper = store.state.shareUserId ? true : false;
    this.publicData.$on("kanSwitchValue", (isCustomSwitching, refName) => {
      this.isCustomSwitching = isCustomSwitching;
      if(isCustomSwitching == '1') {
        this.isHelper = false;
      }else if(isCustomSwitching == "2"){
        this.isHelper = true;
      }else if(isCustomSwitching == "3"){
        this.isHelper = true;
      }
    });
    var timestamp = new Date().getTime();
    this.dtimestamp = timestamp;
    this.publicData.$on('bargainTime', (startTime, endTime) => {
      this.stime = startTime;
      this.etime = endTime;
    });
  },
  methods: {
    initData(data) {
      this.dataAll = data;
    },

    setShareButton() {
      allShare(this.isTemplate, this,(callBackData)=>{
        console.log(callBackData,'callBackData')
      });
    },

    copyShare() {
      let div = document.getElementById('copy-content');
      let range = '';
      if (document.body.createTextRange) {
        //兼容ie
        range = document.body.createTextRange();
        range.moveToElementText(div);
        range.select();
      } else if (window.getSelection) {
        // 兼容非IE，比如Firefox/chrome
        let selection = window.getSelection();
        range = document.createRange();
        range.selectNodeContents(div);
        selection.removeAllRanges();
        selection.addRange(range);
      }
      document.execCommand('Copy'); // 执行浏览器复制命令
      this.$toast('已复制好，可粘贴');
      // console.log('已复制好，可贴粘');
    },
     styleClick(type, refName) {
      if (this.isWebClick) {
        //传值给B端
        let byValue = {
          modifyContent: this.modifyContent,
          refName: refName,
          styleData: this.styleData,
          c_this: this,
          isCustomSwitching: this.isCustomSwitching,
          styleDataOld: this.styleDataOld,
        };
        this.$emit("opertaionCom", type, byValue);
      }
    },
  }
};
</script>

<style lang="scss">
.play {
  -moz-transform: rotate(-45deg);
  -webkit-transform: rotate(-4.5deg);
  display: block;
  position: absolute;
  top: 0.2rem;
  width: 100%;
  font-weight: bold;
  color: white;
}
.people span {
  color: #fbdd7d;
}
.van-popup {
  width: 5rem;
  height: 3rem;
  display: flex;
  justify-content: center;
  // align-items: center;
}
.inputshare {
  width: 100%;
  height: 2rem;
  font-size: 0.3rem;
}
// .sharebutton {
//   position: absolute;
//   background: skyblue;
//   top: 1.5rem;
//   left: 0rem;
//   font-size: 0.5rem;
// }
</style>
