<view>
  <!-- 轮播 -->
  <view class='swiper_box'>
    <swiper class="swiperBox" current="{{currentSwiper}}" bindchange="swiperChange"
      autoplay="{{autoplay}}" interval="{{interval}}" circular="{{ circular }}">
      <block wx:for="{{imgUrls}}" wx:key="{{index}}">
        <swiper-item class="swiperCon">
          <image src="{{item.url}}" class="slideImage"/>
        </swiper-item>
      </block>
    </swiper>
    <view class="dots">
      <block wx:for="{{imgUrls}}" wx:key>
        <view class="dot {{index == currentSwiper ? 'active' : ''}}"></view>
      </block>
    </view>
  </view>
  <view id="userTab">
    <view class="userTabItem">
      <image src="../../assets/back_tap.png"></image>
      <text>{{teenageName}}</text>
    </view>
    <image id="userCenter" src="../../assets/icon_setting.png" bindtap="toMine"></image>
  </view>
  <!-- 头像、设置 -->
  <view id="userBox">
    <view>
      <image id="userHead" src="{{ avatar }}" />
    </view>
    <view id="userInfo">
      <view id="userDetail">
        <image id="userGender" src="{{ gender }}" />
        <text>{{age}}岁</text>
        <view id="initial">
          <text>当前视力</text>
          <text class="initialIcon">R</text>
          <text>{{rightEye}}</text>
          <text class="initialIcon">L</text>
          <text>{{leftEye}}</text>
        </view>
      </view>
    </view>
  </view>
  <view id="userBtnBox">
    <image src="../../assets/btn_trainplan_nor.png" bindtap="plan"></image>
    <image src="../../assets/btn_trainset_nor.png" bindtap="set"></image>
  </view>
  <!-- 监控 -->
  <view class="checkCon">
    <view class="checkDes">
      <text id="trainTime">设备使用中，今日已训练0分钟</text>
      <view id="powerBox" bindtap="PowerOff">
        <text class="PowerOff">立即关机</text>
        <image src="../../assets/power.png" />
      </view>
    </view>
    <view class="checkImg">
      <view id="checkImgNo" wx:if="{{!isRun}}">
        <image src="../../assets/indexDefault.png" />
        <view hidden="{{true}}" id="checkImgNoRefreshBox"><text id="checkImgNoRefresh">手动刷新</text></view>
      </view>
      <view id="checkImgConBox" wx:else>
        <image id="checkImgCon" src="{{checkImg}}" />
        <image id="btn_refresh" bindtap="refresh" src="../../assets/btn_refresh.png"></image>
      </view>
    </view>
  </view>
  <!-- 灰色间隔start -->
  <!-- <view class="grayBlock"></view> -->
  <!-- 灰色间隔end -->
  <!-- 适合的目标 -->
  <!-- <view class="target" bindtap="target">
    <text>适合【佩奇】的小目标</text>
    <view class="targetDes">
      <image src="../../assets/task_complete.png" />
      <view>接下来的一周按要求完成训练任务，瓜分<text>9999</text>积分</view>
    </view>
  </view> -->
  <view class="grayBlock"></view>
  <!-- 训练报告 -->
  <view class="report">
    <view class="reportTitle" bindtap="trainReport">
      <view class="reportTitleLeft">训练报告</view>
      <view class="targetHistory">
        <!-- <text>历史报告</text> -->
        <image src="../../assets/icon_more.png"></image>
      </view>
    </view>
    <view class="reportDes">
      <view id="taskCompleteWrap" wx:if="{{finishedStatus==1}}">
        <view id="taskComplete">
          <image src="../../assets/task_complete.png" />
          上周训练计划完成
        </view>
        <view id="taskCompleteDes">连续<text>{{continuousWeeks}}</text>周完成训练，超过<text>{{surpassRatio}}</text>的人</view>
      </view>
      <view id="taskNocompleteWrap" wx:else>
        <view id="taskNocomplete">
          <image src="../../assets/task_incomplete.png" />
          训练计划未完成
        </view>
        <view id="taskNocompleteDes">请坚持完成训练哦</view>
      </view>
    </view>
    <view class="reprotChartTitle">上周（{{beginDay}}~{{endDay}}）共训练<text>{{weekDuration}}</text>分钟</view>
    <view class="reprotChart">
      <view class="reprotWeekChart">
        <ec-canvas id="reprotWeekChart" ec="{{ weekChart }}"></ec-canvas>
      </view>
      <view class="reprotPieChart">
        <ec-canvas id="reprotPieChart" ec="{{ pieChart }}"></ec-canvas>
      </view>
      <!-- <view class="reprotChartSuggest">
        <view class="reprotChartSuggestTitle">训练建议</view>
        <view class="adviseItem" wx:for="{{visionAdvice}}" wx:key>
          <image src="../../assets/advise.png" />
          <text>{{item}}</text>
        </view>
      </view> -->
    </view>
  </view>
  <!-- 灰色间隔start -->
  <view class="grayBlock"></view>
  <!-- 灰色间隔end -->
  <!-- 训练成就 -->
  <view id="achieve">
    <view class="achieveTitle">
      <text>训练成就</text>
      <!-- <image src="../../assets/icon_more.png"></image> -->
    </view>
    <view class="achieveTime">累计训练<text>{{totalTrainingDays}}</text>天</view>
    <view class="achieveChange">
      视力从<text>{{lastVision}}</text>
      <text wx:if="{{lastVision<nowVision}}">提升到</text><text wx:elif="{{lastVision==nowVision}}">保持在</text><text wx:else>降低到</text>
      <text>{{nowVision}}</text>
    </view>
      <view class="reprotChartSuggest">
        <view class="reprotChartSuggestTitle">训练建议</view>
        <view class="adviseItem" wx:for="{{visionAdvice}}" wx:key>
          <image src="../../assets/advise.png" />
          <text>{{item}}</text>
        </view>
      </view>
    <view id="leftEyeChartBox">
      <view class="eyeChartName">左眼视力</view>
      <view class="legend_box">
        <view class="legend_over">
          <image src="../../assets/legend_over.png" />
          <text>训练后</text>
        </view>
        <view class="legend_no">
          <image src="../../assets/legend_no.png" />
          <text>未训练</text>
        </view>
      </view>
    </view>
    <view class="leftEyeChart">
      <ec-canvas id="leftEyeChart" ec="{{ leftEyeChart }}"></ec-canvas>
      <text id="leftYear">{{beginYear}}</text>
    </view>
    <view id="rightEyeChartBox">
      <view class="eyeChartName">右眼视力</view>
      <view class="legend_box">
        <view class="legend_over">
          <image src="../../assets/legend_over.png" />
          <text>训练后</text>
        </view>
        <view class="legend_no">
          <image src="../../assets/legend_no.png" />
          <text>未训练</text>
        </view>
      </view>
    </view>
    <view class="rightEyeChart">
      <ec-canvas id="rightEyeChart" ec="{{ rightEyeChart }}"></ec-canvas>
      <text id="rightYear">{{beginYear}}</text>
    </view>
  </view>
  <!-- 灰色间隔start -->
  <view class="grayBlock"></view>
  <!-- 灰色间隔end -->
  <!-- 训练排行 -->
  <view id="trainSort">
    <view class="trainSortTitle" bindtap="toTrainSort">
      <view class="trainSortTitleLeft">训练排行</view>
      <view class="trainSortTitleRight">
        <!-- <text>完整排行</text> -->
        <image src="../../assets/icon_more.png"></image>
      </view>
    </view>
    <view id="trainSortList">
      <view class="trainSortListItemWrap {{item.ranking==userRanking?'trainSortListItemSelf':''}}" wx:for="{{trainSortList}}" wx:key="{{index}}">
        <view class="trainSortListItem">
          <view class="trainSortListItemLeft">
            <text>{{item.ranking}}</text>
            <view class="trainSortListItemInfo">
              <image src="{{item.avatar}}" />
              <text>{{item.name}}</text>
            </view>
          </view>
          <text>{{we.toFixed(item.duration/60)}}分钟</text>
        </view>
      </view>
    </view>
  </view>
  <!-- 灰色间隔start -->
  <view class="grayBlock"></view>
  <!-- 灰色间隔end -->
  <!-- 光明之星 -->
  <view id="resultSort">
    <view class="resultSortTitle" bindtap="toStarSort">
      <view class="resultSortTitleLeft">光明之星</view>
      <view class="resultSortTitleRight">
        <!-- <text>完整排行</text> -->
        <image src="../../assets/icon_more.png"></image>
      </view>
    </view>
    <view id="resultSortList">
      <view class="resultSortListItemWrap" wx:for="{{resultSortList}}" wx:key="{{index}}">
        <view class="resultSortListItem">
          <view class="resultSortListItemLeft">
            <text>{{item.ranking}}</text>
            <view class="resultSortListItemInfo">
              <image src="{{item.avatar}}" />
              <text>{{item.name}}</text>
            </view>
          </view>
          <view class="resultSortListItemRight">
            <image src="../../assets/up.png" />
            <!-- <image wx:if="{{item.type=='up'}}" src="../../assets/up.png" /> -->
            <!-- <image wx:elif="{{item.type=='down'}}" src="../../assets/down.png" /> -->
            <!-- <image wx:else src="../../assets/none.png" /> -->
            <view class="resultSortListItemRightEyeBox">
              <text>{{item.degree}}</text>
              <text class="resultSortListItemRightEye">{{item.promoteMode}}</text>
            </view>
          </view>
        </view>
      </view>
    </view>
    <view id="indexBottom"></view>

    <!-- 更新训练计划弹窗 -->
    <view id="mustUpdate" catchtouchmove="preventTouchMove" hidden="{{mustUpdate}}">
      <view id="mustUpdateBox" wx:if="{{status==2}}">
        <!-- 内容 -->
        <view id="mustUpdateCon">
          <view id="mustUpdateTitle">尊敬的家长您好</view>
          <view id="mustUpdateDes">请前往“训练计划”更新训练计划，否则护眼仪将暂时无法正常使用。</view>
        </view>
        <!-- 按钮组 -->
        <view id="mustUpdateBtn">
          <text id="lastGoBtn" bindtap="lastGo">稍后前往</text>
          <text id="nowGoBtn" bindtap="nowGo">一键前往</text>
        </view>
      </view>
      <view id="mustUpdateBox" wx:else>
        <!-- 内容 -->
        <view id="mustUpdateCon">
          <view id="mustUpdateTitle">尊敬的家长您好</view>
          <view id="mustUpdateDes">因您长时间未更新视力信息，眼保仪已被暂时锁定。为了保障孩子的训练成效，请您立即前往"训练计划"更新“视力数据”！</view>
        </view>
        <!-- 按钮组 -->
        <view id="mustUpdateBtn">
          <text id="nowGoBtn" bindtap="nowGo">立即前往</text>
        </view>
      </view>
    </view>
  </view>
</view>

<wxs module="we">
  var toFixed = function (value) {
    return Math.floor(value);
  }
  module.exports = {
    toFixed :toFixed
  }
</wxs>