<template>
  <div>
    <div :style="styleData.limitMin" v-if="activityType == '10038'">
      <img class="limitMinImg"
        src="//img10.360buyimg.com/imgzone/jfs/t1/213434/32/26845/1397/641d6971F89215d5b/f2ae6d9cb1079103.png" alt="">
      活动期间同一账号，每单每个商品最少购买{{ limitMin }}件，最多可购买{{ limitMax }}件，才可享受专享价。
    </div>

    <div :style="styleData.bargainTeam" ref="bargainTeamNew" @click="styleClick('click', 'bargainTeamNew')"
      @mousemove="styleClick('mousemove', 'bargainTeamNew')" @mouseout="styleClick('mouseout')">

      <div :style="styleData.skuDetail">
        <div :style="styleData.ib"><img :src="goodsImage" style="width: 100%; height: 100%" /></div>
        <div :style="styleData.ibTal">
          <div :style="styleData.goodsName">{{ goodsName }}</div>
          <div :style="styleData.discountPrice">
            <img :style="styleData.discountPriceBack" :src="styleData.discountPriceBack.imageUrl" alt="" />
            ￥{{ discountPrice }}
          </div>
          <div class="price" :style="styleData.price">京东价：￥{{ price | toFixed }}</div>
          <img :key="timer" :style="styleData.goumaitup" :src="styleData.goumaitup.imageUrl" v-lz-click="'5'"
            v-lz-skuid="skuInfo.skuId" @click="goBuy()" />
        </div>
      </div>
      <div class="tacType1" :style="styleData[keyData.tacType1]" v-if="type == 1">
        <div :style="styleData.tacType2">
          已邀请
          <span :style="styleData.tacType5">{{ inviteNum }}</span>
          人，当前价：
          <span :style="styleData.tacType6">￥{{ discountPrice }}</span>
        </div>
        <div style="
          font-size: 0.24rem;
          color: #8c8c8c;
          font-weight: 500;
          margin-bottom: 0.15rem;
        ">
          {{ reallyLevelId3 == 1 ? '真棒，当前价已经是最低价了哦~' : '邀请更多好友砍出超低价' }}
        </div>
        <div class="tacType2">
          <!-- <div class="tacType3" :style="styleData[keyData.tacType3]"></div> -->
          <div class="tacType4">
            <div :style="styleData[keyData.tacType4]">活动开始</div>
            <div class="ibTacGo" :style="styleData[keyData.ibTacGo]">GO</div>
          </div>
          <div class="tacType4">
            <div :class="reallyLevelId1 == 2 && 'decoration'">
              <div :style="reallyLevelId1 == 1 && styleData.tacType4" v-if="displayPrice == 0">￥{{ firstPrice }}</div>
              <div :style="reallyLevelId1 == 1 && styleData.tacType4" v-if="displayPrice == 1">{{ firstPrice }}折</div>
              <div :style="reallyLevelId1 == 1 && styleData.tacType4" v-if="displayPrice == 2">砍{{ firstPrice }}元</div>
            </div>
            <div style="position: relative; width: 100%; height: 0.3rem;">剩余名额：{{ piecesLeft1 }}人</div>
          </div>

          <div class="tacType4">
            <div :class="reallyLevelId2 == 2 && 'decoration'">
              <div :style="reallyLevelId2 == 1 && styleData[keyData.tacType4]" v-if="displayPrice == 0">￥{{ secondPrice }}
              </div>
              <div :style="reallyLevelId2 == 1 && styleData[keyData.tacType4]" v-if="displayPrice == 1">{{ secondPrice }}折
              </div>
              <div :style="reallyLevelId2 == 1 && styleData[keyData.tacType4]" v-if="displayPrice == 2">砍{{ secondPrice
              }}元</div>
            <div style="position: relative; width: 100%; height: 0.3rem;">剩余名额：{{ piecesLeft2 }}人</div>
            </div>

          </div>
          <div class="tacType4">
            <div :class="reallyLevelId3 == 2 && 'decoration'">
              <div :style="reallyLevelId3 == 1 && styleData[keyData.tacType4]" v-if="displayPrice == 0">￥{{ thirdPrice }}元
              </div>
              <div :style="reallyLevelId3 == 1 && styleData[keyData.tacType4]" v-if="displayPrice == 1">{{ thirdPrice }}折
              </div>
              <div :style="reallyLevelId3 == 1 && styleData[keyData.tacType4]" v-if="displayPrice == 2">砍{{ thirdPrice }}元
              </div>
              <div style="position: relative; width: 100%; height: 0.3rem;">剩余名额：{{ piecesLeft3 }}人</div>
            </div>

          </div>
        </div>
        <div class="ibFuHaoBack" style="margin-bottom: 0.9rem;">
          <!-- 砍价的区间线 -->
          <div class="ibFuHaoBackxian">
            <div :class="reallyLevelId1 > 0 ? 'backXian1' : 'backXian'"></div>
            <div :class="reallyLevelId2 > 0 ? 'backXian1' : 'backXian'"></div>
            <div :class="reallyLevelId3 > 0 ? 'backXian1' : 'backXian'"></div>
          </div>
          <!-- 开始 -->
          <img class="ibFuHaoBackImg position"
            src="//img10.360buyimg.com/imgzone/jfs/t1/202544/15/16332/1484/619dfb59Ebb8fea11/890b9279c5478a38.png"
            alt="" />
          <!-- 第一个价格 -->
          <img v-if="reallyLevelId1 == 1 && reallyLevelId2 == 0" class="ibFuHaoBackImg1 positionSuss1"
            src="//img10.360buyimg.com/imgzone/jfs/t1/209502/4/10442/5281/619dfb52E28f76c72/fd57e72afaa2e961.png"
            alt="" />
          <img v-else-if="reallyLevelId2 > 0" class="ibFuHaoBackImg position1"
            src="//img10.360buyimg.com/imgzone/jfs/t1/202544/15/16332/1484/619dfb59Ebb8fea11/890b9279c5478a38.png"
            alt="" />
          <img v-else class="ibFuHaoBackImg position1"
            src="//img10.360buyimg.com/imgzone/jfs/t1/201373/8/16826/1147/619dfb63Ed9db6173/7a44e21f1e20f4ae.png"
            alt="" />


          <!-- 第二个价格 -->
          <img v-if="reallyLevelId2 == 1 && reallyLevelId3 == 0" class="ibFuHaoBackImg1 positionSuss2"
            src="//img10.360buyimg.com/imgzone/jfs/t1/209502/4/10442/5281/619dfb52E28f76c72/fd57e72afaa2e961.png"
            alt="" />
          <img v-else-if="reallyLevelId3 > 0" class="ibFuHaoBackImg position2"
            src="//img10.360buyimg.com/imgzone/jfs/t1/202544/15/16332/1484/619dfb59Ebb8fea11/890b9279c5478a38.png"
            alt="" />
          <img v-else class="ibFuHaoBackImg position2"
            src="//img10.360buyimg.com/imgzone/jfs/t1/201373/8/16826/1147/619dfb63Ed9db6173/7a44e21f1e20f4ae.png"
            alt="" />

          <!-- 第三个价格 -->
          <img v-if="reallyLevelId3 == 1" class="ibFuHaoBackImg1 positionSuss3"
            src="//img10.360buyimg.com/imgzone/jfs/t1/209502/4/10442/5281/619dfb52E28f76c72/fd57e72afaa2e961.png"
            alt="" />
          <img v-else-if="reallyLevelId3 == 2" class="ibFuHaoBackImg position3"
            src="//img10.360buyimg.com/imgzone/jfs/t1/202544/15/16332/1484/619dfb59Ebb8fea11/890b9279c5478a38.png"
            alt="" />
          <img v-else class="ibFuHaoBackImg position3"
            src="//img10.360buyimg.com/imgzone/jfs/t1/201373/8/16826/1147/619dfb63Ed9db6173/7a44e21f1e20f4ae.png"
            alt="" />
          <div style="width: 5.5rem; position: relative; height: 0.8rem; display: flex; justify-content: space-around; left: 1.05rem; top: 0.2rem;">
            <div class="tacType4">

              <div class="ibFuHao1" :style="reallyLevelId1 == 1 && styleData[keyData.ibTacGo]">邀请{{ inviteFirst }}人</div>

            </div>
            <div class="tacType4">

              <div class="ibFuHao2" :style="reallyLevelId2 == 1 && styleData[keyData.ibTacGo]">邀请{{ inviteSecond }}人</div>

            </div>
            <div class="tacType4">

              <div class="ibFuHao3" :style="reallyLevelId3 == 1 && styleData[keyData.ibTacGo]">邀请{{ inviteThird }}人</div>

            </div>
          </div>


        </div>
        <div class="piecesLeftCont" v-if="activityType != '10038'">
          <div style="opacity: 0">剩余{{ piecesLeft1 }}件</div>
          <div>
            剩余
            <span class="piecesLeftFont">{{ piecesLeft1 }}</span>
            件
          </div>
          <div>
            剩余
            <span class="piecesLeftFont">{{ piecesLeft2 }}</span>
            件
          </div>
          <div>
            剩余
            <span class="piecesLeftFont">{{ piecesLeft3 }}</span>
            件
          </div>
        </div>
      </div>

      <div v-if="helpStatus == 4" :class="[isWebClick ? '' : 'drawKsqg']" :style="styleData[keyData.drawKsqg]" >
        <div v-if="needFollowShop == 0" class="drawUnpackingBtn1" :style="styleData[keyData.drawUnpackingBtn]"
          v-lz-click="'2'" @click="clickShare()">
          立即召唤小伙伴帮砍价
        </div>
        <div v-else class="drawUnpackingBtn3" :style="styleData[keyData.drawUnpackingBtn]" v-lz-click="'2'"
          @click="clickShare()">
          关注店铺+召唤小伙伴
        </div>
      </div>
      <div v-if="type == 0">
        <div class="yaoQing">
          <img :src="initiatorImage" alt="" class="yaoQingImg" />
          <span class="yaoQingColor">{{ initiatorName | twostar }}：</span>
        </div>
        <div v-if="helpStatus == 0" :class="[isWebClick ? '' : 'drawKsqgss']" :style="styleData[keyData.drawKsqgss]">
          <div>
            <div class="wenan">小伙伴们，快来帮我砍价吧~</div>
            <div class="wenan1">【朋友一生一起走，帮砍一刀有没有】</div>
          </div>
          <div v-if="needFollowShop == 0" class="drawUnpackingBtn2" :style="styleData[keyData.drawUnpackingBtn]"
            @click="joinTeam()">
            立即帮TA砍一刀
          </div>
          <div v-else class="drawUnpackingBtn4" :style="styleData[keyData.drawUnpackingBtn]" @click="joinTeam()">
            关注店铺+帮TA砍一刀
          </div>
        </div>
        <div v-if="helpStatus == 1 || helpStatus == 3" :style="styleData[keyData.fTac]">
          <div class="wenankan" v-if="preferentialWay == 0">奥里给，已经帮我砍过价了~</div>
          <div class="wenankan" v-if="preferentialWay == 1">您已经为其他好友砍过价~</div>
          <!-- <div style="margin-top: 0.2rem" v-if="preferentialWay == 1">
          参与砍价人均可享受优惠
        </div> -->
          <div class="wenan1">【一声朋友你会懂，发现好货就出手】</div>
          <div style="margin-top: 0.05rem">
            <div v-if="preferentialWay == 0" v-lz-click="'25'" :style="styleData.drawUnpackingBtn" @click="goToActive()">
              我也要参加
            </div>
            <div v-else :style="styleData.drawUnpackingBtn" v-lz-click="'25'" @click="clickShare()">
              立即召唤小伙伴帮砍价
            </div>
          </div>
          <div class="yaoqingyi">活动期间只能为一位好友砍价。</div>
        </div>
        <!-- <div
        style="color: #51a86b; position: relative"
        v-else-if="helpStatus == 3"
      >
        <div>您已经为其他好友砍过价。</div>
        <div style="margin-top: 0.2rem">活动期间只能为一位好友砍价。</div>
      </div> -->

        <!-- <div
        v-if="helpStatus == 1 || helpStatus == 3"
        style="margin-top: 0.2rem; position: relative"
      >
        <div style="margin-top: 0.05rem" v-if="preferentialWay == 0">
          <a
            class="ib"
            :style="styleData[keyData.ib]"
            v-lz-click="'25'"
            style="
              width: 1.5rem;
              height: 0.5rem;
              text-align: center;
              border-radius: 0.06rem;
              line-height: 0.48rem;
              color: rgb(83, 153, 101);
              background: yellow;
              font-size: 0.24rem;
            "
            @click="goToActive()"
            >我也要参加</a
          >
        </div>
        <div style="margin-top: 0.05rem" v-else>
          <a
            class="ib"
            :style="styleData[keyData.ib]"
            v-lz-click="'25'"
            style="
              width: 1.75rem;
              height: 0.5rem;
              text-align: center;
              border-radius: 0.06rem;
              line-height: 0.48rem;
              color: rgb(83, 153, 101);
              background: yellow;
              font-size: 0.24rem;
            "
            @click="clickShare()"
            >邀请朋友帮忙砍</a
          >
        </div>
      </div> -->
      </div>
      <!-- <div
      v-if="type == 0 && helpStatus == 0"
      class="cbYaoQing"
      :style="styleData[keyData.cbYaoQing]"
    >
      <div class="ib" :style="styleData[keyData.ib]">
        <img
          :src="initiatorImage"
          alt=""
          class="yaoQingImg"
          :style="styleData[keyData.yaoQingImg]"
        />
      </div>
      <div
        class="ib"
        :style="styleData[keyData.ib]"
        style="margin-left: 0.2rem; font-size: 0.25rem; color: #51a86b"
      >
        <div>{{ initiatorName | twostar }} 邀请您帮忙砍价</div>
      </div>
    </div> -->
    </div>
  </div>
</template>

<script>
import apis1 from '../../../util/apis1.js';
import store from '../../../store/store';
import { newToSkuPage, goToShopPage } from '../../../util/tools.js';
import { allShare } from '../../../js/share.js';
import dateUtil from '../../../util/dateUtil';
import { joinVipService1, BargainMemberPopComService1 } from '../../../util/comCreate.js';
// import { float } from 'html2canvas/dist/types/css/property-descriptors/float';
let { taskBargaining, barginFollowShop, barginToBargain, getToken, barginShareUserList, storeGoodsPoint } = apis1;

export default {
  props: ['isTemplate', 'datas', 'keyData', 'styleData', 'templateData', 'isWebClick', 'modifyContent'],
  data() {
    return {
      timer: new Date().getTime(),
      bargainRule: '', // 0 打折优惠 1 减钱优惠
      inviteFirst: '', //门槛邀请人数
      piecesLeft1: '',//门槛1剩余名额
      piecesLeft2: '',//门槛2剩余名额
      piecesLeft3: '',//门槛3剩余名额
      discountFirst: '', // 门槛1折扣
      totalFirst: '', // 门槛1优惠件数
      inviteSecond: '', // 门槛2邀请人数
      discountSecond: '',
      totalSecond: '',
      inviteThird: '',
      discountThird: '',
      totalThird: '',
      ifLimit: '', //0不限购 1限购
      limitMin: '',
      limitMax: '',
      displayPrice: '', //0 优惠价 1优惠折扣 2砍掉价格
      preferentialWay: '', //0独享 1共享
      id: 'id',
      skuInfo: '',
      price: 'price', //商品价格
      firstPrice: '',
      secondPrice: '',
      thirdPrice: '',
      discountPrice: '', //优惠价格
      goodsImage: '',
      goodsName: '',
      showTeamList: false,
      type: '',
      initiatorName: '',
      initiatorImage: '',
      discount: '',
      piecesLeft1: '',
      piecesLeft2: '',
      piecesLeft3: '',
      followShopFlag: '',
      needFollowShop: '',
      shopName: '',
      condition1Empty: true,
      condition2Empty: true,
      condition3Empty: true,
      reallyLevelId: 0,
      reallyLevelId1: 0,
      reallyLevelId2: 0,
      reallyLevelId3: 0,
      helpStatus: 0,
      joinVipList: [],
      styleDataOld: {},
      isCustomSwitching: '', //有tab切换时
      inviteNum: 0,
      limitMin: 1,// 最小限制数
      limitMax: 1, //最大限制数
      activityType: sessionStorage.getItem('activityType')
    };
  },
  created() {
    this.initData();
    //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
  },
  // filters: {
  //   twostar: function (value) {
  //     if (!value) {
  //       return "";
  //     }
  //     return value.substr(0, 1) + "**" + value.substr(-1, 1);
  //   },
  //   toFixed: function (value) {
  //     if (!value) {
  //       return "";
  //     }
  //     return value.toFixed(2);
  //   },
  // },

  methods: {
    styleClick(type, refName) {
      if (this.isWebClick) {
        //传值给B端
        let byValue = {
          modifyContent: this.modifyContent,
          refName: refName,
          styleData: this.styleData,
          isCustomSwitching: this.isCustomSwitching, //有tab切换时
          c_this: this,
          styleDataOld: this.styleDataOld
        };
        this.$emit('opertaionCom', type, byValue);
      }
    },
    goToActive() {
      this.type = 1;
      this.helpStatus = 4;
      taskBargaining(bargain => {
        this.bargainRule = bargain.data.rule.bargainRule;
        this.inviteFirst = bargain.data.rule.inviteFirst;
        this.discountFirst = bargain.data.discountFirst;
        this.piecesLeft1 = bargain.data.piecesLeft1;
        this.piecesLeft2 = bargain.data.piecesLeft2;
        this.piecesLeft3 = bargain.data.piecesLeft3;
        this.totalFirst = bargain.data.rule.totalFirst;
        this.inviteSecond = bargain.data.rule.inviteSecond;
        this.discountSecond = bargain.data.discountSecond;
        this.totalSecond = bargain.data.rule.totalSecond;
        this.inviteThird = bargain.data.rule.inviteThird;
        this.discountThird = bargain.data.discountThird;
        this.totalThird = bargain.data.rule.totalThird;
        this.ifLimit = bargain.data.rule.ifLimit;
        this.limitMin = bargain.data.rule.limitMin;
        this.limitMax = bargain.data.rule.limitMax;
        this.displayPrice = bargain.data.rule.displayPrice;
        this.preferentialWay = bargain.data.rule.preferentialWay;
        this.skuInfo = bargain.data.skuInfo;
        this.price = bargain.data.skuInfo.skuPrice;
        this.discountPrice = bargain.data.skuInfo.skuPrice;
        this.goodsName = bargain.data.skuInfo.skuName;
        this.goodsImage = bargain.data.skuInfo.skuImg;
        this.piecesLeft1 = bargain.data.piecesLeft1;
        this.piecesLeft2 = bargain.data.piecesLeft2;
        this.piecesLeft3 = bargain.data.piecesLeft3;
        this.followShopFlag = bargain.data.followShopFlag;
        this.needFollowShop = bargain.data.needFollowShop;
        this.discount = bargain.data.discount;
        this.limitMax = bargain.data.rule.limitMax
        this.limitMin = bargain.data.rule.limitMin
        this.firstPrice = this.discountFirst;
        this.secondPrice = this.discountSecond;
        this.thirdPrice = this.discountThird;
        console.log(this.skuInfo, 'this.skuInfo');

        let condition1Empty = bargain.data.condition1Empty;
        let condition2Empty = bargain.data.condition2Empty;
        let condition3Empty = bargain.data.condition3Empty;
        let reallyLevelId1 = bargain.data.reallyLevelId1;
        let reallyLevelId2 = bargain.data.reallyLevelId2;
        let reallyLevelId3 = bargain.data.reallyLevelId3;

        if (this.bargainRule == 0) {
          if (this.reallyLevelId3 == 1) {
            if (reallyLevelId3 == 1) {
              this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
            } else {
              if (condition3Empty == false) {
                this.discountPrice = this.price;
              } else {
                this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
              }
            }
          }

          if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 1) {
            if (reallyLevelId2 == 1) {
              this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
            } else {
              if (condition2Empty == false) {
                this.discountPrice = this.price;
              } else {
                this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
              }
            }
          }
          if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 1) {
            if (reallyLevelId1 == 1) {
              this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
            } else {
              if (condition1Empty == false) {
                this.discountPrice = this.price;
              } else {
                this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
              }
            }
          }
          if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 0) {
            this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
          }
        } else {
          if (this.reallyLevelId3 == 1) {
            if (reallyLevelId3 == 1) {
              this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
            } else {
              if (condition3Empty == false) {
                this.discountPrice = this.price;
              } else {
                this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
              }
            }
          }
          if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 1) {
            if (reallyLevelId2 == 1) {
              this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
            } else {
              if (condition2Empty == false) {
                this.discountPrice = this.price;
              } else {
                this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
              }
            }
          }
          if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 1) {
            if (reallyLevelId1 == 1) {
              this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
            } else {
              if (condition1Empty == false) {
                this.discountPrice = this.price;
              } else {
                this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
              }
            }
          }
          if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 0) {
            this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
          }
        }
      });
      this.publicData.$emit('bargainTeamJoin', false);
    },
    initData() {
      var datasAll = this.templateData;
      console.log(datasAll);
      if (this.isTemplate == true) {
        if (!this.isWebClick) {
          this.$toast('活动预览，仅供查看');
        }
        if (datasAll) {
          this.price = datasAll.bargain.skuInfo.price;
          this.discountPrice = datasAll.bargain.skuInfo.price;
          this.goodsName = datasAll.bargain.skuInfo.name;
          this.goodsImage = datasAll.bargain.skuInfo.imagePath;
          this.helpStatus = 4;
          this.condition1Empty = true;
          this.condition2Empty = true;
          this.condition3Empty = true;
          this.reallyLevelId = 0;
          this.bargainRule = datasAll.bargain.bargainRule;
          this.inviteFirst = datasAll.bargain.inviteFirst;
          this.discountFirst = datasAll.bargain.discountFirst;
          this.piecesLeft1 = datasAll.bargain.piecesLeft1;
          this.piecesLeft2 = datasAll.bargain.piecesLeft2;
          this.piecesLeft3 = datasAll.bargain.piecesLeft3;
          this.totalFirst = datasAll.bargain.totalFirst;
          this.inviteSecond = datasAll.bargain.inviteSecond;
          this.discountSecond = datasAll.bargain.discountSecond;
          this.totalSecond = datasAll.bargain.totalSecond;
          this.inviteThird = datasAll.bargain.inviteThird;
          this.discountThird = datasAll.bargain.discountThird;
          this.totalThird = datasAll.bargain.totalThird;
          this.ifLimit = datasAll.bargain.ifLimit;
          this.limitMin = datasAll.bargain.limitMin;
          this.limitMax = datasAll.bargain.limitMax;
          this.displayPrice = datasAll.bargain.displayPrice;
          this.preferentialWay = datasAll.bargain.preferentialWay;
          this.piecesLeft1 = datasAll.bargain.totalFirst;
          this.piecesLeft2 = datasAll.bargain.totalSecond;
          this.piecesLeft3 = datasAll.bargain.totalThird;
          this.shopName = datasAll.activity.shopName;
          this.type = 1;
          this.discount = 10;
          this.needFollowShop = 0; //datasAll.activeConditions.involvementFlag;
          if (this.bargainRule == 0) {
            if (this.displayPrice == 0) {
              this.firstPrice = parseFloat((this.price * this.discountFirst) / 10).toFixed(2);
              this.secondPrice = parseFloat((this.price * this.discountSecond) / 10).toFixed(2);
              this.thirdPrice = parseFloat((this.price * this.discountThird) / 10).toFixed(2);
              this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
            } else if (this.displayPrice == 1) {
              this.firstPrice = this.discountFirst;
              this.secondPrice = this.discountSecond;
              this.thirdPrice = this.discountThird;
              this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
            } else if (this.displayPrice == 2) {
              this.firstPrice = parseFloat(this.price - (this.price * this.discountFirst) / 10).toFixed(2);
              this.secondPrice = parseFloat(this.price - (this.price * this.discountSecond) / 10).toFixed(2);
              this.thirdPrice = parseFloat(this.price - (this.price * this.discountThird) / 10).toFixed(2);
              this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
            }
          } else {
            if (this.displayPrice == 0) {
              this.firstPrice = parseFloat(this.price - this.discountFirst).toFixed(2);
              this.secondPrice = parseFloat(this.price - this.discountSecond).toFixed(2);
              this.thirdPrice = parseFloat(this.price - this.discountThird).toFixed(2);
              this.discountPrice = parseFloat(this.price).toFixed(2);
            } else if (this.displayPrice == 1) {
              this.firstPrice = parseFloat(((this.price - this.discountFirst) / this.price) * 10).toFixed(1);
              this.secondPrice = parseFloat(((this.price - this.discountSecond) / this.price) * 10).toFixed(1);
              this.thirdPrice = parseFloat(((this.price - this.discountThird) / this.price) * 10).toFixed(1);
              this.discountPrice = parseFloat(this.price).toFixed(2);
            } else if (this.displayPrice == 2) {
              this.firstPrice = parseFloat(this.discountFirst).toFixed(2);
              this.secondPrice = parseFloat(this.discountSecond).toFixed(2);
              this.thirdPrice = parseFloat(this.discountThird).toFixed(2);
              this.discountPrice = parseFloat(this.price).toFixed(2);
            }
          }
        } else {
          this.price = 100;
          this.discountPrice = 100;
          this.goodsName = '本儿夹子';
          this.goodsImage = 'http://img12.360buyimg.com/n0/jfs/t1/163350/35/7270/371414/6034cdefEfba59493/98a23d8b2ba8cc92.jpg';
          this.helpStatus = 4;
          this.condition1Empty = true;
          this.condition2Empty = true;
          this.condition3Empty = true;
          this.reallyLevelId = 0;
          this.bargainRule = 0;
          this.inviteFirst = 1;
          this.discountFirst = 5;
          this.totalFirst = 10;
          this.inviteSecond = 5;
          this.discountSecond = 10;
          this.totalSecond = 5;
          this.inviteThird = 10;
          this.discountThird = 15;
          this.totalThird = 2;
          this.ifLimit = 0;
          this.limitMin = 0;
          this.limitMax = 0;
          this.displayPrice = 0;
          this.preferentialWay = 0;
          this.piecesLeft1 = 1;
          this.piecesLeft2 = 1;
          this.piecesLeft3 = 1;
          this.shopName = 'xxx京东自营官方旗舰店';
          this.type = 1;
          this.discount = 10;
          this.needFollowShop = 0;

          if (this.bargainRule == 0) {
            this.firstPrice = parseFloat((this.price * this.discountFirst) / 10).toFixed(2);
            this.secondPrice = parseFloat((this.price * this.discountSecond) / 10).toFixed(2);
            this.thirdPrice = parseFloat((this.price * this.discountThird) / 10).toFixed(2);
            this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
          } else {
            this.firstPrice = parseFloat(this.price - this.discountFirst).toFixed(2);
            this.secondPrice = parseFloat(this.price - this.discountSecond).toFixed(2);
            this.thirdPrice = parseFloat(this.price - this.discountThird).toFixed(2);
            this.discountPrice = parseFloat(this.price).toFixed(2);
          }
        }
      } else {
        barginShareUserList(bargain => {
          this.inviteNum = bargain.data.inviteNum;
        });
        this.type = store.state.shareUserId ? '0' : '1'; // 1 主端 0 客端
        taskBargaining(bargain => {
          if (bargain.data.isMemberOk == 1) {
            this.doFrontBuryPoint({ code: 'tc-ljrh', value: '', event: 'pop' })
            joinVipService1.create(bargain.data, submit => {
              joinVipService1.close();
              return;
            });
          } else if (bargain.data.isMemberOk == 2) {
            BargainMemberPopComService1.create(submit => {
              BargainMemberPopComService1.close();
              return;
            });
          }
          this.bargainRule = bargain.data.rule.bargainRule;
          this.inviteFirst = bargain.data.rule.inviteFirst;
          this.discountFirst = bargain.data.discountFirst;
          this.totalFirst = bargain.data.rule.totalFirst;
          this.inviteSecond = bargain.data.rule.inviteSecond;
          this.discountSecond = bargain.data.discountSecond;
          this.totalSecond = bargain.data.rule.totalSecond;
          this.inviteThird = bargain.data.rule.inviteThird;
          this.discountThird = bargain.data.discountThird;
          this.totalThird = bargain.data.rule.totalThird;
          this.ifLimit = bargain.data.rule.ifLimit;
          this.limitMin = bargain.data.rule.limitMin;
          this.limitMax = bargain.data.rule.limitMax;
          this.displayPrice = bargain.data.rule.displayPrice;
          this.preferentialWay = bargain.data.rule.preferentialWay;
          this.skuInfo = bargain.data.skuInfo;
          this.price = bargain.data.skuInfo.skuPrice;
          this.discountPrice = bargain.data.skuInfo.skuPrice;
          this.goodsName = bargain.data.skuInfo.skuName;
          this.goodsImage = bargain.data.skuInfo.skuImg;
          this.piecesLeft1 = bargain.data.piecesLeft1;
          this.piecesLeft2 = bargain.data.piecesLeft2;
          this.piecesLeft3 = bargain.data.piecesLeft3;
          this.followShopFlag = bargain.data.followShopFlag;
          this.needFollowShop = bargain.data.needFollowShop;
          this.discount = bargain.data.discount;
          this.shopName = bargain.data.shopName;
          this.condition1Empty = bargain.data.condition1Empty;
          this.condition2Empty = bargain.data.condition2Empty;
          this.condition3Empty = bargain.data.condition3Empty;
          this.reallyLevelId1 = bargain.data.reallyLevelId1;
          this.reallyLevelId2 = bargain.data.reallyLevelId2;
          this.reallyLevelId3 = bargain.data.reallyLevelId3;
          this.helpStatus = bargain.data.helpStatus;

          this.firstPrice = this.discountFirst;
          this.secondPrice = this.discountSecond;
          this.thirdPrice = this.discountThird;
          this.timer = new Date().getTime();

          if (this.type == 0) {
            this.initiatorName = bargain.data.inviteUser.nickName;
            this.initiatorImage = bargain.data.inviteUser.userImg;
          }
          this.publicData.$emit('bargainTeamHelpStatus', this.helpStatus);
          let condition1Empty = bargain.data.condition1Empty;
          let condition2Empty = bargain.data.condition2Empty;
          let condition3Empty = bargain.data.condition3Empty;
          let reallyLevelId1 = bargain.data.reallyLevelId1;
          let reallyLevelId2 = bargain.data.reallyLevelId2;
          let reallyLevelId3 = bargain.data.reallyLevelId3;

          // 0 打折优惠 1 减钱优惠
          if (this.bargainRule == 0) {
            if (this.reallyLevelId3 == 1) {
              if (reallyLevelId3 == 1) {
                this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
              } else {
                if (condition3Empty == false) {
                  this.discountPrice = this.price;
                } else {
                  this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
                }
              }
            }

            if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 1) {
              if (reallyLevelId2 == 1) {
                this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
              } else {
                if (condition2Empty == false) {
                  this.discountPrice = this.price;
                } else {
                  this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
                }
              }
            }

            if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 1) {
              if (reallyLevelId1 == 1) {
                this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
              } else {
                if (condition1Empty == false) {
                  this.discountPrice = this.price;
                } else {
                  this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
                }
              }
            }
            if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 0) {
              this.discountPrice = parseFloat((this.price * this.discount) / 10).toFixed(2);
            }
          } else {
            if (this.reallyLevelId3 == 1) {
              if (reallyLevelId3 == 1) {
                this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
              } else {
                if (condition3Empty == false) {
                  this.discountPrice = this.price;
                } else {
                  this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
                }
              }
            }

            if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 1) {
              if (reallyLevelId2 == 1) {
                this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
              } else {
                if (condition2Empty == false) {
                  this.discountPrice = this.price;
                } else {
                  this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
                }
              }
            }

            if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 1) {
              if (reallyLevelId1 == 1) {
                this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
              } else {
                if (condition1Empty == false) {
                  this.discountPrice = this.price;
                } else {
                  this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
                }
              }
            }
            if (this.reallyLevelId3 == 0 && this.reallyLevelId2 == 0 && this.reallyLevelId1 == 0) {
              this.discountPrice = parseFloat(this.price - this.discount).toFixed(2);
            }
          }
        });
      }
    },

    clickShare() {
      if (this.isTemplate == true) {
        if (!this.isWebClick) {
          this.$toast('活动预览，仅供查看');
        }
        return;
      }
      if (this.followShopFlag == false && this.needFollowShop == 1) {
        barginFollowShop(data => { });
      }
      this.doFrontBuryPoint({ code: 'ljq-ljzh', value: '', event: 'click' })
      allShare(this.isTemplate, this, callBackData => {
        console.log(callBackData, 'callBackData');
      });
    },
    goToShop() {
      if (this.isTemplate == true) {
        if (!this.isWebClick) {
          this.$toast('活动预览，仅供查看');
        }
        return;
      }
      let shopId = store.state.shopId;
      storeGoodsPoint(4);
      goToShopPage(shopId);
    },
    goBuy() {
      if (this.isTemplate == true) {
        if (!this.isWebClick) {
          this.$toast('活动预览，仅供查看');
        }
        return;
      }
      this.doFrontBuryPoint({ code: 'ljq-ljgm', value: '', event: 'click' })
      storeGoodsPoint(5);
      newToSkuPage(this.skuInfo);
    },
    //我也要参加
    joinTeam() {
      // 判断关注店铺 - sgx
      if (this.followShopFlag == false && this.needFollowShop == 1) {
        barginFollowShop(data => { });
      }
      barginToBargain(store.state.shareUserId, data => {
        this.helpStatus = data.data.helpStatus;
        if (this.helpStatus == 3) {
          this.doFrontBuryPoint({ code: 'ljq-ljzh', value: '', event: 'click' })
          setTimeout(() => {
            this.$toast('您已经为其他好友砍过价了');
          }, 200);
        } else if (this.helpStatus == 1) {
          setTimeout(() => {
            this.$toast('恭喜您成功帮他砍价');
          }, 200);
          return;
        }
      });
    }
  },
  filters: {
    twostar: function (value) {
      if (!value) {
        return '';
      }
      return value.substr(0, 1) + '**' + value.substr(-1, 1);
    },
    //时间转换
    dateTime(val) {
      if (val) {
        return dateUtil.formatTime(val, 'yyyy-MM-dd hh:mm');
      }
      return val;
    },
    toFixed: function (value) {
      console.log(32, value);
      if (!value) {
        return '';
      } else {
        return Number(value).toFixed(2);
      }
    }
  }
};
</script>

<style lang="scss" scoped>
.tacType4 {
  font-size: 0.2rem;
  color: #8c8c8c;
}

.decoration {
  text-decoration: line-through;
}

.tacType2 {
  display: flex;
  justify-content: space-between;
  margin: 0 0.3rem;
}

.ibFuHaoBack {
  width: 5.7rem;
  height: 0.2rem;
  background: linear-gradient(90deg, #ff9900 0%, #f2270c 100%);
  border-radius: 10px;
  margin: 0.37rem auto 0;
  position: relative;

  .ibFuHaoBackxian {
    width: 5.7rem;
    height: 0.2rem;
    border-radius: 10px;
    margin: 0.37rem auto 0;
    display: flex;

    .backXian {
      width: 33.3%;
      background: #f2f2f2;
    }

    .backXian1 {
      width: 33.3%;
    }
  }

  .ibFuHaoBackImg {
    width: 0.36rem;
    height: 0.36rem;
    position: absolute;
  }

  .ibFuHaoBackImg1 {
    width: 0.74rem;
    height: 0.74rem;
    position: absolute;
  }

  .position {
    top: -0.08rem;
    left: -0.04rem;
  }

  .position1 {
    top: -0.08rem;
    left: 1.82rem;
  }

  .position2 {
    top: -0.08rem;
    left: 3.63rem;
  }

  .position3 {
    top: -0.08rem;
    right: -0.04rem;
  }

  .positionSuss1 {
    top: -0.27rem;
    left: 1.62rem;
  }

  .positionSuss2 {
    top: -0.27rem;
    left: 3.42rem;
  }

  .positionSuss3 {
    top: -0.27rem;
    right: -0.15rem;
  }
}

.piecesLeftCont {
  margin: 0.34rem 0.3rem 0;
  display: flex;
  justify-content: space-between;
  font-size: 0.2rem;
  color: #bfbfbf;

  .piecesLeftFont {
    color: #ff9900;
  }
}

.ibTacGo {
  margin-top: 0.05rem;
}

.yaoQing {
  display: flex;
  align-items: center;
  margin: 0.5rem 0 0 0.4rem;
}

.yaoQingImg {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.21rem;
}

.yaoQingColor {
  font-size: 0.24rem;
  color: #8c8c8c;
}

.wenan {
  font-size: 0.3rem;
  color: #ff9900;
  font-weight: bold;
}

.wenan1 {
  font-size: 0.24rem;
  color: #8c8c8c;
  margin-bottom: 0.67rem;

  font-weight: 500;
}

.wenankan {
  font-size: 0.3rem;
  color: #262626;
  font-weight: bold;
}

.yaoqingyi {
  font-size: 0.24rem;
  color: #f2270c;
  font-weight: 500;
}

.cb,
.cbli li {
  zoom: 1;
}

.fl {
  float: left;
}

.fr {
  float: right;
}

.limitMinImg {
  width: 0.3rem;
  display: inline-block;
  vertical-align: middle;
  margin-right: 0.1rem;
}</style>
