<template>
  <div style="color: rgb(114, 52, 147);
    width: 1.5rem;
    margin-left: 5.3rem;
    position: absolute;
    top: 2.65rem;">
    <div style="text-align:right;font-size:0.25rem;    width: 1.5rem;
    height: 0.5rem;
    display: -webkit-box;
    overflow: hidden;
    text-overflow: ellipsis;
    position: relative;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;">
      <span style="font-size:0.35rem;font-weight: 700;">{{ totalPrizeNum }}</span><span
      v-if="prizeType==4">积分</span><span v-if="prizeType==1">京豆</span></div>
    <div style="text-align:right;font-size: 0.2rem;">
      <span
        style="background-color: #733494;color: #ffc77b;width: 0.33rem;height: 0.33rem;border-radius: 50%;display: inline-block;text-align: center;line-height: 0.33rem;">5</span>人平分
    </div>
  </div>
</template>

<script>
import {goToSkuPage } from '../../../util/tools.js';
import {ActivityOverComService} from '../../../util/comCreate.js';
import apis1 from '../../../util/apis1.js';
import store from '../../../store/store.js'
export default {
     components: {
      store,
  },
  props:['datas','keyData','styleData','isTemplate', "templateData"],
  data() {
    return {
      exposureList:[],
      totalPrizeNum: 0,
      prizeType: 0,
      shareUserId:'',//用户id取得
      totalPrizeNum2:0,

    };
  },
  mounted() {
    this.exposureList = []
  },
created() {
  this.initData();
},
  methods: {
    initData() {
      var datasAll = this.templateData;
      if (this.isTemplate == true) {
        this.$toast("活动预览，仅供查看");
        if (datasAll) {
          this.totalPrizeNum = datasAll.draw.prizeList[0].membersPrize*5;
          this.prizeType = datasAll.draw.prizeList[0].prizeType;

        } else {
          this.totalPrizeNum = 20;
          this.prizeType = '1';
        }
      }else {
        this.getGoodsList();
      }
    },
    getGoodsList(){
       this.shareUserId = store.state.shareUserId;
      let goodsList  = apis1[this.datas.goodsList];
      var shareUserId = this.shareUserId;
      goodsList(shareUserId,data => {

        this.exposureList = data.data;
        this.totalPrizeNum = data.data.memberPrize * 5;
        this.totalPrizeNum2 = data.data.prizeList[0].totalPrizeNum;
        this.prizeType = data.data.prizeType;
        if(this.totalPrizeNum2 < this.totalPrizeNum+data.data.captainPrize){
            ActivityOverComService.create(
            (submit) => {
              ActivityOverComService.close();
            }
          );
        }
      });
    },
    goToBuy(sku) {
      goToSkuPage(sku);
    }
  }
};
</script>
