<template>
  <view class="wrapper">
    <u-navbar title="学习项目" @leftClick="leftClick" placeholder />
    <div class="top-container">
      <u-avatar :src="avatar" size="60" />
      <div class="name">{{ name }}</div>
    </div>
    <div class="title">{{ title }}</div>
    <div class="center-container">
      <div class="left">
        <div class="item">
          <u-icon name="/static/images/正确率.png" size="50" />
          <div class="text">
            <div>正确率</div>
            <div>{{ correctRate }}</div>
          </div>
        </div>
        <div class="item">
          <u-icon name="/static/images/累计作答.png" size="50" />
          <div class="text">
            <div>累计作答</div>
            <div>{{ totalAnswer }}</div>
          </div>
        </div>
        <div class="item">
          <u-icon name="/static/images/累计答对.png" size="50" />
          <div class="text">
            <div>累计答对</div>
            <div>{{ totalCorrect }}</div>
          </div>
        </div>
      </div>
      <div class="right">
        <div class="right-top" @click="handleExercises(1)">
          <div class="right-text">顺序练习</div>
          <u-icon class="top-icon" name="/static/images/顺序练习.png" width="84" height="73" />
        </div>
        <div class="right-bottom" @click="handleExercises(2)">
          <div class="right-text">随机练习</div>
          <u-icon class="bottom-icon" name="/static/images/随机练习.png" width="84" height="73" />
        </div>
      </div>
    </div>
    <!-- 目前不要选择题库 -->
    <!-- <div class="bottom">
      <div class="bottom-text">选择题库</div>
      <u-icon class="bottom-icon" name="/static/images/选择题库.png" width="140" height="100" />
    </div> -->
  </view>
</template>

<script>
export default {
  data() {
    return {
      // 头像
      avatar: 'https://cdn.uviewui.com/uview/album/1.jpg',
      // 姓名
      name: '张三',
      // 练习标题
      title: '送配电线路架设(初级)',
      // 正确率
      correctRate: '80%',
      // 累计作答
      totalAnswer: 100,
      // 累计答对
      totalCorrect: 80
    }
  },
  methods: {
    handleExercises(type) {
      console.log('type', type)
      uni.navigateTo({
        url: `/pages/YNEduApp/prac/exercises?type=${type}`
      })
    },
    leftClick() {
      const from = uni.getStorageSync('from')
      uni.navigateTo({
        url: from
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.wrapper {
  height: 94vh;
  background: url('/static/images/练习-bg.png') no-repeat;
  background-size: 100% 100%;
  padding: 20px;

  .top-container {
    margin-top: 40px;
    display: flex;
    align-items: center;

    .name {
      font-weight: 500;
      font-size: 17px;
      color: #ffffff;
      margin-left: 20px;
    }
  }
  .title {
    margin-top: 50px;
    margin-bottom: 30px;
    font-weight: 800;
    font-size: 26px;
    color: #fff;
    line-height: 30px;
    text-shadow: 0px 1px 2px rgba(0, 0, 0, 0.5);
    text-align: center;
  }

  .center-container {
    display: flex;
    justify-content: space-between;
    .left {
      width: 52%;
      height: 209px;
      background: #5185ed;
      border-radius: 8px;
      display: flex;
      flex-direction: column;
      justify-content: space-around;

      .item {
        padding: 0 15px;
        display: flex;
        align-items: center;
        justify-content: space-around;

        &:first-child {
          margin-left: -8px;
        }

        .text {
          color: #fff;
          font-size: 16px;
          font-weight: 500;
          margin-left: 10px;
          display: flex;
          flex-direction: column;
          align-items: center;
        }
      }
    }

    .right {
      width: 43%;
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .right-top {
        height: 98px;
        background: #e7ac67;
        border-radius: 8px;
        position: relative;
        // top-icon - 在当前位置的右下角
        .top-icon {
          position: absolute;
          right: 0;
          bottom: 0;
        }
      }
      .right-bottom {
        height: 98px;
        background: #73c2f7;
        border-radius: 8px 8px 8px 8px;
        position: relative;
        // bottom-icon - 在当前位置的左下角
        .bottom-icon {
          position: absolute;
          left: 0;
          bottom: 0;
        }
      }

      .right-text {
        font-weight: 500;
        font-size: 15px;
        color: #fff;
        margin: 5px 0 0 10px;
      }
    }
  }
  .bottom {
    margin-top: 20px;
    width: 100%;
    height: 120px;
    background: #226de3;
    border-radius: 8px;
    position: relative;

    .bottom-icon {
      position: absolute;
      right: 0;
      bottom: 0;
    }

    .bottom-text {
      font-weight: 400;
      font-size: 30px;
      color: #ffffff;
      line-height: 120px;
      margin: auto 20px;
    }
  }
}
</style>
