<wxs src="../../../../utils//totalprices.wxs" module="total" />
<nav type="back" background-color="#4F9AF7" frontColor="#000000" title="参与活动" />
<view class="box">
  <view class="banner">
    <swiper class="swiper" indicator-dots="true" autoplay="true" circular="ture">
      <swiper-item wx:for="{{activity.cover}}" wx:key="index">
        <image data-img="{{item}}" bindtap="imagePreview" src="{{item}}" style="width: 100vw;height: 100%;" mode="aspectFill" />
      </swiper-item>
    </swiper>
    <view class="linear"></view>
  </view>
  <view class="detail">
    <view class="name">
      <view class="title" bindtap="getThumbs">
        {{activity.title}}
      </view>

      <view class="desc">
        {{activity.desc}}
      </view>
    </view>
    <block wx:if="{{userInfo}}">
      <van-tabs active="{{ active }}" bind:change="changeTab" color="#4F9AF7">
        <van-tab title="活动详情"></van-tab>
        <van-tab title="排行榜"></van-tab>
      </van-tabs>

      <block wx:if="{{active==0}}">
        <view class="date">
          <view></view>
          <view class="tip" style="color: {{(tips.isCanSign||tips.isCanRevise)?'#7F56B2':'gray'}};">
            {{tips.title}}
          </view>
        </view>
        <block wx:for="{{optionKeyList}}" wx:key="index">
          <view class="item">
            <view class="title">
              {{item}}
            </view>
            <view class="common">{{activity.limitOptions[item]}}</view>
          </view>
        </block>

        <view class="item" wx:if="{{booking}}">
          <view class="title">
            预约时间
          </view>
          <view>
            <view class="common" style="font-weight: bold;color: red;">{{registerList[registerList.length-1].bookObj.from}} - {{registerList[registerList.length-1].bookObj.to}}</view>
          </view>

        </view>
        <view class="item" wx:if="{{booking}}">
          <view class="title">
            预约服务位置
          </view>
          <view class="common" style="font-weight: bold;color: red;">{{registerList[registerList.length-1].shop.storeName||'未知'}}</view>
        </view>
        <block wx:if="{{activity.signFromTo.from&&activity.signFromTo.to}}">
          <view class="item">
            <view class="title">
              报名时间
            </view>
            <view class="common">{{activity.signFromTo.from}} - {{activity.signFromTo.to}}</view>
          </view>
        </block>
        <block wx:if="{{activity.merber>0}}">
          <view class="item">
            <view class="title">
              报名人数
            </view>
            <view class="common">{{count}}人 /{{activity.merber}}</view>
          </view>
        </block>


        <block wx:if="{{activity.start&&activity.end}}">
          <view class="item">
            <view class="title">
              活动时间
            </view>
            <view class="common">{{activity.start}} - {{activity.end}}</view>
          </view>
        </block>

        <block wx:if="{{activity.isEnabled}}">
          <view class="item">
            <view class="title">
              活动状态
            </view>
            <view class="common">{{activity.isEnabled?'已开启':'未开启'}}</view>
          </view>
        </block>

        <block wx:if="{{activity.mobile}}">
          <view class="item">
            <view class="title">
              联系电话
            </view>
            <view class="common">{{activity.mobile}}</view>
          </view>
        </block>
        <block wx:if="{{registerList.length>0}}">
          <view class="item">
            <view class="title">
              报名记录
            </view>
            <block wx:if="{{registerList.length==1}}">
              <view class="common">
                <block wx:for="{{registerList}}" wx:key="index">
                  <view data-index="{{index}}" bind:tap="lookLog" class="arLog">
                    <text>{{item.shopStore.storeName}} {{item.booking}}</text>
                    <van-icon name="{{tips.isEdit?'edit':'medal' }}" size="40rpx" />
                  </view>
                </block>
              </view>
            </block>
          </view>
          <view class="item" wx:if="{{registerList.length>1}}">
            <view class="title">
              <text decode="{{true}}">&emsp;&emsp;&emsp;&emsp;</text>
            </view>
            <view class="common">
              <block wx:for="{{registerList}}" wx:key="index">
                <view data-index="{{index}}" bind:tap="lookLog" class="arLog">
                  <text>{{item.shopStore.storeName}} {{item.booking}}</text>
                  <van-icon name="{{tips.isEdit?'edit':'medal-o' }}" size="40rpx" />
                </view>
              </block>
            </view>
          </view>
        </block>



        <button bindtap="application" wx:if="{{activity.shopStore.length>0&&tips.isCanSign}}" class="btn">
          <text wx:if="{{activity.price}}" style="color: red;font-weight: bold;margin-right: 10rpx;font-size: 28rpx;margin: 10rpx 0;">￥{{activity.price}}</text>
          前 往 报 名
        </button>

      </block>
      <block wx:if="{{active==1}}">
      <block wx:for="{{meRank}}" wx:key="index">
        <view class="meItem">
          <view class="h3">我的成绩</view>
          <view class="avatar">
            <image src="{{item.avatar}}" mode="" />
          </view>
          <view class="name">{{item.booking||''}}</view>
          <view class="name"><text style="font-weight: bold;">{{item.al_steps}}</text> 步</view>
          <view class="rang"><text style="font-weight: bold;">{{item.al_sportDate}}</text> 秒</view>
        </view>
      </block>
      
        <view class="rankbox">
          <view class="ran-top">
            <view class="top-til">{{changetitleMap[changetitle]}}排行榜</view>
            <view class="top-box" bindtap="change">
              切换
              <image style="width: 22rpx;height: 22rpx;" src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241226/fejv43122812199.png"></image>
            </view>
            <view class="top-box" style="margin-left: 20rpx;" bindtap="changeup">
              {{rank=='ASC'?'逆序':'正序'}}
              <image src="https://file-cloud.fmode.cn/qpFbRRSZrO/20241226/8lu1od115228414.png"></image>
            </view>
          </view>

          <block wx:for="{{rankList}}" wx:key="index">
            <view class="cardbox">
              <view class="image1" wx:if="{{index==0}}">1</view>
              <view class="image2" wx:if="{{index==1}}">2</view>
              <view class="image3" wx:if="{{index==2}}">3</view>
              <view class="paiming" wx:if="{{index>=3}}">{{index+1}}</view>
              <image class="avarter" src="{{item.avatar}}"></image>
              <view class="name">
                {{item.nickname}}
                <view class="name2">{{item.booking||''}}</view>
              </view>
              <view class="num">{{item.al_steps}}步</view>
              <view class="num">{{item.al_sportDate}}秒</view>
            </view>
          </block>
          <block wx:if="{{rankList.length<=0}}">
            <van-empty description="榜单静悄悄，运动一下吧~">
            </van-empty>
          </block>
        </view>
      </block>
    </block>
    <block wx:else>
      <button bind:tap="login">登录后可报名</button>
    </block>
  </view>
</view>


<van-popup style="height: 70vh;" show="{{ showpopup }}" bind:click-overlay='onClose' round position="bottom" bind:close="onClose">
  <view class="popup">
    <view class="topTitle topBox">报名信息</view>
    <view class="topBox">报名信息</view>
    <van-cell-group>
      <van-field model:value="{{ name }}" required clearable label="姓名" placeholder="请输入姓名" />
    </van-cell-group>
    <view class="registerStartDate">
      <view class="title">
        <text>*</text>
        姓别
      </view>
      <view class="date">
        <van-radio-group direction='horizontal' model:value="{{ sex }}" bind:change="onChangeSex">
          <van-radio icon-size="35rpx" name="男">男</van-radio>
          <van-radio icon-size="35rpx" name="女">女</van-radio>
        </van-radio-group>
      </view>
    </view>
    <van-cell-group>
      <van-field model:value="{{ idcard }}" type="number" required clearable label="身份证号" />
      <van-field model:value="{{ birthdate }}" required clearable label="出生日期" />
      <van-field model:value="{{ address }}" required clearable label="现居住地" />
      <van-field model:value="{{ mobile }}" type="number" required clearable label="联系电话" placeholder="请输入联系电话" />
      <van-field model:value="{{ classType }}" required clearable label="血型" />
      <van-field model:value="{{ teacher }}" required clearable label="紧急联系人" />
      <van-field model:value="{{ tel }}" type="number" required clearable label="联系人电话" placeholder="紧急联系人电话" />
    </van-cell-group>
    <view class="registerStartDate">
      <view class="title">
        <text>*</text>
        服装尺码
      </view>
    </view>
    <view class="registerStartDate">
      <view class="title"></view>
      <view class="date">
        <van-radio-group model:value="{{ centerDesc }}" bind:change="onChangecenterDesc">
          <van-radio icon-size="35rpx" name="S码(90斤以下)">S码(90斤以下) </van-radio>
          <van-radio icon-size="35rpx" name="M码(90斤-105斤)">M码(90斤-105斤)</van-radio>
          <van-radio icon-size="35rpx" name="L码(105斤-120斤)">L码(105斤-120斤)</van-radio>
          <van-radio icon-size="35rpx" name="XL码(120斤-135斤)">XL码(120斤-135斤)</van-radio>
          <van-radio icon-size="35rpx" name="2XL码(135斤-150斤)">2XL码(135斤-150斤)</van-radio>
          <van-radio icon-size="35rpx" name="3XL码(150斤-165斤)">3XL码(150斤-165斤)</van-radio>
          <van-radio icon-size="35rpx" name="4XL码(165斤-190斤)">4XL码(165斤-190斤)</van-radio>
          <van-radio icon-size="35rpx" name="5XL码(190斤-220斤)">5XL码(190斤-220斤)</van-radio>
        </van-radio-group>
      </view>
    </view>
    <view class="registerStartDate" bindtap="openStore">
      <view class="title">
        <text>*</text>
        位置
      </view>
      <view class="date">{{shop.storeName||'选择位置'}}</view>
    </view>
    <view class="registerStartDate" bindtap="onDisplay">
      <view class="title">
        <text>*</text>
        预约日期
      </view>
      <view class="date" wx:if="{{(!checkDate)&&aRegister.id}}">{{bookObj.from+' - '+bookObj.to}}</view>
      <view class="date" wx:else>{{checkDate?checkDate:'选择日期'}}</view>
    </view>


    <view class="registerStartTime" wx:if="{{checkDate}}">
      <view class="title">
        <text>*</text>
        选择时间
      </view>
      <block wx:if="{{checkTimeList&&checkTimeList.length>0}}">
        <block wx:for="{{checkTimeList}}" wx:key="index">
          <view class="box">
            <view class="time">
              <view class="from">
                <van-icon name="underway-o" />
                {{item.from}}
              </view>
              <view class="to">
                <van-icon name="stop-circle-o" />
                {{item.to}}
              </view>
            </view>
            <view>
              <view wx:if="{{activity.price}}" style="display: flex;flex-direction: column;align-items: center;">
                <text style="color: red;font-weight: bold;margin-right: 10rpx;font-size: 28rpx;margin: 10rpx 0;">￥{{activity.price}}</text>
              </view>
              <block wx:if="{{tips.isEdit}}">
                <view class="btn" data-from="{{item.fromDate}}" data-to="{{item.toDate}}" bindtap="enlists">
                  {{aRegister.id?'更改为本时间':'立即预约'}}
                </view>
              </block>
            </view>
          </view>
        </block>
      </block>
      <van-empty wx:else description="当天无可预约时间" />
    </view>
    <view class="registerStartDate">
      <view style="font-size: 30rpx;">
        <van-radio-group value="{{ isAttachment }}" bind:change="onChangeSexIsAttachment">
          <van-radio icon-size="35rpx" label-disabled name="同意">
            我已阅读并同意
            <text bind:tap="openFile" style="color: red;">《参赛选手免责声明》</text>
          </van-radio>
        </van-radio-group>
      </view>
    </view>
    <van-calendar color="#4F9AF7" formatter="{{ formatter }}" min-date="{{minDate}}" max-date="{{maxDate}}" show="{{ showDate }}" bind:close="onCloseDate" bind:confirm="onConfirm" />
    <view class="btn_btm">
      <button wx:if="{{tips.isEdit&&aRegister.id&&!checkDate}}" class="revise" bindtap="enlists">确认修改</button>
      <button wx:if="{{aRegister.id&&isAttend}}" class="revise" bind:tap="goUrl">前往参与</button>
    </view>
    <view style="height: 200rpx;"></view>
  </view>
</van-popup>


<van-popup show="{{ showStorePopup }}" bind:click-overlay='closeStore' round position="bottom" bind:close="closeStore">
  <view style="height: 70vh;">
    <view style="padding: 20rpx;border-bottom: 1rpx solid rgb(206, 206, 206);text-align: center;font-weight: bold;">选择位置</view>

    <van-empty wx:if="{{!shopList.length}}" description="暂无可选地址" />
    <scroll-view style="height:calc(70vh - 200rpx) ;" scroll-y="{{true}}">
      <view class="company">
        <block wx:for="{{shopList}}" wx:key="index">
          <view data-index="{{index}}" bindtap="chooseShop" class="name" style="color: {{shop.objectId==item.objectId?'#4F9AF7':'gray'}};">{{item.storeName}}
            <van-icon wx:if="{{shop.objectId==item.objectId}}" name="success" />
          </view>
        </block>
      </view>
    </scroll-view>
  </view>
</van-popup>

<block wx:if="{{activity.price}}">
  <payment style="z-index: 99999;" id='payMent' show="{{showPay}}" showType="wxpay" tradeNo="{{tradeNo}}" bind:payResult='acceptResult' price="{{activity.price}}" />
</block>