<template>
  <div class="pb_content">
    <div class="pb_content_body">
      <div class="body_student">
        <div class="student_head">
          <div class="box_course">
            <div class="wheel">
              <img
                :src="
                  studentMessage.headportrait != null
                    ? studentMessage.headportrait
                    : tx
                "
                alt=""
              />
            </div>
            <div class="right_box">
              <div class="right_box_title">{{ studentMessage.name }}</div>
              <div class="people">
                <div>
                  <span>班级：</span><span>{{ studentMessage.cname }}</span>
                </div>
                <div style="margin-left: 50px">
                  <span>所属学校：</span><span>{{ studentMessage.sname }}</span>
                </div>
              </div>
              <div>
                <span>手机号码：</span
                ><span>{{ studentMessage.phonenumber }}</span>
              </div>
            </div>
          </div>
        </div>
        <div class="student_body">
          <div class="myProject">我的项目</div>
          <div class="project_box">
            <div
              class="three_box_inthis"
              v-for="(item, index) in myCourse"
              :key="index"
            >
              <div
                class="project"
                @click="
                  goTo(
                    '/courseDetail?courseId=' +
                      item.courseid +
                      '&userid=' +
                      userid +
                      '&oid=' +
                      oid +
                      '&cid=' +
                      classId +
                      '&tType=' +
                      tType +
                      '&screenType=' +
                      screenType
                  )
                "
              >
                <img
                  :src="
                    item.cover != null && item.cover != ''
                      ? JSON.parse(item.cover)[0].url
                      : mpj
                  "
                  alt=""
                />
                <!-- <img
                  :src="
                    mpj
                  "
                  alt=""
                /> -->
              </div>
              <div class="projct_nav">
                <div
                  style="font-size: 18px"
                  @click="
                    goTo(
                      '/courseDetail?courseId=' +
                        item.courseid +
                        '&userid=' +
                        userid +
                        '&oid=' +
                        oid
                    )
                  "
                >
                  {{ item.title }}
                </div>
                <div style="color: #2fdb88">
                  共{{ JSON.parse(item.chapters).length }}讲
                </div>
                <div>
                  <span style="color: #999">{{ item.createTime }}</span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      myCourse: [],
      studentMessage: [],
      tx: require("../assets/avatar.png"),
      // mpj: require("../assets/project.png"),
      mpj: "https://ccrb.s3.cn-northwest-1.amazonaws.com.cn/noBanner1656409780264.jpg",
      userid: this.$route.query.userid,
      oid: this.$route.query.oid,
      classId: this.$route.query.cid,
      tType: this.$route.query.tType,
      screenType: this.$route.query.screenType,
    };
  },
  methods: {
    goTo(path) {
      this.$router.push(path);
    },
    selectSDetail() {
      let params = {
        uid: this.userid,
      };
      this.ajax
        .get(this.$store.state.api + "selectSDetail", params)
        .then((res) => {
          this.studentMessage = res.data[0][0];
        })
        .catch((err) => {
          this.isLoading = false;
          console.error(err);
        });
    },
    selectMyCourse() {
      let params = {
        uid: this.userid,
      };
      this.ajax
        .get(this.$store.state.api + "selectMyCourseBycid", params)
        .then((res) => {
          this.myCourse = res.data[0];
        })
        .catch((err) => {
          console.error(err);
        });
    },
  },
  created() {
    this.selectSDetail();
    this.selectMyCourse();
    document.scrollingElement.scrollTop = 0;
  },
};
</script>

<style scoped>
.body_student {
  margin: 0px auto;
  width: 98%;
  height: 100%;
}
.student_head {
  width: 100%;
  margin: 0 auto;
  height: 30%;
  background-image: linear-gradient(90deg, #30c499, #75ceba);
  color: #fff;
}
.wheel > img,
.project > img {
  width: 100%;
  height: 100%;
}
.box_course {
  display: flex;
  padding: 35px 0 25px 60px;
  align-items: center;
}
.wheel {
  width: 210px;
}
.right_box {
  display: flex;
  flex-direction: column;
  margin-left: 30px;
  /* justify-content: space-around; */
}
.right_box_title {
  font-size: 23px;
}
.people {
  display: flex;
  margin: 30px 0 20px 0px;
}
.student_body {
  width: 100%;
  margin: 0 auto;
  background: #fff;
  margin-top: 20px;
  padding: 0 0 20px;
}
.project {
  width: 100%;
  height: 175px;
}
.project_box {
  display: flex;
  width: 100%;
  flex-direction: row;
  flex-wrap: wrap;
}
.three_box_inthis {
  display: flex;
  width: 30.33%;
  flex-direction: column;
  align-items: flex-start;
  border: 1px solid #ccc;
  margin: 15px 0 0 15px;
}
.projct_nav {
  margin-left: 5px;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  justify-content: space-around;
}

.projct_nav > div:nth-child(1) {
  cursor: pointer;
}

.projct_nav > div {
  margin-bottom: 5px;
}

.myProject {
  padding: 20px 20px 10px 0;
  border-bottom: 1px solid #ccc;
  margin-left: 20px;
  width: 95%;
}
</style>
