HZH 4 years ago
parent
commit
154fcd2310

+ 3 - 2
src/App.vue

@@ -7,9 +7,7 @@
 </style>
 
 <template>
-  <div id="app">
     <router-view></router-view>
-  </div>
 </template>
 
 <script>
@@ -22,5 +20,8 @@ export default {
     return {
 	  }
   },
+  created() {
+    console.log('fsdf')
+  }
 }
 </script>

+ 0 - 21
src/api/ctrlPaper.js

@@ -1,21 +0,0 @@
-import axios from 'axios';
-
-//获取某学生所有做过的试卷
-export function getCommitPaperList() {
-    return axios.get('/paper/listPaperCommit',{
-        params: {
-        }
-    })
-    .then(res => res.data);
-}
-
-//获取简单结果列表所有做过的试卷
-export function getCommitPaperListSimple(uid,pid) {
-    return axios.get('/paperResult/listSimpleResult',{
-        params: {
-            uid:uid,
-            pid:pid
-        }
-    })
-    .then(res => res.data);
-}

+ 0 - 75
src/api/exam.js

@@ -1,75 +0,0 @@
-import axios from 'axios';
-
-//获取测试卷列表
-export function getPaperList(status,subjectId) {
-    return axios.get('/paper/listPapers',{
-        params: {
-            status: status,
-            subjectId: subjectId
-        }
-    })
-    .then(res => res.data);
-}
-
-//新增试卷
-export function addPaper(paper) {
-    return axios({
-        method: 'post',
-        url: '/paper/uploadPaper',
-        data: paper
-    }).then(res => res.data)
-}
-
-//修改试卷参数
-export function updatePaper(paper) {
-    return axios({
-        method: 'post',
-        url: '/paper/updateParams',
-        data: paper
-    }).then(res => res.data)
-}
-
-//修改试题
-export function updateQuestion(question) {
-    return axios({
-        method: 'post',
-        url: '/question/updateQuestionForPaper',
-        data: question
-    }).then(res => res.data)
-}
-
-//删除试卷
-export function deletePaper(id) {
-    return axios({
-        method: 'post',
-        url: '/paper/delete',
-        params: {id: id}
-    }).then(res => res)
-}
-
-//获取单张试卷
-export function getPaperById(id) {
-    return axios.get('/paper/getOnePaper/'+id)
-    .then(res => res.data);
-}
-
-//检测是否已经测试
-export function checkFirstTest(pid,uid) {
-    return axios.get('/paper/hasCommit',{
-        params: {
-            pid: pid,
-            uid: uid,
-        }
-    })
-    .then(res => res.data);
-}
-
-//提交答题试卷
-export function commitPaper(paper) {
-    return axios({
-        method: 'post',
-        url: '/paper/commit',
-        data: paper
-    })
-        .then(res => res.data)
-}

+ 5 - 5
src/api/login.js

@@ -23,6 +23,11 @@ export function login({username, password,loginFrom}) {
     }).then(res => res.data)
 }
 
+//获取当前身份
+export function getLoginUser(){
+    return axios.get('/user/cur').then(result => result.data)
+}
+
 //验证身份唯一
 export function checkOnly(name){
     return axios.get('/open/user/checkUsername?username=' + name).then(result => result.data)
@@ -37,11 +42,6 @@ export function register(reg) {
     }).then(res => res.data)
 }
 
-//获取当前身份
-export function getLoginUser(){
-    return axios.get('/self/info').then(result => result.data)
-}
-
 //登出
 export function logout() {
     return axios.get('/logout').then(res => res.data);

+ 48 - 0
src/api/month.js

@@ -0,0 +1,48 @@
+import axios from 'axios';
+
+//登录
+export function login({username, password,loginFrom}) {
+    return axios({
+        method: 'post',
+        url: '/login',
+        data: {
+            username,
+            password,
+            loginFrom
+        },
+        transformRequest: [function(data) {
+            let ret = ''
+            for (let it in data) {
+                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
+            }
+            return ret;
+        }],
+        headers: {
+            // 'Content-Type': 'application/x-www-form-urlencoded'
+        }
+    }).then(res => res.data)
+}
+
+//获取当前身份
+export function getLoginUser(){
+    return axios.get('/user/cur').then(result => result.data)
+}
+
+//验证身份唯一
+export function checkOnly(name){
+    return axios.get('/open/user/checkUsername?username=' + name).then(result => result.data)
+}
+
+//注册
+export function register(reg) {
+    return axios({
+        method: 'post',
+        url: '/open/user/register',
+        data: reg
+    }).then(res => res.data)
+}
+
+//登出
+export function logout() {
+    return axios.get('/logout').then(res => res.data);
+}

+ 48 - 0
src/api/quarter.js

@@ -0,0 +1,48 @@
+import axios from 'axios';
+
+//登录
+export function login({username, password,loginFrom}) {
+    return axios({
+        method: 'post',
+        url: '/login',
+        data: {
+            username,
+            password,
+            loginFrom
+        },
+        transformRequest: [function(data) {
+            let ret = ''
+            for (let it in data) {
+                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
+            }
+            return ret;
+        }],
+        headers: {
+            // 'Content-Type': 'application/x-www-form-urlencoded'
+        }
+    }).then(res => res.data)
+}
+
+//获取当前身份
+export function getLoginUser(){
+    return axios.get('/user/cur').then(result => result.data)
+}
+
+//验证身份唯一
+export function checkOnly(name){
+    return axios.get('/open/user/checkUsername?username=' + name).then(result => result.data)
+}
+
+//注册
+export function register(reg) {
+    return axios({
+        method: 'post',
+        url: '/open/user/register',
+        data: reg
+    }).then(res => res.data)
+}
+
+//登出
+export function logout() {
+    return axios.get('/logout').then(res => res.data);
+}

+ 0 - 73
src/api/report.js

@@ -1,73 +0,0 @@
-import axios from 'axios';
-
-//获取报告中用户的个人信息,paperResultId为报告结果Id
-export function getReportUserInfo(pid,uid) {
-    return axios.get('/report/userInfo',{
-        params: {
-            pid: pid,
-            uid: uid
-        }
-    })
-    .then(res => res.data);
-}
-
-//诊断结果
-export function getGlobalResult(paperResultId) {
-    return axios.get('/report/globalResult',{
-        params: {
-            paperResultId: paperResultId,
-        }
-    })
-    .then(res => res.data);
-}
-
-//获取作答时间及平均作答时间
-export function getReportUserTime(pid,uid) {
-    return axios.get('/report/useTime',{
-        params: {
-            pid: pid,
-            uid: uid
-        }
-    })
-    .then(res => res.data);
-}
-
-export function getSpecialReport(pid,uid,resultId) {
-    if(resultId){
-        return axios.get('/specialReport/generate1',{
-            params: {
-                resultId: resultId,
-            }
-        })
-        .then(res => res.data);
-    }
-    else{
-        return axios.get('/specialReport/generate',{
-            params: {
-                pid: pid,
-                uid: uid
-            }
-        })
-        .then(res => res.data);
-    }
-}
-
-export function generateMind(pid,uid,resultId) {
-    if(resultId){
-        return axios.get('/specialReport/generateMind1',{
-            params: {
-                resultId: resultId,
-            }
-        })
-        .then(res => res.data);
-    }
-    else{
-        return axios.get('/specialReport/generateMind',{
-            params: {
-                pid: pid,
-                uid: uid
-            }
-        })
-        .then(res => res.data);
-    }
-}

+ 0 - 39
src/api/user.js

@@ -1,39 +0,0 @@
-import axios from 'axios';
-
-//获取用户列表
-export function getUserList(grade,username) {
-    return axios.get('/user/listStudent',{
-        params: {
-            grade: grade,
-            username: username
-        }
-    })
-    .then(res => res.data);
-}
-
-//新增用户
-export function addUser(user) {
-    return axios({
-        method: 'post',
-        url: '/user/addStudent',
-        data: user
-    }).then(res => res.data)
-}
-
-//修改用户
-export function updateUser(user) {
-    return axios({
-        method: 'post',
-        url: '/user/updatePassword',
-        data: user
-    }).then(res => res.data)
-}
-
-//删除用户
-export function deleteUser(uid) {
-    return axios({
-        method: 'post',
-        url: '/user/deleteStudent',
-        params: {uid: uid}
-    }).then(res => res)
-}

+ 47 - 0
src/api/year.js

@@ -0,0 +1,47 @@
+import axios from 'axios';
+//获取列表
+export function getLoginUser(){
+    return axios.get('/user/cur').then(result => result.data)
+}
+
+//登录
+export function login({username, password,loginFrom}) {
+    return axios({
+        method: 'post',
+        url: '/login',
+        data: {
+            username,
+            password,
+            loginFrom
+        },
+        transformRequest: [function(data) {
+            let ret = ''
+            for (let it in data) {
+                ret += encodeURIComponent(it) + '=' + encodeURIComponent(data[it]) + '&'
+            }
+            return ret;
+        }],
+        headers: {
+            // 'Content-Type': 'application/x-www-form-urlencoded'
+        }
+    }).then(res => res.data)
+}
+
+//验证身份唯一
+export function checkOnly(name){
+    return axios.get('/open/user/checkUsername?username=' + name).then(result => result.data)
+}
+
+//注册
+export function register(reg) {
+    return axios({
+        method: 'post',
+        url: '/open/user/register',
+        data: reg
+    }).then(res => res.data)
+}
+
+//登出
+export function logout() {
+    return axios.get('/logout').then(res => res.data);
+}

+ 1 - 0
src/components/MainPage/Task/Year.vue

@@ -74,6 +74,7 @@ table{
 </template>
 
 <script>
+import { login } from '@/api/login';
 export default {
   name: 'Year',
   components: {

+ 2 - 2
src/login/Login.vue

@@ -111,11 +111,11 @@
                 login({
                     username:this.username,
                     password:this.password,
-                    loginFrom: 'admin'
+                    loginFrom: 'student'
                 })
                 .then(res => {
                     if (res && res.ok == '1')  {
-                        this.$router.replace({name: 'ControlApp'});
+                        this.$router.replace({name: 'App'});
                     } else {
                         this.error = true;
                     }

+ 8 - 8
src/router/index.js

@@ -25,14 +25,14 @@ export default new Router({
         path: '/app',
         name: 'App',
         component: App,
-        // beforeEnter: (to, from, next) => {
-        //     getLoginUser().then(data => {
-        //         store.dispatch('setLoginUser', data);
-        //         next();
-        //     }).catch(() => {
-        //         next({name: 'Index'});
-        //     })
-        // },
+        beforeEnter: (to, from, next) => {
+            getLoginUser().then(data => {
+                store.dispatch('setLoginUser', data);
+                next();
+            }).catch(() => {
+                next({name: 'Login'});
+            })
+        },
         redirect: { name: 'MainPage' },
         children: [{
             path: 'mainPage',