<template>
  <div :style="styleData.infoContainer3" ref="fansTask" @click="styleClick('click', 'fansTask')"
    @mousemove="styleClick('mousemove', 'fansTask')" @mouseout="styleClick('mouseout')">
    <div>
      <img :src="styleData.containerTask.imageUrl" alt="" :style="styleData.containerTask" />
    </div>
    <div :style="styleData.questionO" @click="openStrategyDialog">
      <div :style="styleData.questionoo">能量分领取攻略</div>
    </div>
    <div :style="styleData.taskDiv" v-if="showPage">
      <div :style="styleData.dayTaskContainer" v-if="isShowEvery">
        <div :style="styleData.dayTasks">
          <img :style="styleData.imgDayImg"
            src="//img10.360buyimg.com/imgzone/jfs/t1/86352/31/709/1850/5db16efdE6292ad56/ea2810bee7b2c0e2.png">
          <div :style="styleData.dayTaskText">
            任务<span :style="styleData.dayTaskSpan">每日更新</span>哦，明天也来看看吧～
          </div>
        </div>
        <div v-for="(item, index) in taskList" :key="index">
          <template
            v-if="item.activeOrDay && item.activeOrDay == '1' || item.taskType == 9 || item.taskType == 10 || item.taskType == 12 || item.taskType == 14">
            <!--每日签到-->
            <div :style="styleData.activityTask" v-if="item.taskType == 14">
              <img src="//img10.360buyimg.com/imgzone/jfs/t1/53326/19/14145/7367/5db174b0Ec4274557/e72cf8037ed63f4d.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderActivity">
                <div :style="styleData.taskText">每日签到</div>
                <div :style="styleData.scoreEng">
                  能量分+{{ item.sendNum }}，每日上限{{ item.maxNum }}次
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan">
                  <van-progress pivot-text="" color="#ee0a24" :percentage="(item.completeCount/item.maxNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': item.status == 1,
            }" @click="statusBtn(item, item.taskType)">
                {{ item.status == 1 ? "已完成" : "去签到" }}({{
                item.completeCount
              }}/{{ item.maxNum }})
              </div>
            </div>
            <!--浏览店铺-->
            <div :style="styleData.dayTask" v-if="item.taskType == 2">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/92381/40/626/7290/5db174afE545730d9/9e6bcf473ba09345.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderDay">
                <div :style="styleData.taskText">浏览店铺</div>
                <div :style="styleData.scoreEng">
                  能量分+{{ item.sendNum }}，每日上限{{ item.maxNum }}次
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan" v-if="item.completeCount >=0 &&item.maxNum >= 0">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="((item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum)/item.maxNum)*100" />
                </div>
              </div>

              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': item.status == 1,
            }" @click="statusBtn(item, item.taskType)">
                {{ item.status == 1 ? "已完成" : "去浏览" }}<span
                  v-if="item.completeCount >=0 &&item.maxNum >= 0">({{ item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum }}/{{ item.maxNum }})</span>
              </div>
            </div>

            <!--浏览商品-->
            <div :style="styleData.dayTask" v-if="item.taskType == 3">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/58005/3/14090/8177/5db17629Ebd8e5557/493c5e57845e2fe5.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderDay">
                <div :style="styleData.taskText">浏览商品</div>
                <div :style="styleData.scoreEng">
                  能量分+{{ item.sendNum }}，每日上限{{ item.maxNum }}次
                </div>
              </div>
              <div :style="styleData.progressDiv" v-if="item.completeCount >=0 &&item.maxNum >= 0">
                <div :style="styleData.progressVan">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="((item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum)/item.maxNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': item.status == 1,
            }" @click="statusBtn(item, item.taskType)">
                {{ item.status == 1 ? "已完成" : "去浏览" }}({{
                item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum
              }}/{{ item.maxNum }})
              </div>
            </div>

            <!--浏览会场/直播-->
            <div :style="styleData.dayTask" v-if="item.taskType == 4">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/105326/18/674/7478/5db176b6E81f35354/5ed3596ee291e2e8.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderDay">
                <div :style="styleData.taskText">浏览会场/直播</div>
                <div :style="styleData.scoreEng">
                  能量分+{{ item.sendNum }}，每日上限{{ item.maxNum }}次
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan" v-if="item.completeCount >=0 &&item.maxNum >= 0">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="((item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum) /item.maxNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': item.status == 1,
            }" @click="statusBtn(item, item.taskType)">
                {{ item.status == 1 ? "已完成" : "去浏览" }}({{
                item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum
              }}/{{ item.maxNum }})
              </div>
            </div>
            <!--分享商品-->
            <div :style="styleData.dayTask" v-if="item.taskType == 9">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/82313/33/13620/8143/5db174afE335545ef/7e830e66e70ecb4b.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderDay">
                <div :style="styleData.taskText">分享商品</div>
                <div :style="styleData.scoreEng">
                  能量分+{{ item.sendNum }}，每日上限{{ item.maxNum }}次
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="((item.shareCount/ item.finishNum) / item.maxNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': !(item.maxNum > item.shareCount / item.finishNum),
            }" @click="moreDrawChanceShare(item, item.taskType, item)">
                {{ !(item.maxNum > item.shareCount / item.finishNum) ? "已完成" : "去分享" }}({{
                item.shareCount/ item.finishNum
              }}/{{ item.maxNum }})
              </div>
            </div>
            <!--分享店铺-->
            <div :style="styleData.dayTask" v-if="item.taskType == 10">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/82313/33/13620/8143/5db174afE335545ef/7e830e66e70ecb4b.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderDay">
                <div :style="styleData.taskText">分享店铺</div>
                <div :style="styleData.scoreEng">
                  能量分+{{ item.sendNum }}，每日上限{{ item.maxNum }}次
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="(Math.floor(item.shareCount/ item.finishNum) / item.maxNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': !(item.maxNum > item.shareCount / item.finishNum),
            }" @click="moreDrawChanceShare(item, item.taskType, item)">
                {{ !(item.maxNum > item.shareCount / item.finishNum)? "已完成" : "去分享" }}({{
                Math.floor(item.shareCount/ item.finishNum)
              }}/{{ item.maxNum }})
              </div>
            </div>
            <!--分享活动-->
            <div :style="styleData.dayTask" v-if="item.taskType == 12">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/82313/33/13620/8143/5db174afE335545ef/7e830e66e70ecb4b.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderDay">
                <div :style="styleData.taskText">分享活动</div>
                <div :style="styleData.scoreEng">
                  能量分+{{ item.sendNum }}，每日上限{{ item.maxNum }}次
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="(Math.floor(item.shareCount/ item.finishNum) / item.maxNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': !(item.maxNum > item.shareCount / item.finishNum),
            }" @click="moreDrawChanceShare(item, item.taskType, item)">
                {{ !(item.maxNum > item.shareCount / item.finishNum) ? "已完成" : "去分享" }}({{
                 Math.floor(item.shareCount/ item.finishNum)
              }}/{{ item.maxNum }})
              </div>
            </div>
          </template>
        </div>
      </div>
      <div :style="styleData.activityTaskContainer" v-if="isShowAct">
        <div :style="styleData.activityTaskContainerDiv">
          <img :style="styleData.activityTaskImg"
            src="https://img10.360buyimg.com/imgzone/jfs/t1/85413/18/657/2551/5db174bfEaec4d799/c1e8c78d734771d4.png">
          <div :style="styleData.dayTaskText">
            活动开始啦，奖励<span :style="styleData.dayTaskSpan">更丰富！</span></div>
        </div>
        <div v-for="(item, index) in taskList" :key="index">
          <template v-if="!item.activeOrDay">
            <!--关注商品-->
            <div :style="styleData.activityTask" v-if="item.taskType == 5">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/104966/24/637/8280/5db174b0E5e3fae5a/b8dd41119fcc19bf.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderActivity">
                <div :style="styleData.taskText">关注商品</div>
                <div :style="styleData.scoreEng" v-if="item.oneClickFollowPurchase == 1">
                  能量分+{{ item.sendNum }}，活动内上限{{ item.maxNum }}次
                </div>
                <div :style="styleData.scoreEng" v-else>
                  关注全部商品，能量分+{{ item.sendNum }}
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan" v-if="item.completeCount >=0 &&item.maxNum >= 0">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="((item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum) / item.maxNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': item.status == 1,
            }" @click="statusBtn(item, item.taskType)">
                {{ item.status == 1 ? "已完成" : "去关注" }}({{
                item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum
              }}/{{ item.maxNum }})
              </div>
            </div>
            <!--加购商品-->
            <div :style="styleData.activityTask" v-if="item.taskType == 7">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/104966/24/637/8280/5db174b0E5e3fae5a/b8dd41119fcc19bf.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderActivity">
                <div :style="styleData.taskText">加购商品</div>
                <div :style="styleData.scoreEng" v-if="item.oneClickPurchase == 1">
                  能量分+{{ item.sendNum }}，活动内上限{{ item.activeLimit.limitNum }}次
                </div>
                <div :style="styleData.scoreEng" v-else>
                  加购全部商品，能量分+{{ item.sendNum }}
                </div>
              </div>
              <div :style="styleData.progressDiv">
                <div :style="styleData.progressVan" v-if="item.completeCount >=0 &&item.maxNum >= 0">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="((item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum) / item.maxNum)*100" />
                </div>
                <div :style="styleData.progressVan" v-else-if="item.completeCount >=0 &&item.activeLimit.limitNum >= 0">
                  <van-progress pivot-text="" color="#ee0a24"
                    :percentage="((item.completeCount <= item.activeLimit.limitNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.activeLimit.limitNum) / item.activeLimit.limitNum)*100" />
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': item.status == 1,
            }" @click="statusBtn(item, item.taskType)">
                {{ item.status == 1 ? "已完成" : "去加购" }}<span
                  v-if="item.completeCount >=0 &&item.maxNum >= 0">({{ item.completeCount <= item.maxNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.maxNum }}/{{ item.maxNum }})</span>
                <span
                  v-else-if="item.completeCount >=0 &&item.activeLimit.limitNum >= 0">({{ item.completeCount <= item.activeLimit.limitNum * item.finishNum ? Math.floor(item.completeCount / item.finishNum): item.activeLimit.limitNum }}/{{ item.activeLimit.limitNum }})</span>
              </div>
            </div>

            <!--购买任务-->
            <div :style="styleData.activityTask" v-if="item.taskType == 8">
              <img
                src="https://img10.360buyimg.com/imgzone/jfs/t1/88744/38/7569/8047/5dfca7baEf025d273/0074f926d7980fce.png"
                alt="" :style="styleData.taskIcon" />
              <div :style="styleData.borderActivity">
                <div :style="styleData.taskText">
                  <template>购买商品</template>
                </div>
              </div>
              <div :style="styleData.goTaskBtn" :class="{
              'hasComplete-task-btn': item.status == 1,
            }" @click="moreDrawChanceSale(item, item.taskType)">
                {{ item.status == 1 ? "已完成" : "去购买" }}
              </div>
            </div>
          </template>
        </div>
      </div>
    </div>

  </div>
</template>
<script>
import apis1 from "../../../util/apis1.js";
import { goToShopPage, goToActive, acReminder } from "../../../util/tools.js";
import { allShare,toDoShare } from "../../../js/share.js";
import { allShareByurl } from '../../../js/share.js';
import { Progress } from "vant";
import store from "../../../store/store";
import { HdzxtFollowSkuPopNewComService, HdzxtShareTaskService, ShopPopComNewService } from '../../../util/hdzxtcomCreate.js';

let { storeGoodsPoint, shareTask } = apis1;
import {
  AddSkuPopComService,
  FansRulePopComService,
  FansActivityRemindPopComService,
  CollectCouponsPopComService,
} from "../../../util/comCreate.js";
import Vue from "vue";

Vue.use(Progress);
export default {
  props: [
    "isTemplate",
    "datas",
    "keyData",
    "styleData",
    "templateData",
    "isWebClick",
    "modifyContent",
  ],
  data() {
    return {
      taskList: [],
      shareFlag: false,
      taskId: "",
      skuId: "",
      score: 0,
      checkFlag: false,
      btnFlag: false,
      acRemindAddress: "",
      styleDataOld: {},
      showPage: true,
      everyDayTask: [14, 2, 3, 4, 9, 10, 12],
      actTask: [5, 7, 8],
      isShowEvery: false,
      isShowAct: false
    };
  },

  created() {
    //深拷贝重置需要
    this.styleDataOld = JSON.parse(JSON.stringify(this.styleData));
    this.initData();
    this.publicData.$on("fansTaskComponent", (res) => {
      if (res) {
        this.$nextTick(() => {
          this.taskList = res;
          for (var i = 0; i < this.taskList.length; i++) {
            // 判断如果完成数量超过限制数量
            if (this.taskList[i].taskType == 14 || this.taskList[i].taskType == 2 || this.taskList[i].taskType == 3 || this.taskList[i].taskType == 4 || this.taskList[i].taskType == 9 || this.taskList[i].taskType == 10 || this.taskList[i].taskType == 12) {
              this.isShowEvery = true
            }
            if (this.taskList[i].taskType == 5 || this.taskList[i].taskType == 7 || this.taskList[i].taskType == 8) {
              this.isShowAct = true
            }
            if (this.taskList[i].completeCount > this.taskList[i].maxNum) {
              this.taskList[i].completeCount =
                this.taskList[i].maxNum;
            }
          }
        })
      }
    });
    this.publicData.$on('xhyFollowSkuTask', dataSubmit => {
      if (typeof dataSubmit == 'string') {
        this.emitFansPrize();
      }
    });
  },
  methods: {
    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);
      }
    },
    initData() {
      var datasAll = this.templateData;
      if (this.isTemplate == true) {
        if (datasAll) {
          this.showPage = false;
          this.taskList = datasAll.basicTask.taskList;
          this.$nextTick(() => {
            console.log(this.taskList, 'this.taskList')
            for (var i = 0; i < this.taskList.length; i++) {
              if (this.taskList[i].taskType == 14 || this.taskList[i].taskType == 2 || this.taskList[i].taskType == 3 || this.taskList[i].taskType == 4 || this.taskList[i].taskType == 9 || this.taskList[i].taskType == 10 || this.taskList[i].taskType == 12) {
                this.isShowEvery = true
              }
              if (this.taskList[i].taskType == 5 || this.taskList[i].taskType == 7 || this.taskList[i].taskType == 8) {
                this.isShowAct = true
              }
              // 每日的
              // 浏览店铺
              if (this.taskList[i].taskType == 2) {
                this.taskList[i].completeCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.browseShop.dayLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.browseShop.sendNum;
                this.taskList[i].activeOrDay = datasAll.basicTask.taskList[i].rule.browseShop.activeOrDay;
                this.taskList[i].finishNum = datasAll.basicTask.taskList[i].rule.browseShop.dayLimit.limitNum;
                // 浏览商品
              } else if (this.taskList[i].taskType == 3) {
                this.taskList[i].completeCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.browseSku.dayLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.browseSku.sendNum;
                this.taskList[i].activeOrDay = datasAll.basicTask.taskList[i].rule.browseSku.activeOrDay;
                this.taskList[i].finishNum = datasAll.basicTask.taskList[i].rule.browseSku.dayLimit.limitNum;
                // 浏览会场
              } else if (this.taskList[i].taskType == 4) {
                this.taskList[i].completeCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.browseMeetOrLiveRule.dayLimit.limitNum;
                this.taskList[i].finishNum = 1;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.browseMeetOrLiveRule.sendNum;
                this.taskList[i].meetOrLiveType = datasAll.basicTask.taskList[i].rule.browseMeetOrLiveRule.meetOrLiveType;
                this.taskList[i].activeOrDay = datasAll.basicTask.taskList[i].rule.browseMeetOrLiveRule.activeOrDay;
              }
              else if (this.taskList[i].taskType == 9) {
                this.taskList[i].shareCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.shareSkuRule.dayLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.shareSkuRule.sendNum;
                this.taskList[i].finishNum = datasAll.basicTask.taskList[i].rule.shareSkuRule.finishNum;
              }
              else if (this.taskList[i].taskType == 10) {
                this.taskList[i].shareCount = 0;
                this.taskList[i].finishNum = datasAll.basicTask.taskList[i].rule.shareShopRule.sendNum;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.shareShopRule.dayLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.shareShopRule.sendNum;
              }
              else if (this.taskList[i].taskType == 12) {
                this.taskList[i].shareCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.shareActiveRule.dayLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.shareActiveRule.sendNum;
                this.taskList[i].finishNum = datasAll.basicTask.taskList[i].rule.shareActiveRule.sendNum;
              }
              // 每日签到
              else if (this.taskList[i].taskType == 14) {
                this.taskList[i].completeCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.daySignRule.dayLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.daySignRule.sendNum;
              }
              // 活动期间的
              else if (this.taskList[i].taskType == 5) {
                this.taskList[i].completeCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.followSkuRule.activeLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.followSkuRule.sendTypeNum;
                this.taskList[i].finishNum = datasAll.basicTask.taskList[i].rule.followSkuRule.finishNum;
                this.taskList[i].oneClickFollowPurchase = datasAll.basicTask.taskList[i].rule.followSkuRule.oneClickFollowPurchase;
              }
              else if (this.taskList[i].taskType == 7) {
                this.taskList[i].completeCount = 0;
                this.taskList[i].maxNum = datasAll.basicTask.taskList[i].rule.addSkuRule.activeLimit.limitNum;
                this.taskList[i].sendNum = datasAll.basicTask.taskList[i].rule.addSkuRule.sendTypeNum;
                this.taskList[i].finishNum = datasAll.basicTask.taskList[i].rule.addSkuRule.finishNum;
                this.taskList[i].oneClickPurchase = datasAll.basicTask.taskList[i].rule.addSkuRule.oneClickPurchase;
                this.taskList[i].activeLimit = datasAll.basicTask.taskList[i].rule.addSkuRule.activeLimit;
              }
              else if (this.taskList[i].taskType == 8) {
                this.taskList[i].completeCount = 0;
              }
            }
            this.showPage = true;
          })

        } else {
          //没有模板的数据
          this.taskList = [
            {
              activeOrDay: 1,
              completeCount: 0,
              maxNum: 1,
              sendNum: 1,
              shopId: 1000002791,
              status: 0,
              taskId: "1425695738683203586",
              taskPosition: 1,
              taskType: 2,
              validType: 0,
            }
          ]
          this.isShowEvery = true;
        }
      } else {
        this.shareFlag = this.datas.shareFlag;
        this.shareUserId = store.state.shareUserId;
      }
    },
    openStrategyDialog() {
      if (!this.isWebClick) {
        FansRulePopComService.create((prizeRecordDetilClick) => {
          FansRulePopComService.close();
        });
      }
    },
    statusBtn(item, taskType) {
      if (this.isTemplate) {
        this.$toast('活动预览，仅供查看');
        return;
      }
      let actStatus = sessionStorage.getItem("actStatus");
      if (actStatus == 2) {
        this.$toast("活动已结束");
        return;
      }
      if (actStatus == 1) {
        this.$toast("活动未开始");
        return;
      }
      //1 关注店铺（已完成） 2 浏览店铺（完成） 3 浏览商品（完成） 4浏览会场/直播（完成） 5 关注商品（完成） 6 预约商品（完成测试）
      // 7 加购商品（完成） 8 购买商品 9 分享商品（完成） 10 分享店铺（完成） 11 分享会场(TODO) 12 分享活动（完成）
      // 13 会员开卡 14 每日签到（完成） 15 邀请助力(完成) 16 每日组队 17 活动提醒 18 领取优惠券 22 购买指定收货时间商品
      if (item.status == 1) {
        return;
      }
      // 浏览商品
      if (taskType == 3) {
        this.followSku(item, taskType);
      }
      // 关注商品
      if (taskType == 5) {
        this.followSku(item, taskType);
      }
      // 加购商品
      if (taskType == 7) {
        this.followSku(item, taskType);
      }
      //浏览会场/直播
      if (taskType == 4) {
        shareTask(item.taskId, '', data => {
          location.href = item.meetUrl;
          this.emitFansPrize();
        });
      }
      //每日签到
      if (taskType == 14) {
        shareTask(item.taskId, '', data => {
          this.emitFansPrize();
        });
      }
      // 浏览店铺
      if (taskType == 2) {
        shareTask(item.taskId, '', data => {
          this.emitFansPrize();
          item.status = '1';
          let shopId = store.state.shopId;
          storeGoodsPoint(4)
          this.restDrawCount = this.restDrawCount + item.sendNum;
          let dataSubmit = {
            taskItemData: item
          };
          goToShopPage(shopId);
        });

      }
    },
    //去购买商品
    moreDrawChanceSale(item, taskType) {
      if (this.isTemplate) {
        this.$toast('活动预览，仅供查看');
        return;
      }
      let actStatus = sessionStorage.getItem("actStatus");
      if (actStatus == 2) {
        this.$toast("活动已结束");
        return;
      }
      if (actStatus == 1) {
        this.$toast("活动未开始");
        return;
      }
      var data = item;
      sessionStorage.setItem("taskShare", "taskShare");
      ShopPopComNewService.create(data, this.restDrawCount, this.styleData, (submit) => {
        sessionStorage.setItem("taskShare", "");
        this.emitFansPrize();
        ShopPopComNewService.close();
        // this.restDrawCount = this.restDrawCount + submit;
      });
    },
    moreDrawChanceShare(item, taskType, taskShareData) {
      let actStatus = sessionStorage.getItem("actStatus");
      if (actStatus == 2) {
        this.$toast("活动已结束");
        return;
      }
      if (actStatus == 1) {
        this.$toast("活动未开始");
        return;
      }
      sessionStorage.setItem('taskShareData', JSON.stringify(taskShareData));
      if (this.isTemplate) {
        this.$toast('活动预览，仅供查看');
        return;
      }
      if (taskShareData.maxNum <= taskShareData.shareCount / taskShareData.finishNum) {
        return;
      }
      toDoShare(item,this.isTemplate, this, callBackData => {
          this.back()
          console.log(callBackData, 'callBackData');
      });
      // shareTask(item.taskId, '', data => {
      //   this.emitFansPrize();
      //   var url = '';
      //   //   分享指定商品
      //   if (taskShareData.taskType == 9) {
      //     url =
      //       'https://item.m.jd.com/product/' +
      //       taskShareData.skuInfoVO[0].skuId +
      //       '.html?wjfrom=ISV_2180A2AFA5B2452F9061C01C053C4756_WX&wjwxpubid=wxd9fd3549c5fdb283&wjunionid=&wjopenid=';
      //     allShareByurl(url, this.isTemplate, this, callBackData => {
      //       console.log(callBackData, 'callBackData' + url);
      //     });
      //   } else if (taskShareData.taskType == 10) {
      //     //分享指定店铺
      //     url = 'https://shop.m.jd.com/?shopId=' + taskShareData.shopId;
      //     allShareByurl(url, this.isTemplate, this, callBackData => {
      //       console.log(callBackData, 'callBackData' + url);
      //     });
      //   } else {
      //     url = location.href;
      //     allShare(this.isTemplate, this, callBackData => {
      //       console.log(callBackData, 'callBackData');
      //     });
      //   }
      // });
    },
    //商品弹框
    followSku(item, taskType) {
      var data = item;
      sessionStorage.setItem('taskShare', 'taskShare');
      HdzxtFollowSkuPopNewComService.create(data, this.restDrawCount, this.styleData, this.datas, submit => {
        sessionStorage.setItem('taskShare', '');
        this.emitFansPrize();
        HdzxtFollowSkuPopNewComService.close();
      });
    },
    // 更新activity接口
    emitFansPrize() {
      this.publicData.$emit('fansPrizeComponent', true)
    },
  },
};
</script>
<style lang="scss" scoped>
.hasComplete-task-btn {
  color: #ee0a24;
  background: white;
  border: 1px solid #ee0a24;
  border-radius: 28px;
}

.day-task:nth-child(n + 2),
.activity-task:nth-child(n + 2) {
  margin-top: 0.2rem;
}
</style>
