ChengYuXuan 5 年之前
父節點
當前提交
e68343d7b6

+ 1 - 1
src/App.vue

@@ -16,7 +16,7 @@ export default Vue.extend({
 
   data: () => ({
     //
-  }),
+  })
 });
 </script>
 

+ 12 - 12
src/api/coupon.js

@@ -9,8 +9,8 @@ import { COUPON_MODULE } from "./_prefix";
 export const createCoupon = payload => {
   return axios.post(`${COUPON_MODULE}/create`, payload).then(res => {
     return res.data;
-  })
-}
+  });
+};
 
 /**
  * 发放优惠券
@@ -20,8 +20,8 @@ export const createCoupon = payload => {
 export const deliverCoupon = payload => {
   return axios.post(`${COUPON_MODULE}/deliver`, payload).then(res => {
     return res.data;
-  })
-}
+  });
+};
 
 /**
  * 获取可以发布的优惠券
@@ -69,14 +69,14 @@ export const getCouponList = () => {
   //     "sharable": true
   //   }
   // ])
-}
+};
 
 export const getAvailableCouponsForOrder = orderId => {
-  return axios.get(`${COUPON_MODULE}/getForOrder`, {
-    params: {
-      orderId
-    }
-  }).then(res=>res.data);
+  return axios
+    .get(`${COUPON_MODULE}/getForOrder`, {
+      params: {
+        orderId
+      }
+    })
+    .then(res => res.data);
 };
-
-

+ 45 - 23
src/api/course.js

@@ -3,20 +3,20 @@ import { COURSE_MODULE } from "./_prefix";
 
 /**
  * 获取一门课程 GET /course/{courseId}?uid={uid} 会包含用户是否购买的信息
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const getCourseById = payload => {
   const { uid, courseId } = payload;
   return axios.get(`${COURSE_MODULE}/${courseId}?uid=${uid}`).then(res => {
     return res.data;
   });
-}
+};
 
 /**
  * 根据关键字 分页获取课程列表 GET /course/all/{page}?uid={uid}&key={key}
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const getCoursesByKey = payload => {
   const { uid, key, page } = payload;
@@ -29,8 +29,8 @@ export const getCoursesByKey = payload => {
 
 /**
  * 根据课程分类 分页获取课程列表 GET course/type/{page}?uid={uid}&type={type}
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const getCoursesByType = payload => {
   const { uid, type, page } = payload;
@@ -43,34 +43,56 @@ export const getCoursesByType = payload => {
 
 /**
  * 获取用户已购买的课程列表 GET course/sid/{sid}
- * @param {*} uid 
- * @returns 
+ * @param {*} uid
+ * @returns
  */
 export const getBoughtCourses = uid => {
   return axios.get(`${COURSE_MODULE}/sid/${uid}`).then(res => {
     return res.data;
   });
-}
+};
 
 export const getTeacherCourses = uid => {
   return axios.get(`${COURSE_MODULE}/tid/${uid}`).then(res => {
     return res.data;
   });
-}
+};
 
 /**
  * 创建一门课程 POST course/create
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const createCourse = payload => {
-  const { name, type, intro, picture, school, cost, teacherId, teacherName, bought, manageable } = payload;
-  return axios.post(`${COURSE_MODULE}/create`, {
-    name, type, intro, picture, school, cost, teacherId, teacherName, bought, manageable
-  }).then(res => {
-    return res.data;
-  });
-}
+  const {
+    name,
+    type,
+    intro,
+    picture,
+    school,
+    cost,
+    teacherId,
+    teacherName,
+    bought,
+    manageable
+  } = payload;
+  return axios
+    .post(`${COURSE_MODULE}/create`, {
+      name,
+      type,
+      intro,
+      picture,
+      school,
+      cost,
+      teacherId,
+      teacherName,
+      bought,
+      manageable
+    })
+    .then(res => {
+      return res.data;
+    });
+};
 
 /**
  * 获取热门课程
@@ -78,9 +100,9 @@ export const createCourse = payload => {
  */
 export const getHotCourses = () => {
   return axios.get(`${COURSE_MODULE}/hot/1`).then(res => {
-    return res.data
-  })
-}
+    return res.data;
+  });
+};
 
 /**
  * 点赞课程

+ 68 - 26
src/api/courseWare.js

@@ -3,63 +3,105 @@ import { COURSE_WARE } from "./_prefix";
 
 /**
  * 获取某课件 GET course_ware/{courseWareId}?uid={uid}
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const getCourseWare = payload => {
   const { courseWareId, uid } = payload;
   return axios.get(`${COURSE_WARE}/${courseWareId}?uid=${uid}`).then(res => {
     return res.data;
   });
-}
+};
 
 /**
  * 获取一门课程的所有课件 GET course_ware/course/{courseId}?uid={uid}
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const getCourseWareByCourse = payload => {
   const { courseId, uid } = payload;
   return axios.get(`${COURSE_WARE}/course/${courseId}?uid=${uid}`).then(res => {
     return res.data;
   });
-}
+};
 
 /**
  * 创建课件 POST course_ware/create
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const createCourseWare = payload => {
-  const { courseId, number, title, fileName, fileType, fileSize, freeFlag, downloadFlag, availableFlag } = payload;
-  return axios.post(`${COURSE_WARE}/create`, {
-    courseId, number, title, fileName, fileType, fileSize, freeFlag, downloadFlag, availableFlag
-  }).then(res => {
-    return res.data;
-  });
-}
+  const {
+    courseId,
+    number,
+    title,
+    fileName,
+    fileType,
+    fileSize,
+    freeFlag,
+    downloadFlag,
+    availableFlag
+  } = payload;
+  return axios
+    .post(`${COURSE_WARE}/create`, {
+      courseId,
+      number,
+      title,
+      fileName,
+      fileType,
+      fileSize,
+      freeFlag,
+      downloadFlag,
+      availableFlag
+    })
+    .then(res => {
+      return res.data;
+    });
+};
 
 /**
  * 更新课件 POST course_ware/update
  * @param {*} payload id: 课件id
- * @returns 
+ * @returns
  */
 export const updateCourseWare = payload => {
-  const { id, courseId, number, title, fileName, fileType, fileSize, freeFlag, downloadFlag, availableFlag } = payload;
-  return axios.post(`${COURSE_WARE}/update`, {
-    id, courseId, number, title, fileName, fileType, fileSize, freeFlag, downloadFlag, availableFlag
-  }).then(res => {
-    return res.data;
-  });
-}
+  const {
+    id,
+    courseId,
+    number,
+    title,
+    fileName,
+    fileType,
+    fileSize,
+    freeFlag,
+    downloadFlag,
+    availableFlag
+  } = payload;
+  return axios
+    .post(`${COURSE_WARE}/update`, {
+      id,
+      courseId,
+      number,
+      title,
+      fileName,
+      fileType,
+      fileSize,
+      freeFlag,
+      downloadFlag,
+      availableFlag
+    })
+    .then(res => {
+      return res.data;
+    });
+};
 
 /**
  * 删除课件 POST course_ware/delete/{courseWareId}
- * @param {*} courseWareId 
- * @returns 
+ * @param {*} courseWareId
+ * @returns
  */
 export const deleteCourseWare = courseWareId => {
   return axios.post(`${COURSE_WARE}/delete/${courseWareId}`).then(res => {
     return res.data;
   });
-}
+};

+ 1 - 1
src/api/file.js

@@ -7,4 +7,4 @@ export const uploadFile = payload => {
   return axios.post(`${FILE_MODULE}/upload`, payload).then(res => {
     return res.data;
   });
-}
+};

+ 9 - 5
src/api/order.js

@@ -6,7 +6,7 @@ import { ORDER_MODULE } from "./_prefix";
  * @param {*}
  * @returns
  */
-export const createOrder = (uid,courseId) => {
+export const createOrder = (uid, courseId) => {
   return axios
     .post(`${ORDER_MODULE}/create?uid=${uid}&courseId=${courseId}`)
     .then(res => {
@@ -58,7 +58,9 @@ export const getOrderById = orderId => {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export const useCoupon = (order, couponId) => {
-  return axios.post(`${ORDER_MODULE}/use_coupon?couponId=${couponId}`, order).then(res => res.data);
+  return axios
+    .post(`${ORDER_MODULE}/use_coupon?couponId=${couponId}`, order)
+    .then(res => res.data);
 };
 
 /**
@@ -68,9 +70,11 @@ export const useCoupon = (order, couponId) => {
  * @returns {Promise<AxiosResponse<any>>}
  */
 export const cancelCoupon = (order, couponId) => {
-  return axios.post(`${ORDER_MODULE}/cancel_coupon?couponId=${couponId}`, order).then(res => res.data);
+  return axios
+    .post(`${ORDER_MODULE}/cancel_coupon?couponId=${couponId}`, order)
+    .then(res => res.data);
 };
 
 export const payOrder = orderId => {
-  return axios.post(`${ORDER_MODULE}/pay/${orderId}`).then(res=>res.data)
-}
+  return axios.post(`${ORDER_MODULE}/pay/${orderId}`).then(res => res.data);
+};

+ 2 - 2
src/api/recharge.js

@@ -1,5 +1,5 @@
 import axios from "axios";
-import {RECHARGE_MODULE} from "@/api/_prefix";
+import { RECHARGE_MODULE } from "@/api/_prefix";
 
 /**
  * 用户充值 POST /user/recharge
@@ -12,4 +12,4 @@ export const recharge = payload => {
   return axios.post(`${RECHARGE_MODULE}/`, { userId, value }).then(res => {
     return res.data;
   });
-}
+};

+ 21 - 15
src/api/user.js

@@ -3,20 +3,26 @@ import { USER_MODULE } from "./_prefix";
 
 /**
  * 用户注册 POST /user/register
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const register = payload => {
   console.log(payload);
   const { uname, phone, password, picture, userRole = "STUDENT" } = payload;
-  return axios.post(`${USER_MODULE}/register`, {
-    uname, phone, password, picture, userRole
-  }).then(res => {
-    return res.data;
-  });
+  return axios
+    .post(`${USER_MODULE}/register`, {
+      uname,
+      phone,
+      password,
+      picture,
+      userRole
+    })
+    .then(res => {
+      return res.data;
+    });
 
   /** 前后端分离开发时 前端可以自己写简易的 mock  */
-  // return Promise.resolve({  
+  // return Promise.resolve({
   //   "code": 1,
   //   "msg": "账号注册成功!",
   //   "data": {
@@ -34,8 +40,8 @@ export const register = payload => {
 
 /**
  *  用户登录 POST /user/login
- * @param {*} payload 
- * @returns 
+ * @param {*} payload
+ * @returns
  */
 export const login = payload => {
   console.log(payload);
@@ -43,7 +49,7 @@ export const login = payload => {
   return axios.post(`${USER_MODULE}/login`, { phone, password }).then(res => {
     return res.data;
   });
-  // return Promise.resolve({  
+  // return Promise.resolve({
   //   "code": 1,
   //   "msg": "账号登录成功!",
   //   "data": {
@@ -57,16 +63,16 @@ export const login = payload => {
   //     "createTime": "2021-03-13T01:45:48.246+00:00"
   //   }
   // });
-} 
+};
 
 /**
  *  获取用户 GET /user/{uid}
- * @param {*} uid 
- * @returns 
+ * @param {*} uid
+ * @returns
  */
 export const getUser = uid => {
   console.log(uid);
   return axios.get(`${USER_MODULE}/${uid}`).then(res => {
     return res.data;
   });
-}
+};

+ 14 - 14
src/components/CouponItem.vue

@@ -32,44 +32,44 @@ export default Vue.extend({
   props: {
     id: {
       type: Number,
-      default: 0,
+      default: 0
     },
     type: {
       type: String,
-      default: "",
+      default: ""
     },
     scope: {
       type: String,
-      default: "",
+      default: ""
     },
     name: {
       type: String,
-      default: "",
+      default: ""
     },
     description: {
       type: String,
-      default: "",
+      default: ""
     },
     metadata: {
       type: String,
-      default: "",
+      default: ""
     },
     startTime: {
       type: String,
-      default: "",
+      default: ""
     },
     endTime: {
       type: String,
-      default: "",
+      default: ""
     },
     valid: {
       type: Boolean,
-      default: false,
+      default: false
     },
     sharable: {
       type: Boolean,
-      default: false,
-    },
+      default: false
+    }
   },
   data() {
     return {};
@@ -77,15 +77,15 @@ export default Vue.extend({
   methods: {
     handleDeliver: function() {
       this.$emit("deliver-coupon", this.id);
-    },
+    }
   },
   computed: {
     text: function() {
       return this.description.length < 60
         ? this.description
         : this.description.substring(0, 60) + "...";
-    },
-  },
+    }
+  }
 });
 </script>
 

+ 21 - 21
src/components/CourseItem.vue

@@ -33,12 +33,12 @@
     </v-card-actions>
     <v-row justify="end" class="pr-5">
       <v-btn
-          class="mx-2 align-self-center"
-          fab
-          dark
-          small
-          color="red"
-          @click="handleLike"
+        class="mx-2 align-self-center"
+        fab
+        dark
+        small
+        color="red"
+        @click="handleLike"
       >
         <v-icon dark>
           mdi-heart
@@ -57,41 +57,41 @@ export default Vue.extend({
   props: {
     courseName: {
       type: String,
-      default: "SubjectName",
+      default: "SubjectName"
     },
     courseId: {
       type: Number,
-      default: 0,
+      default: 0
     },
     description: {
       type: String,
-      default: "课程简介",
+      default: "课程简介"
     },
     type: {
       type: String,
-      default: "初级",
+      default: "初级"
     },
     cost: {
       type: Number,
-      default: 0,
+      default: 0
     },
     bought: {
       type: Boolean,
-      default: false,
+      default: false
     },
     manageable: {
       type: Boolean,
-      default: false,
+      default: false
     },
     hasLogin: {
       type: Boolean,
-      default: true,
+      default: true
     },
     courseColor: {
       type: String,
-      default: "#BCAAA4",
+      default: "#BCAAA4"
     },
-    courseLikes:{
+    courseLikes: {
       type: Number,
       default: 0
     }
@@ -99,7 +99,7 @@ export default Vue.extend({
   data() {
     return {
       chip: ["免费", "已购"],
-      chipColor: ["success", "primary"],
+      chipColor: ["success", "primary"]
     };
   },
   methods: {
@@ -116,8 +116,8 @@ export default Vue.extend({
     handlePeek() {
       this.$router.push(`/student/peek/${this.courseId}`);
     },
-    handleLike(){
-      this.$emit("set-like",this.courseId)
+    handleLike() {
+      this.$emit("set-like", this.courseId);
     }
   },
   computed: {
@@ -135,8 +135,8 @@ export default Vue.extend({
         return 1;
       }
       return -1;
-    },
-  },
+    }
+  }
 });
 </script>
 

+ 11 - 11
src/components/CourseItemTeacher.vue

@@ -24,36 +24,36 @@ export default Vue.extend({
   props: {
     courseName: {
       type: String,
-      default: "SubjectName",
+      default: "SubjectName"
     },
     courseId: {
       type: Number,
-      default: 0,
+      default: 0
     },
     description: {
       type: String,
-      default: "课程简介",
+      default: "课程简介"
     },
     type: {
       type: String,
-      default: "初级",
+      default: "初级"
     },
     cost: {
       type: Number,
-      default: 0,
+      default: 0
     },
     bought: {
       type: Boolean,
-      default: false,
+      default: false
     },
     manageable: {
       type: Boolean,
-      default: false,
+      default: false
     },
     courseColor: {
       type: String,
-      default: "#BCAAA4",
-    },
+      default: "#BCAAA4"
+    }
   },
 
   computed: {
@@ -61,8 +61,8 @@ export default Vue.extend({
       return this.description.length < 60
         ? this.description
         : this.description.substring(0, 60) + "...";
-    },
-  },
+    }
+  }
 });
 </script>
 

+ 6 - 6
src/layouts/adminLayout.vue

@@ -41,13 +41,13 @@ export default {
       optionList: [
         {
           optionName: "优惠管理",
-          link: "/admin/coupon",
+          link: "/admin/coupon"
         },
         {
           optionName: "登出",
-          link: "/",
-        },
-      ],
+          link: "/"
+        }
+      ]
     };
   },
   methods: {
@@ -65,8 +65,8 @@ export default {
       window.localStorage.removeItem("userPhone");
       window.localStorage.removeItem("username");
       window.localStorage.removeItem("userRole");
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 2 - 2
src/layouts/defaultLayout.vue

@@ -30,8 +30,8 @@ export default {
       if (this.$route.path !== link) {
         this.$router.push(link);
       }
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 7 - 7
src/layouts/studentLayout.vue

@@ -41,17 +41,17 @@ export default {
       optionList: [
         {
           optionName: "历史订单",
-          link: "/student/history",
+          link: "/student/history"
         },
         {
           optionName: "个人中心",
-          link: `/student/user/${window.localStorage.getItem("userId")}`,
+          link: `/student/user/${window.localStorage.getItem("userId")}`
         },
         {
           optionName: "登出",
-          link: "/",
-        },
-      ],
+          link: "/"
+        }
+      ]
     };
   },
   methods: {
@@ -69,8 +69,8 @@ export default {
       window.localStorage.removeItem("userPhone");
       window.localStorage.removeItem("username");
       window.localStorage.removeItem("userRole");
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 6 - 6
src/layouts/teacherLayout.vue

@@ -41,13 +41,13 @@ export default {
       optionList: [
         {
           optionName: "个人中心",
-          link: `/teacher/user/${window.localStorage.getItem("userId")}`,
+          link: `/teacher/user/${window.localStorage.getItem("userId")}`
         },
         {
           optionName: "登出",
-          link: "/",
-        },
-      ],
+          link: "/"
+        }
+      ]
     };
   },
   methods: {
@@ -65,8 +65,8 @@ export default {
       window.localStorage.removeItem("userPhone");
       window.localStorage.removeItem("username");
       window.localStorage.removeItem("userRole");
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 12 - 11
src/router/index.js

@@ -24,7 +24,7 @@ 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";
+import { judgeTeacher, judgeStudent } from "@/util/auth";
 
 Vue.use(VueRouter);
 
@@ -37,29 +37,29 @@ const routes = [
       {
         path: "/",
         name: "Home",
-        component: Home,
+        component: Home
       },
       {
         path: "login",
         name: "Login",
-        component: Login,
+        component: Login
       },
       {
         path: "register",
         name: "Register",
-        component: Register,
+        component: Register
       }
     ]
   },
   {
     path: "/admin",
-    name: 'Admin',
+    name: "Admin",
     component: AdminLayout,
     children: [
       {
         path: "/",
         name: "CouponList",
-        redirect: 'coupon'
+        redirect: "coupon"
       },
       {
         path: "coupon",
@@ -76,8 +76,8 @@ const routes = [
         path: "coupon/deliver",
         name: "CouponDeliver",
         component: CouponDeliver
-      },
-    ],
+      }
+    ]
   },
   {
     path: "/teacher",
@@ -148,15 +148,16 @@ const router = new VueRouter({
 
 router.beforeEach((to, from, next) => {
   let legal = false;
-  if (!to.path.startsWith("/student") && !to.path.startsWith("/teacher")) legal = true;
+  if (!to.path.startsWith("/student") && !to.path.startsWith("/teacher"))
+    legal = true;
   if (to.path.startsWith("/student") && judgeStudent()) legal = true;
   if (to.path.startsWith("/teacher") && judgeTeacher()) legal = true;
   if (to.name === "CoursePeek") legal = true;
   if (legal) {
     next();
   } else {
-    next({name: "Login"})
+    next({ name: "Login" });
   }
-})
+});
 
 export default router;

+ 3 - 4
src/util/auth.js

@@ -1,12 +1,11 @@
 export const judgeLogin = () => {
   return !!window.localStorage.getItem("userId");
-}
+};
 
 export const judgeStudent = () => {
   return judgeLogin() && window.localStorage.getItem("userRole") === "STUDENT";
-}
+};
 
 export const judgeTeacher = () => {
   return judgeLogin() && window.localStorage.getItem("userRole") === "TEACHER";
-}
- 
+};

+ 16 - 16
src/views/Home.vue

@@ -115,7 +115,7 @@ import { getCoursesByType, getCoursesByKey } from "@/api/course";
 export default {
   name: "Home",
   components: {
-    CourseItem,
+    CourseItem
   },
   data() {
     return {
@@ -129,43 +129,43 @@ export default {
         name: "初级",
         totalPage: 1,
         currentPage: 1,
-        list: [],
+        list: []
       },
       medium: {
         name: "中级",
         totalPage: 1,
         currentPage: 1,
-        list: [],
+        list: []
       },
       advanced: {
         name: "高级",
         totalPage: 1,
         currentPage: 1,
-        list: [],
+        list: []
       },
       searchText: "",
       searchCourse: [],
       searchTotalPage: 1,
-      searchCurrentPage: 1,
+      searchCurrentPage: 1
     };
   },
   watch: {
     "primary.currentPage": {
       handler: function(val) {
         this.handleGetCoursesByType(val, "primary");
-      },
+      }
     },
 
     "medium.currentPage": {
       handler: function(val) {
         this.handleGetCoursesByType(val, "medium");
-      },
+      }
     },
 
     "advance.currentPage": {
       handler: function(val) {
         this.handleGetCoursesByType(val, "advanced");
-      },
+      }
     },
 
     searchCurrentPage: function() {
@@ -174,7 +174,7 @@ export default {
 
     searchText: function() {
       this.handleSearchCourse();
-    },
+    }
   },
   methods: {
     showDialog() {
@@ -182,7 +182,7 @@ export default {
     },
 
     handleBuyCourse() {
-      Promise.resolve(1).then((res) => {
+      Promise.resolve(1).then(res => {
         this.dialog = false;
         if (res) {
           this.dialog2 = true;
@@ -194,7 +194,7 @@ export default {
 
     handleGetCoursesByType(page, type) {
       const typeMap = { primary: "初级", medium: "中级", advanced: "高级" };
-      getCoursesByType({ uid: "", type: typeMap[type], page }).then((res) => {
+      getCoursesByType({ uid: "", type: typeMap[type], page }).then(res => {
         console.log(res);
         this[type].totalPage = res.pages;
         this[type].list = res.list;
@@ -205,20 +205,20 @@ export default {
       getCoursesByKey({
         uid: "",
         key: this.searchText,
-        page: this.searchCurrentPage,
-      }).then((res) => {
+        page: this.searchCurrentPage
+      }).then(res => {
         console.log(res);
         this.searchCourse = res.list;
         this.searchTotalPage = res.pages;
       });
-    },
+    }
   },
 
   mounted() {
-    ["primary", "medium", "advanced"].forEach((t) => {
+    ["primary", "medium", "advanced"].forEach(t => {
       this.handleGetCoursesByType(1, t);
     });
     this.handleSearchCourse();
-  },
+  }
 };
 </script>

+ 4 - 4
src/views/Login.vue

@@ -62,12 +62,12 @@ export default {
       showSuccessDialog: false,
       showFailDialog: false,
       msg: "",
-      username: "",
+      username: ""
     };
   },
   methods: {
     handleLogin() {
-      login({ phone: this.phone, password: this.password }).then((res) => {
+      login({ phone: this.phone, password: this.password }).then(res => {
         console.log(res);
         if (res.code === 1) {
           window.localStorage.setItem("userId", res.data.id);
@@ -101,8 +101,8 @@ export default {
           }, 1000);
         }
       });
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 5 - 5
src/views/Register.vue

@@ -66,7 +66,7 @@ export default {
       showSuccessDialog: false,
       showFailDialog: false,
       msg: "",
-      roles: ["teacher", "student","admin"],
+      roles: ["teacher", "student", "admin"]
     };
   },
   methods: {
@@ -76,8 +76,8 @@ export default {
         phone: this.phone,
         password: this.password,
         picture: null,
-        userRole: this.userRole.toUpperCase(),
-      }).then((res) => {
+        userRole: this.userRole.toUpperCase()
+      }).then(res => {
         console.log(res);
         if (res.code === 1) {
           window.localStorage.setItem("userId", res.data.id);
@@ -97,8 +97,8 @@ export default {
           }, 1000);
         }
       });
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 9 - 9
src/views/admin/CouponCreate.vue

@@ -106,7 +106,7 @@ export default {
         "单一课程",
         "指定教师的课程",
         "指定学习的课程",
-        "全站课程通用",
+        "全站课程通用"
       ],
       couponInfo: {
         type: "满减", // "DISCOUNT"
@@ -116,7 +116,7 @@ export default {
         metadata: "",
         startTime: "",
         endTime: "",
-        sharable: false,
+        sharable: false
       },
       meta: {
         threshold: 0,
@@ -124,12 +124,12 @@ export default {
         discount: 0,
         courseId: "",
         teacherId: "",
-        schoolId: "",
+        schoolId: ""
       },
 
       showSuccessDialog: false,
       showFailDialog: false,
-      msg: "",
+      msg: ""
     };
   },
 
@@ -139,16 +139,16 @@ export default {
         ...this.couponInfo,
         type: this.typeList_[this.typeList.indexOf(this.couponInfo.type)],
         scope: this.scopeList_[this.scopeList.indexOf(this.couponInfo.scope)],
-        metadata: JSON.stringify(this.meta),
+        metadata: JSON.stringify(this.meta)
       };
       console.log(payload);
-      createCoupon(payload).then((res) => {
+      createCoupon(payload).then(res => {
         console.log(res);
         if (res.code === 1) {
           this.showSuccessDialog = true;
           setTimeout(() => {
             this.showSuccessDialog = false;
-            this.$router.go(-1)
+            this.$router.go(-1);
           }, 1000);
         } else {
           this.showFailDialog = true;
@@ -158,8 +158,8 @@ export default {
           }, 1000);
         }
       });
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 4 - 4
src/views/admin/CouponDeliver.vue

@@ -38,18 +38,18 @@ import { getCouponList } from "@/api/coupon";
 export default {
   name: "CouponDeliver",
   components: {
-    CouponItem,
+    CouponItem
   },
   data() {
     return {
       colorList: ["#26A69A", "#00B0FF", "#5C6BC0", "#FFB300", "#E57373"],
-      couponList: null,
+      couponList: null
     };
   },
   mounted() {
-    getCouponList().then((res) => {
+    getCouponList().then(res => {
       this.couponList = res || [];
     });
-  },
+  }
 };
 </script>

+ 8 - 8
src/views/admin/CouponList.vue

@@ -93,7 +93,7 @@ import { getCouponList, deliverCoupon } from "@/api/coupon";
 export default {
   name: "CouponList",
   components: {
-    CouponItem,
+    CouponItem
   },
   data() {
     return {
@@ -111,11 +111,11 @@ export default {
       showDeliverDialog: false,
       showSuccessDialog: false,
       showFailDialog: false,
-      msg: "",
+      msg: ""
     };
   },
   mounted() {
-    getCouponList().then((res) => {
+    getCouponList().then(res => {
       this.couponList = res.data || [];
     });
   },
@@ -129,17 +129,17 @@ export default {
     handleDeliverCoupon() {
       const extra = {
         userId: this.userId,
-        courseId: this.courseId,
+        courseId: this.courseId
       };
       const payload = {
         couponId: this.couponId,
         deliver: this.deliverList_[this.deliverList.indexOf(this.deliver)],
         canDuplicate: this.canDuplicate,
         nums: Number.parseInt(this.nums),
-        extra: extra,
+        extra: extra
       };
       console.log(payload);
-      deliverCoupon(payload).then((res) => {
+      deliverCoupon(payload).then(res => {
         console.log(res);
         if (res.code === 1) {
           this.showSuccessDialog = true;
@@ -156,7 +156,7 @@ export default {
           }, 1000);
         }
       });
-    },
-  },
+    }
+  }
 };
 </script>

+ 55 - 52
src/views/student/CourseList.vue

@@ -248,7 +248,6 @@
     <v-snackbar v-model="showSnackBar" :color="snackBarColor" top>
       {{ snackBarMsg }}
     </v-snackbar>
-
   </div>
 </template>
 
@@ -261,8 +260,14 @@ import {
   getHotCourses,
   setCourseLike
 } from "@/api/course";
-import {cancelCoupon, createOrder, getOrderById, payOrder, useCoupon} from "@/api/order";
-import {getAvailableCouponsForOrder} from "@/api/coupon";
+import {
+  cancelCoupon,
+  createOrder,
+  getOrderById,
+  payOrder,
+  useCoupon
+} from "@/api/order";
+import { getAvailableCouponsForOrder } from "@/api/coupon";
 
 export default {
   name: "StudentCourseList",
@@ -331,9 +336,7 @@ export default {
           value: "sharable"
         }
       ],
-      coupons: [
-
-      ],
+      coupons: [],
       selectedCoupons: [],
       settleDialog: false,
       currentOrder: {}
@@ -377,27 +380,27 @@ export default {
     },
     openSettleDialog() {
       const uid = window.localStorage.getItem("userId");
-      createOrder(uid,this.currentCourseId).then(res=>{
-
-        if(res.code === 0){
-          this.snackBarColor = 'error'
-          this.snackBarMsg = res.msg
-          this.showSnackBar = true
-          this.dialog = false
-          return
+      createOrder(uid, this.currentCourseId).then(res => {
+        if (res.code === 0) {
+          this.snackBarColor = "error";
+          this.snackBarMsg = res.msg;
+          this.showSnackBar = true;
+          this.dialog = false;
+          return;
         }
 
         this.dialog = false;
         this.settleDialog = true;
-        this.currentOrder = res.data
+        this.currentOrder = res.data;
 
-        getAvailableCouponsForOrder(this.currentOrder.id).then(res=>{
-          this.selectedCoupons = this.currentOrder.usedCoupons ? this.currentOrder.usedCoupons : []
+        getAvailableCouponsForOrder(this.currentOrder.id).then(res => {
+          this.selectedCoupons = this.currentOrder.usedCoupons
+            ? this.currentOrder.usedCoupons
+            : [];
 
-          this.coupons = [...res.data,...this.selectedCoupons] // 将当前可用的 和 已经用的 合并起来展示,若之前创建过订单没有付款,再次进入时需要这样
-
-        })
-      })
+          this.coupons = [...res.data, ...this.selectedCoupons]; // 将当前可用的 和 已经用的 合并起来展示,若之前创建过订单没有付款,再次进入时需要这样
+        });
+      });
     },
     handleGetCoursesByType(page, type) {
       const uid = window.localStorage.getItem("userId");
@@ -444,23 +447,23 @@ export default {
 
     onSelectCoupon({ item, value }) {
       if (value) {
-        useCoupon(this.currentOrder, item.id).then((res)=>{
-          this.snackBarColor = 'success'
-          this.snackBarMsg = res.msg
-          this.showSnackBar = true
-              getOrderById(this.currentOrder.id).then(res=>{
-                this.currentOrder = res.data
-          })
-        })
+        useCoupon(this.currentOrder, item.id).then(res => {
+          this.snackBarColor = "success";
+          this.snackBarMsg = res.msg;
+          this.showSnackBar = true;
+          getOrderById(this.currentOrder.id).then(res => {
+            this.currentOrder = res.data;
+          });
+        });
       } else {
-        cancelCoupon(this.currentOrder,item.id).then((res)=>{
-          this.snackBarColor = 'success'
-          this.snackBarMsg = res.msg
-          this.showSnackBar = true
-          getOrderById(this.currentOrder.id).then(res=>{
-            this.currentOrder = res.data
-          })
-        })
+        cancelCoupon(this.currentOrder, item.id).then(res => {
+          this.snackBarColor = "success";
+          this.snackBarMsg = res.msg;
+          this.showSnackBar = true;
+          getOrderById(this.currentOrder.id).then(res => {
+            this.currentOrder = res.data;
+          });
+        });
       }
     },
 
@@ -479,22 +482,22 @@ export default {
         }
       });
     },
-    confirmPayment(){
-      this.settleDialog = false
-      payOrder(this.currentOrder.id).then((res)=>{
-        this.snackBarColor = 'success'
-        this.snackBarMsg = res.msg
-        this.showSnackBar = true
-      })
+    confirmPayment() {
+      this.settleDialog = false;
+      payOrder(this.currentOrder.id).then(res => {
+        this.snackBarColor = "success";
+        this.snackBarMsg = res.msg;
+        this.showSnackBar = true;
+      });
     },
-    leaveSettlement(){
-      this.currentOrder = {}
-      this.currentCourseId = 0
-      this.currentCoursePrice = 0
-      this.currentCourseName = ''
-      this.coupons = []
-      this.selectedCoupons = []
-      this.settleDialog = false
+    leaveSettlement() {
+      this.currentOrder = {};
+      this.currentCourseId = 0;
+      this.currentCoursePrice = 0;
+      this.currentCourseName = "";
+      this.coupons = [];
+      this.selectedCoupons = [];
+      this.settleDialog = false;
     }
   },
 

+ 12 - 9
src/views/student/CourseStudy.vue

@@ -139,7 +139,10 @@
         </v-col>
         <!-- 课程信息 -->
         <v-col>
-          <form class="pa-12 grey lighten-5 mt-8" style="position: sticky;top: 0">
+          <form
+            class="pa-12 grey lighten-5 mt-8"
+            style="position: sticky;top: 0"
+          >
             <v-text-field
               v-model="courseInfo.name"
               label="课程名称"
@@ -222,22 +225,22 @@ export default {
         freeFlag: false,
         downloadFlag: true,
         availableFlag: false,
-        uploadTime: "",
-      },
+        uploadTime: ""
+      }
     };
   },
 
   computed: {
     isCharge: function() {
       return this.courseInfo.cost !== 0;
-    },
+    }
   },
 
   methods: {
     refreshFile() {
       const { courseId } = this.$route.params;
       const uid = window.localStorage.getItem("userId");
-      getCourseWareByCourse({ courseId, uid }).then((res) => {
+      getCourseWareByCourse({ courseId, uid }).then(res => {
         this.files = res || [];
       });
     },
@@ -245,13 +248,13 @@ export default {
     loadCourse() {
       const { courseId } = this.$route.params;
       const uid = window.localStorage.getItem("userId");
-      getCourseById({ uid, courseId }).then((res) => {
+      getCourseById({ uid, courseId }).then(res => {
         this.courseInfo = res;
       });
     },
 
     showFileDialog(courseWareId) {
-      const currentFile = this.files.find((f) => f.id === courseWareId);
+      const currentFile = this.files.find(f => f.id === courseWareId);
       console.log(currentFile);
       this.currentFile = currentFile;
       this.dialog = true;
@@ -268,13 +271,13 @@ export default {
       //   }, 1000);
       // });
       window.open(`${FILE_BASE_PATH}/${this.currentFile.fileName}`);
-    },
+    }
   },
 
   mounted() {
     this.refreshFile();
     this.loadCourse();
-  },
+  }
 };
 </script>
 

+ 5 - 5
src/views/student/HistoryOrder.vue

@@ -35,24 +35,24 @@ export default {
         "#039BE5",
         "#546E7A",
         "#B39DDB",
-        "#EF9A9A",
+        "#EF9A9A"
       ],
-      orderList: [],
+      orderList: []
     };
   },
 
   methods: {
     handleStudy(courseId) {
       this.$router.push(`/student/course/${courseId}`);
-    },
+    }
   },
 
   mounted() {
     const uid = window.localStorage.getItem("userId");
-    getOrdersByUser(uid).then((res) => {
+    getOrdersByUser(uid).then(res => {
       console.log(res);
       this.orderList = res || [];
     });
-  },
+  }
 };
 </script>

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

@@ -76,7 +76,7 @@
 
 <script>
 import { getUser } from "@/api/user";
-import { recharge} from "@/api/recharge";
+import { recharge } from "@/api/recharge";
 
 export default {
   name: "UserCenter",
@@ -91,18 +91,18 @@ export default {
         picture: null,
         balance: 0,
         userRole: "",
-        createTime: "",
+        createTime: ""
       },
       dialog: false,
       showAlert: false,
       value: 0,
-      msg: "",
+      msg: ""
     };
   },
 
   methods: {
     handleRecharge() {
-      recharge({ userId: this.userInfo.id, value: this.value }).then((res) => {
+      recharge({ userId: this.userInfo.id, value: this.value }).then(res => {
         console.log(res);
         if (res && res.code === 1) {
           this.msg = res.msg;
@@ -118,15 +118,15 @@ export default {
 
     refreshUserInfo() {
       const userId = window.localStorage.getItem("userId");
-      getUser(userId).then((res) => {
+      getUser(userId).then(res => {
         this.userInfo = res || {};
       });
-    },
+    }
   },
 
   mounted() {
     this.refreshUserInfo();
-  },
+  }
 };
 </script>
 

+ 6 - 6
src/views/teacher/CourseCreate.vue

@@ -86,14 +86,14 @@ export default {
         intro: "",
         picture: "course1.png",
         school: "",
-        cost: 0,
+        cost: 0
       },
       isCharge: false,
       types: ["初级", "中级", "高级"],
       dialog: false,
       showSuccessDialog: false,
       showFailDialog: false,
-      msg: "",
+      msg: ""
     };
   },
 
@@ -107,10 +107,10 @@ export default {
         teacherId: uid,
         teacherName: uname,
         bought: false,
-        manageable: true,
+        manageable: true
       };
       console.log(payload);
-      createCourse(payload).then((res) => {
+      createCourse(payload).then(res => {
         console.log(res);
         if (res.code === 1) {
           this.showSuccessDialog = true;
@@ -125,8 +125,8 @@ export default {
           }, 1000);
         }
       });
-    },
-  },
+    }
+  }
 };
 </script>
 

+ 13 - 13
src/views/teacher/CourseEdit.vue

@@ -232,7 +232,7 @@ import {
   getCourseWareByCourse,
   createCourseWare,
   updateCourseWare,
-  deleteCourseWare,
+  deleteCourseWare
 } from "@/api/courseWare";
 import { getCourseById } from "@/api/course";
 
@@ -261,15 +261,15 @@ export default {
         freeFlag: false,
         downloadFlag: true,
         availableFlag: false,
-        uploadTime: "",
-      },
+        uploadTime: ""
+      }
     };
   },
 
   computed: {
     isCharge: function() {
       return this.courseInfo.cost !== 0;
-    },
+    }
   },
 
   methods: {
@@ -288,9 +288,9 @@ export default {
           fileSize: res.data.size,
           freeFlag: true,
           downloadFlag: true,
-          availableFlag: true,
+          availableFlag: true
         };
-        createCourseWare(fileInfo).then((res) => {
+        createCourseWare(fileInfo).then(res => {
           console.log(res);
           this.alertMsg = res.msg;
           this.showAlert = true;
@@ -305,7 +305,7 @@ export default {
     refreshFile() {
       const { courseId } = this.$route.params;
       const uid = window.localStorage.getItem("userId");
-      getCourseWareByCourse({ courseId, uid }).then((res) => {
+      getCourseWareByCourse({ courseId, uid }).then(res => {
         this.files = res || [];
       });
     },
@@ -313,20 +313,20 @@ export default {
     loadCourse() {
       const { courseId } = this.$route.params;
       const uid = window.localStorage.getItem("userId");
-      getCourseById({ uid, courseId }).then((res) => {
+      getCourseById({ uid, courseId }).then(res => {
         this.courseInfo = res;
       });
     },
 
     showEditFileDialog(courseWareId) {
-      const currentFile = this.files.find((f) => f.id === courseWareId);
+      const currentFile = this.files.find(f => f.id === courseWareId);
       console.log(currentFile);
       this.currentEditFile = currentFile;
       this.dialog = true;
     },
 
     handleEditSubmit() {
-      updateCourseWare(this.currentEditFile).then((res) => {
+      updateCourseWare(this.currentEditFile).then(res => {
         this.dialog = false;
         console.log(res);
         this.alertMsg = res.msg;
@@ -343,7 +343,7 @@ export default {
     },
 
     handleDeleteCourseWare() {
-      deleteCourseWare(this.currentEditFile.id).then((res) => {
+      deleteCourseWare(this.currentEditFile.id).then(res => {
         this.alertMsg = res.msg;
         this.deleteDialog = false;
         this.dialog = false;
@@ -353,13 +353,13 @@ export default {
           this.showAlert = false;
         }, 1000);
       });
-    },
+    }
   },
 
   mounted() {
     this.refreshFile();
     this.loadCourse();
-  },
+  }
 };
 </script>
 

+ 4 - 4
src/views/teacher/CourseList.vue

@@ -36,22 +36,22 @@ import { getTeacherCourses } from "@/api/course";
 export default {
   name: "CourseList",
   components: {
-    CourseItemTeacher,
+    CourseItemTeacher
   },
   data() {
     return {
       colorList: ["#26A69A", "#00B0FF", "#5C6BC0", "#FFB300", "#E57373"],
-      courseList: null,
+      courseList: null
     };
   },
   mounted() {
     const uid = window.localStorage.getItem("userId");
     if (uid) {
-      getTeacherCourses(uid).then((res) => {
+      getTeacherCourses(uid).then(res => {
         console.log(res);
         this.courseList = res || [];
       });
     }
-  },
+  }
 };
 </script>

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

@@ -76,7 +76,7 @@
 
 <script>
 import { getUser } from "@/api/user";
-import {recharge} from "@/api/recharge";
+import { recharge } from "@/api/recharge";
 
 export default {
   name: "TeacherCenter",
@@ -91,18 +91,18 @@ export default {
         picture: null,
         balance: 0,
         userRole: "",
-        createTime: "",
+        createTime: ""
       },
       dialog: false,
       showAlert: false,
       value: 0,
-      msg: "",
+      msg: ""
     };
   },
 
   methods: {
     handleRecharge() {
-      recharge({ userId: this.userInfo.id, value: this.value }).then((res) => {
+      recharge({ userId: this.userInfo.id, value: this.value }).then(res => {
         console.log(res);
         if (res && res.code === 1) {
           this.msg = res.msg;
@@ -118,15 +118,15 @@ export default {
 
     refreshUserInfo() {
       const userId = window.localStorage.getItem("userId");
-      getUser(userId).then((res) => {
+      getUser(userId).then(res => {
         this.userInfo = res || {};
       });
-    },
+    }
   },
 
   mounted() {
     this.refreshUserInfo();
-  },
+  }
 };
 </script>
 

+ 1 - 1
vue.config.js

@@ -6,7 +6,7 @@ module.exports = {
         // target: "http://courselearning.seec.seecoder.cn/",
         target: "http://localhost:8081",
         ws: true,
-        changeOrigin: true,
+        changeOrigin: true
         // pathRewrite: {
         // '^/api/': '/', // remove base path
         // },