<template>
  <div class="friendsHelp">
  <template v-if="cardList.canAssist == 2 || cardList.canAssist == 4">
    <div v-if="friendsHelpList.length > 0" class="friendgivecardgroup">
      <div class="friendgivecardtitle">已有{{helpCount}}位好友帮你抽卡</div>
      <template v-for="(item,index) in friendsHelpList">
        <div class="friendgiveitem">
          <div class="fgcinfoleft">
            <img
              :src="item.helpUserImg||'https://img10.360buyimg.com/imgzone/jfs/t1/8136/5/13801/2619/5c4ae5efE757a72c1/6639cb75e7f0762d.png'">
            <div class="fgcname">{{ item.helpUserName|twostar }}</div>
          </div>
          <div class="fgcinforight">
            <div class="fgccontext">疯狂助攻，抽到“{{ item.cardName }}”</div>
            <div class="fgcdate">{{ item.createTime|dateTime }}</div>
          </div>
        </div>
      </template>
    </div>
  </template>
  <template v-else>
    <div class="friendAssistGroup" v-if="cardList.canAssist == 0">
      <div class="fAssistuser">
        <div class="userinfoleft">
          <img class="userimg"
               :src="cardList.helpUserImg||'https://img10.360buyimg.com/imgzone/jfs/t1/8136/5/13801/2619/5c4ae5efE757a72c1/6639cb75e7f0762d.png'"/>
          {{cardList.helpUserName}}
        </div>
        <div v-if="cardList.helpCardName == '未抽中'" class="thankssuc">很遗憾未抽中</div>
        <div v-if="cardList.helpCardStatus == 1" class="thankssuc">谢谢您帮我抽中“{{ cardList.helpCardName }}”</div>
        <div v-else class="thanksfalse">很遗憾您没帮我抽中...</div>
      </div>
      <img v-if="cardList.helpCardStatus == 1" :src="cardList.helpCardUrl" class="friendCardimg">
      <div v-else style="width: 100%;margin:0.6rem auto 0;"></div>
      <div class="mainbtn" style="margin: 0.2rem auto;" v-lz-click="'19'" @click="closeFriendsHelp()">查看我的集卡进度</div>
      <div class="friendAssistTip">助人为乐的您也有机会<span class="redText">获得一张卡</span>，赶紧去看看吧</div>
    </div>
  </template>
  </div>
</template>
<script>
import apis1 from "../../../util/apis1.js";
import dateUtil from "../../../util/dateUtil.js";
import store from '../../../store/store.js';
let { cardFriendHelpList , cardInfoList , cardFriendsHelpList } = apis1;

export default {
  components: {
    store,
  },
  props:["isTemplate", "datas", "keyData", "styleData", "templateData"],
  data() {
    return {
      friendsHelpList:[],
      cardList:[],
      shareUserId:'',
      helpCount:0,
    };
  },

  created() {
    this.initData();
  },
  mounted() {
    this.friendsHelpList = [];
    this.cardList = [];
  },
  methods: {
    initData() {
      var datasAll = this.templateData;

      if (this.isTemplate == true) {
        this.$toast("活动预览，仅供查看");
      }else {
        this.shareUserId = store.state.shareUserId;
        var shareUserId = this.shareUserId;
        cardFriendsHelpList(shareUserId,data => {
          this.cardList = data.data;
          this.friendsHelpBack();
        });
      }
    },
    closeFriendsHelp(){
      this.cardList.canAssist = 4;
    },
    friendsHelpBack() {
      cardFriendHelpList(data => {
        this.friendsHelpList = data.data.collectHelpListDTOS;
        this.helpCount = data.data.helpCount;
      });
    }
  },
  filters: {
    //时间转换
    dateTime(val) {
      if (val) {
        return dateUtil.formatTime(val, 'yyyy-MM-dd hh:mm');
      }
      return val;
    },
    twostar: function(value) {
      if (!value) {
        return ""
      }
      return value.substr(0, 1) + "**" + value.substr(-1, 1)
    }
  }
};
</script>
<style lang="scss" scoped>
.friendsHelp{
  width: 100%;
  max-height: 6.1rem;
  background: #fff;
  top: 1rem;
  overflow-y: auto;
  position: absolute;
}
.friendAssistGroup {
  width: 100%;
  background: #fff;
  padding: 0.2rem;
  margin-top: 0.2rem;
}
.friendgivecardgroup {
  width: 100%;
  background: #fff;
  padding: 0.2rem 0.3rem;
  margin-top: 0.2rem;
}
.friendgivecardtitle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #333333;
  font-size: 0.3rem;
  margin-bottom: 0.2rem;
}
.friendgiveitem {
  width: 100%;
  height: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px dashed #cccccc;
}

.friendgiveitem img {
  width: 0.72rem;
  height: 0.72rem;
  border-radius: 50%;
}
.fgcinfoleft {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}
.fgcname {
  color: #333333;
  font-size: 0.3rem;
  margin-left: 0.1rem;
}
.fgcinforight {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-end;
}
.fgccontext {
  font-size: 0.2rem;
  color: #333;
}

.fgcdate {
  font-size: 0.18rem;
  color: #f23c3c;
}
.fAssistuser {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0 0.1rem;
}
.userinfoleft {
  display: flex;
  align-items: center;
  color: #333333;
  font-size: 0.2rem;
}
.userimg {
  border-radius: 50%;
  overflow: hidden;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.1rem;
}
.thankssuc {
  font-size: 0.24rem;
  color: #f23c3c;
  padding: 0.1rem 0.2rem;
  border: 1px solid #ffe5ea;
  border-radius: 0.22rem;
  margin-left: 0.1rem;
}

.thanksfalse {
  font-size: 0.24rem;
  color: #333333;
  padding: 0.1rem 0.2rem;
  border: 1px solid #e6e6e6;
  border-radius: 0.22rem;
  margin-left: 0.1rem;
}
.friendCardimg {
  width: 1.1rem;
  height: 1.2rem;
  margin: 0.25rem auto;
  display: block;
}
.mainbtn {
  width: 2.65rem;
  height: 0.7rem;
  /*background: linear-gradient(to right, #ff2a3e, #ff614c, #ff9e6d); !* 标准的语法 *!*/
  border-radius: 0.1rem;
  background: #fff;
  color: #CA0D22;
  font-size: 0.3rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.friendAssistTip {
  width: 100%;
  text-align: center;
  font-size: 0.2rem;
  color: #999999;
}
.redtext {
  color: #f23c3c;
}
</style>
