|
@@ -1,262 +0,0 @@
|
|
|
-<script setup>
|
|
|
-import { ref, reactive, watch } from "vue";
|
|
|
-import { useMainStore } from "@/stores/store";
|
|
|
-import axios from "axios";
|
|
|
-import Navbar from "@/components/Navbar.vue";
|
|
|
-import CourseCard from "@/components/CourseCard.vue";
|
|
|
-
|
|
|
-const store = useMainStore();
|
|
|
-let pageNum = ref(1); // 頁數(預設第一頁)
|
|
|
-let pageAmount = ref(18); // 每頁顯示筆數
|
|
|
-let totalPages = ref(1); // 總頁數
|
|
|
-
|
|
|
-let loading = ref(false);
|
|
|
-let searchInput = ref("");
|
|
|
-let searchError = ref(false);
|
|
|
-const courseAll = reactive({
|
|
|
- classes: [],
|
|
|
-});
|
|
|
-const courseData = reactive({
|
|
|
- classes: [],
|
|
|
-});
|
|
|
-
|
|
|
-const listLocation = ref(null);
|
|
|
-
|
|
|
-// 切換分頁時回到列表上方
|
|
|
-watch(pageNum, () => {
|
|
|
- getClass();
|
|
|
- listLocation.value.scrollIntoView({ behavior: "smooth", block: "start" });
|
|
|
-});
|
|
|
-
|
|
|
-async function getClass() {
|
|
|
- loading.value = true;
|
|
|
- let url = `https://cmm.ai:8088/api/get_class_name?page_num=${pageNum.value}&page_amount=${pageAmount.value}`;
|
|
|
-
|
|
|
- try {
|
|
|
- const response = await axios.get(url);
|
|
|
- totalPages.value = store.getTotalPages(response.data.total_num, 18);
|
|
|
- courseAll.classes = response.data.classes;
|
|
|
- courseData.classes = response.data.classes;
|
|
|
- loading.value = false;
|
|
|
- console.log("response", response);
|
|
|
- } catch (error) {
|
|
|
- loading.value = false;
|
|
|
- console.error(error);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-getClass();
|
|
|
-
|
|
|
-// 開啟登入視窗
|
|
|
-function openLoginDialog() {
|
|
|
- store.loginDialog = true;
|
|
|
-}
|
|
|
-
|
|
|
-// 收藏課程清單
|
|
|
-let favorites = reactive({
|
|
|
- list: [],
|
|
|
-});
|
|
|
-
|
|
|
-let progress = ref(false);
|
|
|
-// let token = localStorage.getItem("token");
|
|
|
-
|
|
|
-// 加入收藏課程
|
|
|
-// async function setFavoriteClass(classId) {
|
|
|
-// let isLogin = store.checkToken();
|
|
|
-// if (!isLogin) {
|
|
|
-// openLoginDialog();
|
|
|
-// return;
|
|
|
-// }
|
|
|
-
|
|
|
-// progress.value = true;
|
|
|
-
|
|
|
-// const url = `https://cmm.ai:8088/api/add_favorite_class?class_name_id=${classId}&access_token=${token}`;
|
|
|
-// try {
|
|
|
-// const response = await axios.post(url);
|
|
|
-// getFavoriteClass();
|
|
|
-// progress.value = false;
|
|
|
-// } catch (error) {
|
|
|
-// console.error(error);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// 取得收藏課程
|
|
|
-// async function getFavoriteClass() {
|
|
|
-// try {
|
|
|
-// const response = await axios.get(
|
|
|
-// `https://cmm.ai:8088/api/get_favorite_class?access_token=${token}`
|
|
|
-// );
|
|
|
-// favorites.list = response.data.favorite_courses;
|
|
|
-// } catch (error) {
|
|
|
-// console.error(error);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// getFavoriteClass();
|
|
|
-
|
|
|
-// 刪除收藏課程
|
|
|
-// async function deleteFavoriteClass(classId) {
|
|
|
-// progress.value = true;
|
|
|
-// try {
|
|
|
-// const response = await axios.post(
|
|
|
-// `https://cmm.ai:8088/api/delete_favorite_class?class_name_id=${classId}&access_token=${token}`
|
|
|
-// );
|
|
|
-// progress.value = false;
|
|
|
-// getFavoriteClass();
|
|
|
-// } catch (error) {
|
|
|
-// console.error(error);
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
-// 檢查收藏狀態
|
|
|
-// function isClassFavorite(classId) {
|
|
|
-// let list = favorites.list.map((e) => e.class_name_id);
|
|
|
-// return list.includes(classId);
|
|
|
-// }
|
|
|
-
|
|
|
-const breadcrumbs = reactive([
|
|
|
- {
|
|
|
- title: "首頁",
|
|
|
- disabled: false,
|
|
|
- href: "/",
|
|
|
- },
|
|
|
- {
|
|
|
- title: "探索課程",
|
|
|
- disabled: true,
|
|
|
- },
|
|
|
-]);
|
|
|
-</script>
|
|
|
-
|
|
|
-<template>
|
|
|
- <div class="college-bg-img">
|
|
|
- <Navbar />
|
|
|
- <v-container fluid class="college-content pb-16 px-sm-0">
|
|
|
- <div class="banner">
|
|
|
- <img src="@/assets/img/course/banner.png" alt="" />
|
|
|
- </div>
|
|
|
- <div class="main-block">
|
|
|
- <v-breadcrumbs
|
|
|
- :items="breadcrumbs"
|
|
|
- divider="/"
|
|
|
- class="mt-10 pa-0"
|
|
|
- ></v-breadcrumbs>
|
|
|
-
|
|
|
- <!-- <div
|
|
|
- class="d-flex flex-column flex-sm-row align-center justify-space-between title"
|
|
|
- >
|
|
|
- <h2>最新開課</h2>
|
|
|
- <div class="search">
|
|
|
- <span>
|
|
|
- <input
|
|
|
- v-model="searchInput"
|
|
|
- type="text"
|
|
|
- @keyup.enter="search()" placeholder="關鍵字搜尋"
|
|
|
- />
|
|
|
- <button @click="search()">
|
|
|
- <img src="@/assets/img/news/news-search-icon.png" alt="" />
|
|
|
- </button>
|
|
|
- </span>
|
|
|
- <div
|
|
|
- v-if="searchError"
|
|
|
- class="d-flex justify-center align-center error me-4"
|
|
|
- >
|
|
|
- <v-icon color="primary" icon="mdi-alert" class="me-2"></v-icon>
|
|
|
- 沒有符合搜尋條件的項目
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- <v-row>
|
|
|
- <v-col
|
|
|
- sm="6"
|
|
|
- md="4"
|
|
|
- cols="12"
|
|
|
- v-for="(item, index) in testData"
|
|
|
- :key="index"
|
|
|
- class="pa-5"
|
|
|
- >
|
|
|
- <CourseCard :data="item" />
|
|
|
- </v-col>
|
|
|
- </v-row> -->
|
|
|
-
|
|
|
- <div
|
|
|
- class="d-flex flex-column flex-sm-row align-center justify-space-between title"
|
|
|
- ref="listLocation"
|
|
|
- >
|
|
|
- <h2>課程清單</h2>
|
|
|
- <div class="search">
|
|
|
- <span>
|
|
|
- <input
|
|
|
- v-model="searchInput"
|
|
|
- type="text"
|
|
|
- @keyup.enter="search()"
|
|
|
- placeholder="關鍵字搜尋"
|
|
|
- />
|
|
|
- <button @click="search()">
|
|
|
- <img src="@/assets/img/news/news-search-icon.png" alt="" />
|
|
|
- </button>
|
|
|
- </span>
|
|
|
- <div
|
|
|
- v-if="searchError"
|
|
|
- class="d-flex justify-center align-center error me-4"
|
|
|
- >
|
|
|
- <v-icon color="primary" icon="mdi-alert" class="me-2"></v-icon>
|
|
|
- 沒有符合搜尋條件的項目
|
|
|
- </div>
|
|
|
- </div>
|
|
|
- </div>
|
|
|
-
|
|
|
- <div class="d-flex justify-center mb-10" v-if="loading">
|
|
|
- <v-progress-circular
|
|
|
- color="grey-lighten-4"
|
|
|
- indeterminate
|
|
|
- ></v-progress-circular>
|
|
|
- </div>
|
|
|
-
|
|
|
- <v-row>
|
|
|
- <v-col
|
|
|
- sm="6"
|
|
|
- md="4"
|
|
|
- cols="12"
|
|
|
- v-for="(item, index) in courseData.classes"
|
|
|
- :key="index"
|
|
|
- class="pa-5"
|
|
|
- >
|
|
|
- <CourseCard :data="item" />
|
|
|
- </v-col>
|
|
|
- </v-row>
|
|
|
- <div class="progress-item" v-if="progress">
|
|
|
- <v-progress-circular
|
|
|
- :size="50"
|
|
|
- indeterminate
|
|
|
- color="primary"
|
|
|
- ></v-progress-circular>
|
|
|
- </div>
|
|
|
- <v-pagination
|
|
|
- v-model="pageNum"
|
|
|
- :length="totalPages"
|
|
|
- rounded="circle"
|
|
|
- class="mt-16"
|
|
|
- ></v-pagination>
|
|
|
- </div>
|
|
|
- </v-container>
|
|
|
- </div>
|
|
|
-</template>
|
|
|
-
|
|
|
-<style lang="scss" scoped>
|
|
|
-.banner {
|
|
|
- display: flex;
|
|
|
- justify-content: end;
|
|
|
- img {
|
|
|
- width: 75%;
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-.main-block {
|
|
|
- margin-top: -20%;
|
|
|
-}
|
|
|
-
|
|
|
-.v-pagination {
|
|
|
- margin: auto;
|
|
|
- max-width: 500px;
|
|
|
-}
|
|
|
-</style>
|