靳炳淑 5 years ago
parent
commit
c41c69438d

+ 1 - 1
src/layouts/studentLayout.vue

@@ -45,7 +45,7 @@ export default {
         },
         {
           optionName: "个人中心",
-          link: "/student/user/001",
+          link: `/student/user/${window.localStorage.getItem("userId")}`,
         },
         {
           optionName: "登出",

+ 1 - 1
src/layouts/teacherLayout.vue

@@ -41,7 +41,7 @@ export default {
       optionList: [
         {
           optionName: "个人中心",
-          link: "/teacher/user/0001",
+          link: `/teacher/user/${window.localStorage.getItem("userId")}`,
         },
         {
           optionName: "登出",

+ 7 - 4
src/router/index.js

@@ -1,23 +1,24 @@
 import Vue from "vue";
 import VueRouter from "vue-router";
+// teacher
 import TeacherLayout from "@/layouts/teacherLayout.vue";
 import CourseList from "@/views/teacher/CourseList.vue";
 import CourseCreate from "@/views/teacher/CourseCreate.vue";
 import CourseEdit from "@/views/teacher/CourseEdit.vue";
 import TeacherCenter from "@/views/teacher/UserCenter.vue";
-
+// student
 import StudentLayout from "@/layouts/studentLayout.vue";
 import StudentCourseList from "@/views/student/CourseList.vue";
 import UserCenter from "@/views/student/UserCenter.vue";
 import HistoryOrder from "@/views/student/HistoryOrder.vue";
 import CourseStudy from "@/views/student/CourseStudy.vue";
 import CoursePeek from "@/views/student/CoursePeek.vue";
-
+// defualt
 import DefaultLayout from "@/layouts/defaultLayout.vue";
 import Login from "@/views/Login.vue";
 import Register from "@/views/Register.vue";
 import Home from "@/views/Home.vue";
-
+// authentication
 import { judgeTeacher, judgeStudent  } from "@/util/auth";
 
 Vue.use(VueRouter);
@@ -67,7 +68,7 @@ const routes = [
       },
       {
         path: "edit/:courseId",
-        name: "TeacherCourseEdir",
+        name: "TeacherCourseEdit",
         component: CourseEdit
       }
     ]
@@ -120,6 +121,8 @@ router.beforeEach((to, from, next) => {
   if (to.name === "CoursePeek") legal = true;
   if (legal) {
     next();
+  } else {
+    next({name: "Login"})
   }
 })
 

+ 3 - 1
src/views/Home.vue

@@ -2,6 +2,7 @@
   <div>
     <v-container class="ma-8 pa-4">
       <template>
+        <!-- 分类课程 -->
         <v-card>
           <v-tabs color="deep-purple accent-4" right v-model="currentTab">
             <v-tab>初级课程</v-tab>
@@ -44,6 +45,7 @@
         <v-divider></v-divider>
       </v-row>
 
+      <!-- 搜索课程 -->
       <v-row class="mt-10">
         <v-col cols="5">
           <v-text-field
@@ -73,7 +75,7 @@
         >
         </course-item>
       </v-row>
-      <v-row>
+      <v-row class="d-flex justify-center">
         <v-pagination
           v-model="searchCurrentPage"
           :length="searchTotalPage"

+ 30 - 3
src/views/student/CourseList.vue

@@ -2,6 +2,20 @@
   <div>
     <v-container class="ma-8 pa-4">
       <template>
+        <!-- 分类课程 -->
+        <v-row class="mt-2 mb-8">
+          <v-chip
+            class="ma-2"
+            color="deep-purple lighten-3"
+            label
+            text-color="white"
+          >
+            <v-icon left>
+              mdi-label
+            </v-icon>
+            分类课程
+          </v-chip>
+        </v-row>
         <v-card>
           <v-tabs color="deep-purple accent-4" right v-model="currentTab">
             <v-tab>初级课程</v-tab>
@@ -43,8 +57,17 @@
         <v-divider></v-divider>
       </v-row>
 
+      <!-- 搜索课程 -->
       <v-row class="mt-10">
-        <v-col cols="5">
+        <v-col>
+          <v-chip color="deep-purple lighten-3" label text-color="white">
+            <v-icon left>
+              mdi-label
+            </v-icon>
+            搜索课程
+          </v-chip>
+        </v-col>
+        <v-col>
           <v-text-field
             v-model="searchText"
             outlined
@@ -71,7 +94,7 @@
         >
         </course-item>
       </v-row>
-      <v-row>
+      <v-row class="d-flex justify-center">
         <v-pagination
           class="mt-4"
           v-model="searchCurrentPage"
@@ -85,7 +108,7 @@
       </v-row>
 
       <!-- 已购课程 -->
-      <v-row class="mt-8 mb-2 ml-1">
+      <v-row class="mt-8 mb-2">
         <v-chip
           class="ma-2"
           color="deep-purple lighten-3"
@@ -176,9 +199,11 @@ import { createOrder } from "@/api/order";
 
 export default {
   name: "StudentCourseList",
+
   components: {
     CourseItem,
   },
+
   data() {
     return {
       dialog: false,
@@ -215,6 +240,7 @@ export default {
       boughtCoursesList: [],
     };
   },
+
   watch: {
     "primary.currentPage": {
       handler: function(val) {
@@ -242,6 +268,7 @@ export default {
       this.handleSearchCourse();
     },
   },
+
   methods: {
     showDialog(courseId, courseName, coursePrice) {
       this.currentCourseId = courseId;

+ 7 - 5
src/views/student/UserCenter.vue

@@ -100,7 +100,7 @@ export default {
   },
 
   methods: {
-    async handleRecharge() {
+    handleRecharge() {
       recharge({ userId: this.userInfo.id, value: this.value }).then((res) => {
         console.log(res);
         if (res && res.code === 1) {
@@ -115,14 +115,16 @@ export default {
       });
     },
 
-    async refreshUserInfo() {
+    refreshUserInfo() {
       const userId = window.localStorage.getItem("userId");
-      this.userInfo = await getUser(userId);
+      getUser(userId).then((res) => {
+        this.userInfo = res || {};
+      });
     },
   },
 
-  async mounted() {
-    await this.refreshUserInfo();
+  mounted() {
+    this.refreshUserInfo();
   },
 };
 </script>

+ 4 - 2
src/views/teacher/CourseEdit.vue

@@ -13,7 +13,7 @@
         {{ alertMsg }}
       </v-alert>
 
-      <!-- dialog-->
+      <!-- 删除 dialog-->
       <template>
         <v-row justify="center">
           <v-dialog v-model="deleteDialog" persistent max-width="600px">
@@ -42,7 +42,7 @@
         </v-row>
       </template>
 
-      <!-- dialog-->
+      <!-- 编辑 dialog-->
       <template>
         <v-row justify="center">
           <v-dialog v-model="dialog" persistent max-width="600px">
@@ -124,6 +124,7 @@
       </template>
 
       <v-row>
+        <!-- 课件列表 -->
         <v-col>
           <v-card max-width="600" class="mx-auto mt-8">
             <v-toolbar color="primary" dark>
@@ -168,6 +169,7 @@
             </v-list>
           </v-card>
         </v-col>
+        <!-- 课程信息 -->
         <v-col>
           <form class="pa-12 grey lighten-5 mt-8">
             <v-text-field

+ 0 - 1
src/views/teacher/CourseList.vue

@@ -41,7 +41,6 @@ export default {
   data() {
     return {
       colorList: ["#26A69A", "#00B0FF", "#5C6BC0", "#FFB300", "#E57373"],
-
       courseList: null,
     };
   },

+ 7 - 5
src/views/teacher/UserCenter.vue

@@ -100,7 +100,7 @@ export default {
   },
 
   methods: {
-    async handleRecharge() {
+    handleRecharge() {
       recharge({ userId: this.userInfo.id, value: this.value }).then((res) => {
         console.log(res);
         if (res && res.code === 1) {
@@ -115,14 +115,16 @@ export default {
       });
     },
 
-    async refreshUserInfo() {
+    refreshUserInfo() {
       const userId = window.localStorage.getItem("userId");
-      this.userInfo = await getUser(userId);
+      getUser(userId).then((res) => {
+        this.userInfo = res || {};
+      });
     },
   },
 
-  async mounted() {
-    await this.refreshUserInfo();
+  mounted() {
+    this.refreshUserInfo();
   },
 };
 </script>