<!--packageH/turmaroundTime/turmaroundIndex/turmaroundIndex.wxml-->
<wxs module="m1">
  var Fixed = function(num) {
  var fix = (num / 1000).toFixed(3);
  return fix
  }
  module.exports.Fixed = Fixed;
</wxs>
<wxs module="timestr">
  var secondsFormat = function(sec){
    if(sec >= 60000){
      var minute = Math.floor((sec /1000)/60);
      var second = Math.floor((sec/1000) % 60);
      var msec = (sec/1000) % 60;
      var msec = msec.toString().split('.')[1]
      var msec = '0.' + msec;
      msec = msec*1000;
      msec = msec.toFixed(0);
      return minute+':'+second+'.'+msec
    }else{
      return (sec /1000).toFixed(3)
    }
  }
  module.exports.secondsFormat = secondsFormat;
</wxs>
<view class="turmaround {{topNav == 0 || topNav == 2 ? 'turmaround_poS' : '' }}">
  <view class="head">
    <view class="rank headBox" catchtap="tapTopNav" data-ind="0"
      style="{{topNav == 0?'background-position-y: 1rpx':'background-position-y: 29rpx;line-height: 120rpx;transition: 0.5s;'}}">
      成绩排行</view>
    <view class="myGrade headBox" catchtap="tapTopNav" data-ind="1"
      style="{{topNav == 1?'background-position-y: 1rpx':'background-position-y: 29rpx;line-height: 120rpx;transition: 0.5s'}}">
      我的成绩</view>
    <view class="currentTime headBox" catchtap="tapTopNav" data-ind="2"
      style="{{topNav == 2?'background-position-y: 1rpx':'background-position-y: 29rpx;line-height: 120rpx;transition: 0.5s'}}">
      实时成绩
    </view>
  </view>
  <block wx:if="{{topNav == 0 || topNav == 2}}">
    <!-- 成绩排行 -->
    <view class="navlist" wx:if="{{topNav == 0}}">
      <view class="navlis {{navTaps == index?'selectNav':''}}" wx:for="{{navlis}}" wx:key='index' catchtap="tapNav"
        data-ind='{{index}}'>
        {{item}}
      </view>
    </view>
    <view class="calendar" wx:if="{{topNav == 0 && navTaps != 4}}">
      <view class="calendarTime">
        <van-icon name="arrow-left" class="iconLeft" size="15px" catchtap="yesterday" />
        <view class="timetxt" catchtap="tapCaledar">{{navTaps == 0?nowTime:textTime_class}}</view>
        <icon class="iconfont icon-fontclass-rili" catchtap="tapCaledar"></icon>
        <van-icon name="arrow" class="iconRight" size="15px" catchtap="tomorrow" />
      </view>
    </view>
    <view class="carNav" wx:if="{{topNav == 0}}">
      <view class="carItem" wx:for="{{carlis}}" wx:key="index" catchtap="tapCarNav" data-ind="{{item.id}}">
        <view class="carlis {{carTaps == item.id?'tapCarlis':''}}">{{item.name}}</view>
      </view>
    </view>
    <!-- end -->
    <!-- 实时成绩 -->
    <view class="topCurrentTime" wx:if="{{topNav == 2 && istemp}}">
      <view class="timeBox">
        <view class="timeBoxOne">{{GroupList.started_at}}</view>
        <view class="timeBoxTwo">
          <view class="timeBoxTwo_left">
            <view class="timeBoxTwo_left_ds">
              <view style="margin-left: 26rpx;">race time </view>
              <view style="flex: 1;text-align: center;">{{ GroupList.state == '6'?'0':is_running_at}}</view>
            </view>
            <view class="timeBoxTwo_left_ds">
              <view style="margin-left: 26rpx;">local time </view>
              <view style="flex: 1;text-align: center;">{{local_time}}</view>
            </view>
          </view>
          <view class="timeBoxTwo_right" wx:if="{{GroupList.type == '2'}}">
            <view class="timeBoxTwo_left_ds">
              <view style="margin-left: 26rpx;">time to go</view>
              <view style="flex: 1;text-align: center;" wx:if="{{GroupList.state != '5' && GroupList.state != '6'}}">{{start_at_time}}</view>
              <view wx:else style="flex: 1;text-align: center;" >0</view>
            </view>
            <view class="timeBoxTwo_left_ds">
            </view>
          </view>
        </view>
      </view>
    </view>
    <view class="carNav" wx:if="{{topNav == 2 && istemp}}">
      <view class="carItem" wx:for="{{group}}" wx:key="index" catchtap="tapGroupNav" data-ind="{{item.id}}">
        <view class="carlis {{GroupTaps == item.id?'tapCarlis':''}}">{{(index + 1)+'组'}}</view>
      </view>
    </view>
    <!-- end -->
    <!-- 暂无成绩 -->
    <view class="isNone" wx:if="{{!istemp}}">
      <view class="noneImg">
        <image src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/turmaroundTimeZW.png"></image>
      </view>
    </view>
    <!-- end -->
    <!-- 排行榜列表 -->
    <block wx:if="{{topNav == 2 || topNav == 0}}">
      <!--  -->
      <view class="prizeAwarding" wx:if="{{istemp}}">
        <view class="headInfo">
          <view class="memberHead" style="margin-top:23rpx;">
            <view class="headTwo" wx:if="{{first_info[1]}}" catchtap="goMy" data-item="{{first_info[1]}}">
              <image class="onImg" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/turmaroundTimeTwo.png"></image>
              <image class="inImg"
                src="{{first_info[1].member.avatar_image?first_info[1].member.avatar_image:first_info[1].avatar_image}}">
              </image>
            </view>
            <view class="memberName">
              {{first_info[1].member.nickname?first_info[1].member.nickname:first_info[1].nickname}}</view>
            <view class="second">{{first_info[1].fine?timestr.secondsFormat(first_info[1].fine):''}}</view>
          </view>
          <view class="memberHead" style="margin-left:65rpx;margin-right:65rpx;">
            <view class="headTwo" wx:if="{{first_info[0]}}" catchtap="goMy" data-item="{{first_info[0]}}">
              <image class="onImg" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/turmaroundTimeOne.png"></image>
              <image class="inImg"
                src="{{first_info[0].member.avatar_image?first_info[0].member.avatar_image:first_info[0].avatar_image}}">
              </image>
            </view>
            <view class="memberName">
              {{first_info[0].member.nickname?first_info[0].member.nickname:first_info[0].nickname}}</view>
            <view class="second">{{first_info[0].fine?timestr.secondsFormat(first_info[0].fine):''}}</view>
          </view>
          <view class="memberHead" style="margin-top:42rpx;">
            <view class="headTwo" wx:if="{{first_info[2]}}" catchtap="goMy" data-item="{{first_info[2]}}">
              <image class="onImg" src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/turmaroundTimeThr.png"></image>
              <image class="inImg"
                src="{{first_info[2].member.avatar_image?first_info[2].member.avatar_image:first_info[2].avatar_image}}">
              </image>
            </view>
            <view class="memberName">
              {{first_info[2].member.nickname?first_info[2].member.nickname:first_info[2].nickname}}</view>
            <view class="second">{{first_info[2].fine?timestr.secondsFormat(first_info[2].fine):''}}</view>
          </view>
        </view>
      </view>
      <!-- 列表题头 -->
      <view class="gradeList" wx:if="{{istemp}}">
        <view wx:for="{{geade}}" wx:key='index' class="gradeLis">
          {{item}}
        </view>
      </view>
      <block wx:for="{{info}}" wx:key="index">
        <!-- 实时成绩排名列表 -->
        <view class="memberLis" wx:if="{{topNav == 2}}" catchtap="goMy" data-item="{{item}}">
          <view class="no">{{index + 4}}</view>
          <view class="imgbox">
            <view class="img">
              <image src="{{item.member.avatar_image}}"></image>
            </view>
            <view class="userName">{{item.member.nickname}}</view>
          </view>
          <view class="carNumber">{{item.kart.serial}}</view>
          <view class="circle">{{item.circle}}</view>
          <view class="totalTime">{{item.hour?timestr.secondsFormat(item.hour):''}}</view>
          <view class="fastest">
            <view class="fastTime">{{item.fine?timestr.secondsFormat(item.fine):''}}</view>
            <i class="iconfont icon-advertise-next"></i>
          </view>
          <view class="line"></view>

        </view>
        <!-- 成绩排行列表 -->
        <view class="memberLis" wx:if="{{topNav == '0'}}" catchtap="goMy" data-item="{{item}}">
          <view class="no">{{index + 4}}</view>
          <view class="imgbox">
            <view class="img">
              <image src="{{item.avatar_image}}"></image>
            </view>
            <view class="userName">{{item.nickname}}</view>
          </view>
          <view class="carNumber">{{item.kart_serial}}</view>
          <view class="circle">{{item.circle}}</view>
          <view class="totalTime">{{item.hour?timestr.secondsFormat(item.hour):''}}</view>
          <view class="fastest">
            <view class="fastTime">{{item.fine?timestr.secondsFormat(item.fine):''}}</view>
            <i class="iconfont icon-advertise-next"></i>
          </view>
          <view class="line"></view>

        </view>
      </block>

    </block>
    <!-- end -->
    <!-- 悬浮我的排名 -->
    <view class="myPos" wx:if="{{topNav == '0'}}" catchtap="goMy" data-item="{{my_info}}">
      <view class="myposLeft">
        <view style="font-size: 30rpx;">{{is_ranking == '1'?(my_info_ind + 1):'未上榜'}}</view>
        <view class="myPosImg">
          <image src="{{my_info.avatar_image?my_info.avatar_image:my_info.member.avatar_image}}"></image>
          <text style="font-size: 24rpx;">{{my_info.nickname?my_info.nickname:my_info.member.nickname}}</text>
        </view>
      </view>
      <view class="myposRight" style="font-size: 28rpx;color: #f77860;" wx:if="{{is_ranking == '1'}}">
        {{timestr.secondsFormat(my_info.fine)}}
        <icon class="iconfont icon-member_right"></icon>
      </view>
    </view>
  </block>
  <block wx:else>
    <view class="myGradeBox">
      <view class="gradeBoxBj">
        <view class="userMsg">
          <view class="userTop">
            <view class="userimg">
              <image class="bjimg" src="{{memberInfo.avatar_image}}"></image>
              <view class="userimg_pos">
                <image src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/turmaroundTimeNan.png" wx:if="{{memberInfo.gender == '1'}}"></image>
                <image src="https://mini-app-img-1251768088.cos.ap-guangzhou.myqcloud.com/turmaroundTimeNv.png" wx:if="{{memberInfo.gender == '2'}}"></image>
              </view>
            </view>
            <view class="nickName">{{memberInfo.nickname}}</view>
            <view class="shareBtn">
              分享给好友
              <button open-type="share" class="openBtn"></button>
            </view>
          </view>
          <view class="userBottom">
            <view class="userBottom_left">
              <i class="iconfont icon-zb_all_like"></i>
              <text
                style="font-size: 40rpx;color: #ffad37;">{{memberInfo.kart_likes_count?memberInfo.kart_likes_count:'0'}}</text>
              <text style="font-size: 28rpx;color: #666666;margin-left:10rpx;">已获赞</text>
            </view>
            <view class="userBottom_Right">
              <text
                style="font-size: 40rpx;color: #ffad37;">￥{{memberInfo.kart_accepts_count?memberInfo.kart_accepts_count:'0'}}</text>
              <view style="font-size: 28rpx;color: #666666;margin-left:10rpx;">
                收获打赏
                <!-- <view>共23人打赏</view> -->
              </view>
            </view>
          </view>
        </view>
        <view class="history">
          <view class="historyHead" catchtap="showHistory">
            <view style="font-size: 32rpx;">历史成绩</view>
            <van-icon name="arrow" wx:if="{{!showIn}}" />
            <van-icon name="arrow-down" wx:if="{{showIn}}" />
          </view>
          <view class="historyShow" wx:for="{{history}}" wx:key="index" wx:if="{{showIn}}">
            <view style="font-size: 30rpx;">{{item.date}}</view>
            <view class="historyShow_two">
              <text style="font-size: 30rpx;color: #ffad37;">{{timestr.secondsFormat(item.fine)}}</text>
              <text style="font-size: 30rpx;">{{item.name}}</text>
            </view>
            <view class="historyShow_two">
              <text style="font-size: 30rpx;">{{m2.filtrate(item.type)}}榜</text>
              <text style="font-size: 30rpx;">第{{item.ranking}}名</text>
            </view>
          </view>
        </view>
      </view>
    </view>
  </block>

</view>

<!-- 日历  日和周 -->
<van-calendar bind:select="tapCalendar" show="{{ show }}" type="{{navTaps == 1?'range':'single'}}" bind:close="onClose" bind:confirm="onConfirm" default-date="{{navTaps==1?calendarArr:nowTime}}" min-date="{{ minDate }}" />
<c-time monthYearShow="{{monthYearShow}}" selectMonth="{{selectMonth}}" navTaps="{{navTaps}}" monthIndex="{{monthIndex}}" bindconfirmBtn="getTimeC" arr="{{yearArr}}"></c-time>
<wxs module="m2">
  var filtrate = function(num) {
    if(num == '1'){
      return '日'
    }else if(num == '2'){
      return '周'
    }else if(num == '3'){
      return '月'
    }else if(num == '4'){
      return '年'
    }else if(num == '5'){
      return '总'
    }
    
  }
  module.exports.filtrate = filtrate;
</wxs>