<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>首页-特训营-爽客邦</title>
    <meta name="keywords" content="首页-特训营-爽客邦">
    <meta name="description" content="首页-特训营-爽客邦">
    <meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,shrink-to-fit=no,user-scalable=no" name="viewport" viewport="cover">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <meta content="telephone=no" name="format-detection">
    <meta content="email=no" name="format-detection">
    <meta name="apple-mobile-web-app-title" content="首页-特训营-爽客邦">
    <meta http-equiv="Cache-Control" content="no-siteapp">
    <link rel="stylesheet" href="./static/css/main.css">
  </head>
  <body class="train_record pb0">
    <div id="app">
      <van-nav-bar class="user_rank_explan_title" title="参团记录" @click-left="goback" v-if="toptitleisshow" @click-right="rules" left-arrow v-cloak>
        <template #left> <img src="./static/images/left.png" alt=""></template>
        <template #right>
          <van-icon name="question-o" size="20" color="#666666"></van-icon>
        </template>
      </van-nav-bar>
      <van-pull-refresh v-model="refreshing" @refresh="onRefresh" v-cloak> 
        <van-tabs class="recordtabs" v-model="active" @click="checktab">
          <van-tab title="组队记录">
            <van-list v-model="loading" :finished="finished0" @load="onLoad" :immediate-check="false" :class="teamInfo.length === 0 ? 'isnodata':''">
              <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="isnodata"></van-empty>
              <div class="camp_enrollinfopanel rel recordtop" v-for="item in teamInfo" :key="item" :class="failfn(item.Status)? 'greybg':''">
                <div class="titlepanel df">
                  <div class="text c333 f18 b" :class="failfn(item.Status)? 'fail':''">{{item.TeamName}} <img class="iconnotes" src="./static/images/icon-notes.png" alt="" v-if="item.Status === 1 || item.Status === 4">
                    <div class="slogan f12 c999 n">{{item.WatchWord}}</div>
                  </div><span class="sign recordend tr" v-if="item.Status !== 0">组队待审核
                    <div class="begin f12 recordendcolor">离开始还剩：{{item.OverDays}}天</div></span><span class="sign recordend tr" v-if="item.Status === 1">组队审核通过(报名中)
                    <div class="begin f12 recordendcolor">离开始还剩：{{item.OverDays}}天</div></span><span class="end recordend tr doing" v-if="item.Status === 2">活动进行中
                    <div style="opacity: 0;">这个div是为了布局</div></span><span class="end recordend tr" v-if="item.Status === 3">活动已结束
                    <div style="opacity: 0;">这个div是为了布局</div></span><span class="end recordend tr greybg" v-if="item.Status === 4">组队审核失败
                    <div style="opacity: 0;">这个div是为了布局</div></span><span class="end recordend tr greybg" v-if="item.Status === 5">组队失败（人数未达标）
                    <div style="opacity: 0;">这个div是为了布局</div></span>
                </div>
                <div class="mainpanel f12 c666 rel">
                  <div class="info">队长：{{item.TeamLeader}}</div>
                  <div class="info">人数：{{item.MemberCount}}人 </div>
                  <div class="info">时间：{{item.EffectStartDate}}~{{item.EffectEndDate}}</div>
                  <div class="info">地点：{{item.Areas}}
                    <button class="f14 cfff" v-if="item.Status !== 0" @click="tipexamine(item.Id)">提醒审核</button>
                  </div>
                </div>
              </div>
              <div class="bottomline tc c999 f12 pr16 pl16 rel" v-if="tipsisshow0 &amp;&amp; !isnodata"> 
                <div class="line abs"></div><span>我是有底线的</span>
              </div>
            </van-list>
          </van-tab>
          <van-tab title="报名记录">
            <van-list v-model="loading" :finished="finished1" @load="onLoad" :immediate-check="false" :class="signList.length === 0 ? 'isnodata':''">
              <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="isnodata2"></van-empty>
              <div class="camp_enrollinfopanel rel recordtop" v-for="item in signList" :key="item.Id" :class="failfn(item.Status)? 'greybg':''">
                <div class="titlepanel df">
                  <div class="text c333 f18 b" :class="failfn(item.Status)? 'fail':''">{{item.TeamName}} <img class="iconnotes" src="./static/images/icon-notes.png" alt="" v-if="item.Status === 1 || item.Status === 2 || item.Status === 4">
                    <div class="slogan f12 c999 n">{{item.WatchWord}}</div>
                  </div><span class="sign recordend tr" v-if="item.Status === 0">报名待审核
                    <div class="begin f12 recordendcolor">离开始还剩：{{item.OverDays}}</div></span><span class="sign recordend tr" v-if="item.Status === 1">报名审核通过
                    <div class="begin f12 recordendcolor">离开始还剩：{{item.OverDays}}</div></span><span class="end recordend tr doing" v-if="item.Status === 2">活动进行中
                    <div style="opacity: 0;">这个div是为了布局</div></span><span class="end recordend tr" v-if="item.Status === 3">活动已结束
                    <div style="opacity: 0;">这个div是为了布局</div></span><span class="end tr greybg" v-if="item.Status === 4">报名失败
                    <div style="opacity: 0;">这个div是为了布局</div></span><span class="end tr greybg" v-if="item.Status === 5">报名已取消
                    <div style="opacity: 0;">这个div是为了布局</div></span>
                </div>
                <div class="mainpanel f12 c666 rel">
                  <div class="info">队长：{{item.TeamLeader}}</div>
                  <div class="info">人数：{{item.MemberCount}}人</div>
                  <div class="info">时间：{{item.EffectStartDate}}~{{item.EffectEndDate}}</div>
                  <div class="info">地点：{{item.Areas}}
                    <button class="f14 c999 cancel signbtn" v-if="item.Status !== 0" @click="cancelsignup(item.Id)">取消报名</button><br>
                    <button class="f14 cfff signbtn" v-if="item.Status !== 0" @click="tipsignup(item.Id)">提醒审核</button>
                  </div>
                </div>
              </div>
              <div class="bottomline tc c999 f12 pr16 pl16 rel" v-if="tipsisshow1 &amp;&amp; !isnodata2">
                <div class="line abs"></div><span>我是有底线的</span>
              </div>
            </van-list>
          </van-tab>
        </van-tabs>
      </van-pull-refresh>
    </div>
    <script src="./static/js/klm-vv.min.js"></script>
    <script src="./static/js/klm-axios-config.js"></script>
    <script>
      // 在 #app 标签下渲染一个按钮组件
      let app = new Vue({
        el: '#app',
        data() {
          return {
            isnodata:false,
            isnodata2:false,
            toptitleisshow:false,
            //- 滚动加载
            loading: false,
            finished0: false,
            finished1: false,
            //- 刷新
            refreshing: false,
            //- 是否显示完成
            tipsisshow0:false,
            tipsisshow1:false,
            active: 0,
            teamInfo:[
            ],
            signList:[
            ],
            pageinfo0:{
              PageSize:10,
              PageNum:1
            },
            pageinfo1:{
              PageSize:10,
              PageNum:1
            },
          }
        },
        created() {
          this.toptitleisshow = toptitleisshow;
          this.getcreatedteamrecord();
        },
        methods: {
          goback(){
            PublicLib.GoBack({Level:1});
          },
          failfn(status){
            if(status=== 4 || status === 5) {
              return true
            }
            return false
          },
          onLoad() {
            if(this.active === 0) {
                if (this.refreshing) {
                  this.teamInfo = [];
                  this.refreshing = false;
                  this.pageinfo0.PageNum = 0;
                }
                this.pageinfo0.PageNum++;
                this.getcreatedteamrecord();
            } else {
                if (this.refreshing) {
                  this.signList = [];
                  this.refreshing = false;
                  this.pageinfo1.PageNum = 0;
                }
                this.pageinfo1.PageNum++;
                this.getsignuprecord();
            }
          },
          onRefresh() {
            // 清空列表数据
            this.finished0 = false;
            this.finished1 = false;
            //- 隐藏底线完
            this.tipsisshow0=false,
            this.tipsisshow1=false,
      
            // 重新加载数据
            // 将 loading 设置为 true，表示处于加载状态
            this.loading = true;
            this.onLoad();
          },
          checktab(index){
            if(index === 1) {
              this.signList = [];
              this.getsignuprecord();
            }else{
              this.teamInfo = [];
              this.getcreatedteamrecord();
            }
          },
          async getsignuprecord(){
            PublicLib.ShowLoading({Message:''});
            const UserId = PublicLib.getCookieInfo('userId');
            const res = await getRequest('/api/v1/teamofferapply/signuplist',JSON.stringify({UserId,...this.pageinfo1}));
            if(res.status !== '1') return tips('获取报名记录失败，请重试！');
            PublicLib.HideLoading();
            if(res.data.length < this.pageinfo0.PageSize) {
              this.finished1 = true;
              this.tipsisshow1 = true
            };
            this.signList.push(...res.data);
            console.log(this.signList)
            this.loading = false;
            if(this.signList.length === 0) {this.isnodata2 = true}else{this.isnodata2 = false};
          },
          async getcreatedteamrecord(){
            PublicLib.ShowLoading({Message:''});
            const UserId = PublicLib.getCookieInfo('userId');
            const res = await getRequest('/api/v1/teamapply/mylist',JSON.stringify({UserId,...this.pageinfo0}));
            if(res.status !== '1') return tips('获取组队记录失败，请重试！');
            PublicLib.HideLoading();
            if(res.data.length < this.pageinfo1.PageSize) {
              this.finished0 = true;
              this.tipsisshow0 = true
            };
            this.teamInfo.push(...res.data);
            this.loading = false;
            if(this.teamInfo.length === 0) {this.isnodata = true}else{this.isnodata = false};
          },
          //- 提醒审核
          tipexamine:undebounce(async function(Id){
            const res = await postRequest('/api/v1/teamapply/ring',JSON.stringify({Id}));
            if(res.status !== '1') return tips('提醒审核失败，请重试！');
            tips('提醒审核成功！');
          }),
          //- async tipexamine(Id){
          //-   const res = await postRequest('/api/v1/teamapply/ring',JSON.stringify({Id}));
          //-   if(res.status !== '1') return tips('提醒审核失败，请重试！');
          //-   tips('提醒审核成功！');
          //- },
          //- 取消报名
          async cancelsignup(Id){
            const res = await postRequest('/api/v1/teamofferapply/cancelsignup',JSON.stringify({Id}));
            if(res.status !== '1') return tips('取消报名失败，请重试！');
            tips('报名取消成功！');
            this.getsignuprecord();
          },
          //- 取消报名
          tipsignup:undebounce(async function(Id){
            const res = await postRequest('/api/v1/teamofferapply/ring',JSON.stringify({Id}));
            if(res.status !== '1') return tips('提醒审核失败，请重试！');
            tips('提醒审核成功！');
          }),
          //- 营训规则
          rules(){
            PublicLib.Goto({Url:'trainingCamp-rules'});
          }
        },
      });
    </script>
  </body>
</html>