<template>
  <div class="page-person-box">
    <div class="user-box">
      <!-- 头像 -->
      <div class="userCardBox">
        <div class="userInfo">
          <van-image
            class="userHeaderImg"
            fit="cover"
            :src="maleAvatar"
            :show-error="true"
            :error-icon="maleAvatar"
          />
          <div class="userName">
            {{ userName }}
          </div>
        </div>
        <div class="userCardLine"></div>
        <!-- 今日积分 -->
        <div class="todayScoreBox">
          <div class="flexRowStartCenter">
            <span class="todayScore">今日积分:</span>
            <span class="todayScoreNum">50</span>
          </div>
        </div>
        <div style="height: 1rem"></div>
      </div>
    </div>
    <!-- 积分 -->
    <div class="all-score-box">
      <div class="allScoreCard">
        <div class="allScore">总积分: 100</div>
      </div>
    </div>
    <!-- 菜单 -->
    <div class="menu-box">
      <div class="menuCard">
        <van-grid>
          <van-grid-item
            v-for="(item, index) in menus"
            :key="index"
            :icon="item.icon"
            :text="item.title"
            @click="clickGridIcon(item)"
          />
        </van-grid>
        <div style="height: 3rem"></div>
      </div>
    </div>
  </div>
</template>

<script>
import maleAvatar from "@/assets/image/maleAvatar.jpg";
export default {
  name: "page-personal",
  components: {},
  data() {
    return {
      maleAvatar,
      avatarStyle: {
        "border-radius": "3rem",
        width: "1.8rem",
        height: "1.8rem",
        "background-color": "white",
        "margin-right": "0.2rem"
      },
      faceUrl: "",
      userName: "test@test.com",
      menus: [
        { title: "考试成绩", icon: "photo-o", to: "exam-history" },
        { title: "收藏", icon: "photo-o", to: "collection" },
        { title: "排行榜", icon: "photo-o", to: "rank" },
        { title: "使用手册", icon: "photo-o", to: "user-manual" },
        { title: "积分兑换", icon: "photo-o", to: "" }
      ]
    };
  },
  mounted() {
    this.getDailyPoints();
  },
  methods: {
    //   获取今日分数
    getDailyPoints() {
      let path = {
        userName: "testuser-zirKBELIlg"
      };
      this.$_http
        .get(this.$pathParams(this.$_API.JTXT_GET_USER_DAIYL_POINTS, path))
        .then(res => {
          this.contentObj = res.data;
          console.log("--user--" + JSON.stringify(this.contentObj));
        })
        .catch(() => {
          this.$store.commit("toggleLoading", false);
        });
    },
    // 点击宫格图标
    clickGridIcon(item) {
      console.log("---click--" + JSON.stringify(item));
      this.$router.push({
        name: item.to,
        params: { userId: "testuser-zirKBELIlg" }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
.page-person-box {
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  font-size: 1rem;
  width: 100%;
  height: 100%;
  .user-box {
    padding: 0.5rem 0.5rem;
    .userCardBox {
      background-color: #fff;
      padding: 0.5rem 0.5rem;
      box-shadow: 0 0 4px 2px rgba(139, 163, 198, 0.3);
      -webkit-box-shadow: 0 0 4px 2px rgba(139, 163, 198, 0.3);
      border-radius: 0.1rem;
      .userHeaderImg {
        width: 2.5rem;
        height: 2.5rem;
        border-radius: 0.1rem;
        margin-right: 0.5rem;
      }
      .userCardLine {
        border-bottom: 1px solid #f1f1f1;
        width: 100%;
        height: 1px;
        margin: 0.4rem 0;
      }
      .userInfo {
        padding: 0.5rem 0;
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
      }
      .userName {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
      }
      .flexRowStartCenter {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
      }
      .todayScoreBox {
        padding: 0.5rem 0;
        font-size: 0.5rem;
        flex-wrap: nowrap;
        white-space: nowrap;
        overflow: hidden;
        .todayScore {
          margin-left: 0.5rem;
          margin-right: 0.5rem;
          font-size: 0.7rem;
        }
        .todayScoreNum {
          margin-right: 0.5rem;
          font-size: 0.7rem;
        }
      }
    }
  }
  .all-score-box {
    padding: 0.5rem 0.5rem;
    .allScoreCard {
      background-color: #fff;
      width: 100%;
      padding: 0.5rem 0.5rem;
      box-shadow: 0 0 4px 2px rgba(139, 163, 198, 0.3);
      -webkit-box-shadow: 0 0 4px 2px rgba(139, 163, 198, 0.3);
      border-radius: 0.1rem;
      .allScore {
        padding: 0.5rem 0;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
        font-size: 0.8rem;
        color: #f6664f;
        font-weight: bold;
      }
    }
  }

  .menu-box {
    padding: 0.5rem 0.5rem;
    .menuCard {
      background-color: #fff;
      width: 100%;
      padding: 1rem 0.5rem;
      box-shadow: 0 0 4px 2px rgba(139, 163, 198, 0.3);
      -webkit-box-shadow: 0 0 4px 2px rgba(139, 163, 198, 0.3);
      border-radius: 0.1rem;
    }
  }
}
</style>
