<template>
  <view class="bg">
    <view class="topBg">
      <m-nav-bar
        :title="navTitle"
        :transparent="true"
        theme="white"
      ></m-nav-bar>
      <view class="header">
        <view
          class="header-underline"
          :style="{
            left: active * 50 + '%',
          }"
        >
          <view class="header-underline-bg"></view>
        </view>
        <view
          @click="
            () => {
              active = 0;
              navTitle = '课程目录';
            }
          "
          class="header-item"
        >
          课程目录
        </view>
        <view
          @click="
            () => {
              active = 1;
              navTitle = '课程描述';
            }
          "
          class="header-item"
        >
          课程描述
        </view>
      </view>
    </view>

    <scroll-view
      enable-flex
      @scrolltoupper="
        () => {
          active = 0;
          navTitle = '课程目录';
        }
      "
      @scrolltolower="
        () => {
          active = 1;
          navTitle = '课程描述';
        }
      "
      :scroll-into-view="'courseCatalog-' + active"
      scroll-x
      class="content"
    >
      <view id="courseCatalog-0" class="">
        
        <course-catalog
          :price="query.price"
          :examId="query.examId"
          :list="examRoadList"
        ></course-catalog>
      </view>
      <view id="courseCatalog-1" class="">
        <course-desc></course-desc>
      </view>
    </scroll-view>
  </view>
</template>

<script>
import mNavBar from "../../components/m-nav-bar/m-nav-bar.vue";
import CourseDesc from "./components/courseDesc.vue";
import courseCatalog from "./components/courseCatalog.vue";
import api from "@/api";
import { mapGetters, mapState } from "vuex";
export default {
  components: { mNavBar, CourseDesc, courseCatalog },
  data() {
    return {
      query: {
        price: 0,
        state: 1,
      },
      examRoadList: [],
      active: 0,
      navTitle: "课程目录",
    };
  },
  onLoad(query) {
    this.query = query;
    this.$store.dispatch("GetRoadExamVip");
    api.carVideo.studentVipVideoList(this.query).then((res) => {
      this.examRoadList = res.rows;
    });
  },
  computed: {
    ...mapGetters(["roadExamIds"]),
  },
};
</script>

<style lang="scss" scoped>
.topBg {
  width: 750rpx;
  height: 350rpx;
  background: linear-gradient(48deg, #3ac770 0%, #50e68a 100%);
}
#courseCatalog-0 {
  display: inline-block;
  white-space: nowrap;
  width: 100%;
  height: 100%;
  overflow-y: scroll;
}
#courseCatalog-1 {
  display: inline-block;
  white-space: nowrap;
  width: 100%;
  height: 100%;
  overflow-y: scroll;
}
.bg {
  background: #fff;
  width: 100%;
  min-height: 100vh;
  overflow-y: scroll;
}

.header {
  width: 100%;
  display: flex;
  position: relative;
  .header-underline {
    position: absolute;
    width: 50%;
    bottom: 0;
    left: 0;
    display: flex;
    height: 8rpx;
    justify-content: center;
    box-sizing: border-box;

    .header-underline-bg {
      width: 64rpx;
      height: 8rpx;
      background: #fff;
      transform: translateY(50%);
    }
  }
  .header-item {
    width: 50%;
    height: 70rpx;
    line-height: 70rpx;
    text-align: center;
    color: #fff;
    font-size: 38rpx;
  }
  .header-item_select {
    color: #0a1a33;
  }
}
.content {
  white-space: nowrap;
  width: 100%;
  height: calc(100vh - 180rpx);
  position: absolute;
  top: 180rpx;
  border-radius: 80rpx 80rpx 0px 0px;
  background: #fff;
}
</style>