<!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" style="padding:0;">
    <div id="app">
      <van-nav-bar class="camp_title f16" title="特训营排行" @click-left="goback" v-if="toptitleisshow" left-arrow v-cloak>
        <template #left> 
          <van-icon name="arrow-left" color="#fff" size="20"></van-icon>
        </template>
      </van-nav-bar>
      <van-pull-refresh v-model="refreshing" @refresh="onRefresh" v-cloak :class="teamList.length === 0 ? 'isnodata':''"> 
        <van-tabs class="ranking recordtabs" v-model="active" v-cloak @click="checktabs">
          <van-tab title="团队排行">
            <van-list v-model="loading" finished-text="没有更多数据了" :finished="finished0" @load="onLoad" :immediate-check="false">
              <div class="title df pr16 pl16 c999 f12">
                <div class="ranking">排名</div>
                <div class="count">参与总数</div>
              </div>
              <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="isnodata"></van-empty>
              <div class="rankingpanel" v-if="teamList.length !== 0">
                <div class="panelitem df cm" v-for="(item,index) in teamList" :key="index">
                  <div class="rank rel">
                    <div class="num abs f14 c666" v-if="index &gt; 2">{{index + 1}}</div><img src="./static/images/user-rank-1.png" alt="" v-if="index === 0"><img src="./static/images/user-rank-2.png" alt="" v-if="index === 1"><img src="./static/images/user-rank-3.png" alt="" v-if="index === 2">
                  </div>
                  <div class="teaminfo flex1">
                    <div class="teamname c333 f14">{{item.TeamName}}</div>
                    <div class="oinfo c999"><span>{{item.TeamStartDate}} - {{item.TeamEndDate}}</span><span>{{item.MemberCount}}人</span><span></span></div>
                  </div>
                  <div class="usercount f16 b">{{item.TeamActMerNum}}户</div>
                </div>
              </div>
            </van-list>
          </van-tab>
          <van-tab title="个人排行">
            <van-list v-model="loading" finished-text="没有更多数据了" :finished="finished1" @load="onLoad" :immediate-check="false">
              <div class="title df pr16 pl16 c999 f12">
                <div class="ranking">排名</div>
                <div class="count">参与总数</div>
              </div>
              <van-empty class="custom-image" image="./static/images/empty-img.png" description="暂无数据" v-if="isnodata2"></van-empty>
              <div class="rankingpanel" v-if="userList.length !== 0">
                <div class="panelitem df cm" v-for="(item,index) in userList" :key="index">
                  <div class="rank rel">
                    <div class="num abs f14 c666" v-if="index &gt; 2">{{index + 1}}</div><img src="./static/images/user-rank-1.png" alt="" v-if="index === 0"><img src="./static/images/user-rank-2.png" alt="" v-if="index === 1"><img src="./static/images/user-rank-3.png" alt="" v-if="index === 2">
                  </div>
                  <div class="teaminfo flex1 df">
                    <div class="userimg"><img :src="item.MakerHeadPhoto" alt=""></div>
                    <div class="userinfo">
                      <div class="teamname c333 f14"> <span class="c333 f12 mr8">{{item.MakerName}}</span><span class="c999 f12">{{item.TeamName}}</span></div>
                      <div class="oinfo c999"><span>{{item.TeamStartDate}} - {{item.TeamEndDate}}</span></div>
                    </div>
                  </div>
                  <div class="usercount f16 b">{{item.TeamActMerNum}}户</div>
                </div>
              </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:true,
            //- 滚动加载
            loading: false,
            finished0: false,
            finished1: false,
            pageinfo0:{
              PageSize:10,
              PageNum:1,
            },
            pageinfo1:{
              PageSize:10,
              PageNum:1,
            },
            //- 刷新
            refreshing: false,
            active:0,
            teamList:[
            ],
            userList:[
            ],
          }
        },
        created() {
          this.getteamrankinglist();
        },
        methods: {
          checktabs(active){
            this.userList = [];
            this.teamList = [];
            if(active === 1) {
              this.getpersonrankinglist();
           }else {
              this.getteamrankinglist();
           }
          },
          goback(){
            PublicLib.GoBack({Level:1});
          },
          onLoad() {
            if(this.active === 0) {
                if (this.refreshing) {
                  this.teamList = [];
                  this.refreshing = false;
                  this.pageinfo0.PageNum = 0;
                }
                this.pageinfo0.PageNum++;
                this.getteamrankinglist();
            } else {
                if (this.refreshing) {
                  this.userList = [];
                  this.refreshing = false;
                  this.pageinfo0.PageNum = 0;
                }
                this.pageinfo0.PageNum++;
                this.getpersonrankinglist();
            }
          },
          onRefresh() {
            // 清空列表数据
            this.finished0 = false;
            this.finished1 = false;
            // 重新加载数据
            // 将 loading 设置为 true，表示处于加载状态
            this.loading = true;
            this.onLoad();
          },
          //- 团队排行榜
          async getteamrankinglist(){
            PublicLib.ShowLoading({Message:''});
            const res = await getRequest('/api/v1/teampersondaytop/teamlist',JSON.stringify({...this.pageinfo0}));
            if(res.status !== '1') return tips('获取团队排行失败，请重试！');
            PublicLib.HideLoading();
            if(res.data.length < this.pageinfo0.PageSize) {
              this.finished0 = true;
            };
            this.teamList.push(...res.data);
            this.teamList = [
              {
                TeamStartDate: "2021-12-21", //队伍开始时间
                TeamEndDate: "2022-01-02", //队伍结束时间
                TeamActMerNum: "65", //队伍直营激活商户数
                MemberCount: "15", //队伍人数
                TeamName: "实干兴邦队", //队伍名称
              },
              {
                TeamStartDate: "2021-12-14", //队伍开始时间
                TeamEndDate: "2021-12-21", //队伍结束时间
                TeamActMerNum: "48", //队伍直营激活商户数
                MemberCount: "12", //队伍人数
                TeamName: "飞鹰战队", //队伍名称
              },
              {
                TeamStartDate: "2021-12-08", //队伍开始时间
                TeamEndDate: "2021-12-17", //队伍结束时间
                TeamActMerNum: "39", //队伍直营激活商户数
                MemberCount: "8", //队伍人数
                TeamName: "狼牙特战队", //队伍名称
              },
              {
                TeamStartDate: "2021-12-17", //队伍开始时间
                TeamEndDate: "2021-12-28", //队伍结束时间
                TeamActMerNum: "28", //队伍直营激活商户数
                MemberCount: "7", //队伍人数
                TeamName: "百亿军团队", //队伍名称
              },
            ];
            if(this.teamList.length === 0) {this.isnodata = true}else{this.isnodata = false};
            this.loading = false;
          },
           //- 个人排行榜
          async getpersonrankinglist(){
            PublicLib.ShowLoading({Message:''});
            const res = await getRequest('/api/v1/teampersondaytop/list',JSON.stringify({...this.pageinfo1}));
            if(res.status !== '1') return tips('获取个人排行失败，请重试！');
            PublicLib.HideLoading();
            if(res.data.length < this.pageinfo1.PageSize) {
              this.finished1 = true;
            };
            this.userList.push(...res.data);
            this.loading = false;
            this.userList = [
              {
                TeamStartDate: "2021-12-21", //队伍开始时间
                TeamEndDate: "2022-01-02", //队伍结束时间
                TeamActMerNum: "12", //队伍直营激活商户数
                TeamName: "惠*航", //队伍名称
                MakerHeadPhoto:'./static/images/user-img-color@3x.png'
              },
              {
                TeamStartDate: "2021-12-14", //队伍开始时间
                TeamEndDate: "2021-12-21", //队伍结束时间
                TeamActMerNum: "10", //队伍直营激活商户数
                TeamName: "张*源", //队伍名称
                MakerHeadPhoto:'./static/images/user-img-color@3x.png'
              },
              {
                TeamStartDate: "2021-12-08", //队伍开始时间
                TeamEndDate: "2021-12-17", //队伍结束时间
                TeamActMerNum: "9", //队伍直营激活商户数
                TeamName: "徐*", //队伍名称
                MakerHeadPhoto:'./static/images/user-img-color@3x.png'
              },
              {
                TeamStartDate: "2021-12-17", //队伍开始时间
                TeamEndDate: "2021-12-28", //队伍结束时间
                TeamActMerNum: "7", //队伍直营激活商户数
                TeamName: "李*雷", //队伍名称
                MakerHeadPhoto:'./static/images/user-img-color@3x.png'
              },
              {
                TeamStartDate: "2021-12-17", //队伍开始时间
                TeamEndDate: "2021-12-28", //队伍结束时间
                TeamActMerNum: "7", //队伍直营激活商户数
                TeamName: "谢*", //队伍名称
                MakerHeadPhoto:'./static/images/user-img-color@3x.png'
              },
            ];
            if(this.userList.length === 0) {this.isnodata2 = true}else{this.isnodata2 = false};
          }
        },
      });
    </script>
  </body>
</html>