Browse Source

Merge branch 'master' of http://git.cc-lotus.info/new_train/train-student

wuhongyuq 5 years ago
parent
commit
6e0cbe958a

+ 1 - 29
README.md

@@ -1,29 +1 @@
-# train-student
-
-## Project setup
-```
-npm install
-```
-
-### Compiles and hot-reloads for development
-```
-npm run serve
-```
-
-### Compiles and minifies for production
-```
-npm run build
-```
-
-### Run your tests
-```
-npm run test
-```
-
-### Lints and fixes files
-```
-npm run lint
-```
-
-### Customize configuration
-See [Configuration Reference](https://cli.vuejs.org/config/).
+测试openid: 12345678 

File diff suppressed because it is too large
+ 2991 - 2716
package-lock.json


+ 9 - 2
src/App.vue

@@ -10,9 +10,16 @@ export default {
   props: {},
   components: {},
   data: () => ({}),
-  created() {},
+  created() {
+    this.checkOpenid();
+  },
   computed: {},
-  methods: {},
+  methods: {
+    checkOpenid() {
+      const openid = this.$route.query.openid;
+      if (openid) sessionStorage.setItem('openid', openid);
+    },
+  },
 };
 </script>
 

+ 2 - 2
src/layout/common/writeStu.vue

@@ -11,7 +11,7 @@
             placeholder="身份证号"
             :rules="[{ required: true, message: '请填写身份证号' }]"
           />
-          <van-field v-model="form.phone" name="手机号" label="手机号" placeholder="手机号" :rules="[{ required: true, message: '请填写手机号' }]" />
+          <van-field v-model="form.mobile" name="手机号" label="手机号" placeholder="手机号" :rules="[{ required: true, message: '请填写手机号' }]" />
           <div style="margin: 16px;">
             <van-button round block type="info" native-type="submit">
               綁定
@@ -35,7 +35,7 @@ export default {
   computed: {},
   methods: {
     onSubmit() {
-      this.$emit('onSubmit', { data: this.form });
+      this.$emit('onSubmit', this.form);
     },
   },
 };

+ 1 - 1
src/main.js

@@ -2,7 +2,7 @@ import Vue from 'vue';
 import App from './App.vue';
 import router from './router';
 import store from './store';
-import '@/plugins/element.js';
+import '@/plugins/element';
 import '@/plugins/vant';
 import '@/plugins/axios';
 import '@/plugins/check-res';

+ 21 - 2
src/router/index.js

@@ -1,5 +1,6 @@
 import Vue from 'vue';
 import VueRouter from 'vue-router';
+import store from '@/store/index';
 
 Vue.use(VueRouter);
 
@@ -19,9 +20,9 @@ const routes = [
   },
   // 填写学生绑定信息
   {
-    path: '/writeMessage',
+    path: '/bind',
     meta: { title: '填写信息', isleftarrow: true },
-    component: () => import('../views/writeMessage.vue'),
+    component: () => import('../views/bind.vue'),
   },
   // 班级名单
   {
@@ -100,6 +101,13 @@ const routes = [
     meta: { title: '考勤管理', isleftarrow: true },
     component: () => import('../views/user/checkWork.vue'),
   },
+
+  //正在登陆
+  {
+    path: '/login',
+    meta: { title: '登陆中', isleftarrow: true },
+    component: () => import('../views/login.vue'),
+  },
 ];
 
 const router = new VueRouter({
@@ -108,4 +116,15 @@ const router = new VueRouter({
   routes,
 });
 
+router.beforeEach((to, form, next) => {
+  store.commit('setUser');
+  let user = store.state.user;
+  if (user) {
+    console.log('已登录');
+  }
+  //下面是没登录的情况,需要跳转页面到用户未登录页
+  else console.log('未登录');
+  next();
+});
+
 export default router;

+ 0 - 38
src/store/attendance.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  checkInfo: `/api/train/attendance`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.checkInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.checkInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.checkInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.checkInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.checkInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 0 - 48
src/store/group.js

@@ -1,48 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  groupInfo: `/api/train/group`,
-  // insertInfo: `/api/train/group/insert`,
-  // exitInfo: `/api/train/group/exit`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, termid, batchid, classid, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.groupInfo}`, { skip, limit, ...info, termid, batchid, classid });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.groupInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.groupInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.groupInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.groupInfo}/${payload}`);
-    return res;
-  },
-  async insert({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.groupInfo}/insert`, payload);
-    return res;
-  },
-  async exit({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.groupInfo}/exit`, payload);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 17 - 13
src/store/index.js

@@ -1,18 +1,24 @@
 import Vue from 'vue';
 import Vuex from 'vuex';
-import leave from './leave';
-import attendance from './attendance';
-import group from './group';
-import question from './question';
-import questionnaire from './questionnaire';
-import student from './student';
-import lesson from './lesson';
-import teacher from './teacher';
-import score from './score';
-
+import leave from '@frame/store/leave';
+import attendance from '@frame/store/attendance';
+import group from '@frame/store/group';
+import question from '@frame/store/question';
+import questionnaire from '@frame/store/questionnaire';
+import student from '@frame/store/student';
+import lesson from '@frame/store/lesson';
+import teacher from '@frame/store/teacher';
+import score from '@frame/store/score';
+import login from '@frame/store/login';
+import * as ustate from '@frame/store/user/state';
+import * as umutations from '@frame/store/user/mutations';
 Vue.use(Vuex);
 
 export default new Vuex.Store({
+  state: { ...ustate },
+  mutations: { ...umutations },
+  actions: {}, //异步操作
+
   modules: {
     leave,
     attendance,
@@ -23,8 +29,6 @@ export default new Vuex.Store({
     lesson,
     teacher,
     score,
+    login,
   },
-  state: {}, //变量
-  mutations: {}, //同步方法
-  actions: {}, //异步操作
 });

+ 0 - 38
src/store/leave.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  leaveInfo: `/api/train/leave`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.leaveInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.leaveInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.leaveInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.leaveInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.leaveInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 0 - 38
src/store/lesson.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  questionInfo: `/api/train/lesson`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.questionInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.questionInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.questionInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.questionInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.questionInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 0 - 38
src/store/question.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  questionInfo: `/api/train/question`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.questionInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.questionInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.questionInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.questionInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.questionInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 0 - 38
src/store/questionnaire.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  questionnaireInfo: `/api/train/questionnaire`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.questionnaireInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.questionnaireInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.questionnaireInfo}/show/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.questionnaireInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.questionnaireInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 0 - 38
src/store/score.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  scoreInfo: `/api/train/score`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.scoreInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.scoreInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.scoreInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.scoreInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.scoreInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 0 - 38
src/store/student.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  studentInfo: `/api/train/student`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.studentInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.studentInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.studentInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.studentInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.studentInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 0 - 38
src/store/teacher.js

@@ -1,38 +0,0 @@
-import Vue from 'vue';
-import Vuex from 'vuex';
-import _ from 'lodash';
-Vue.use(Vuex);
-const api = {
-  studentInfo: `/api/train/teacher`,
-};
-const state = () => ({});
-const mutations = {};
-
-const actions = {
-  async query({ commit }, { skip = 0, limit, ...info } = {}) {
-    const res = await this.$axios.$get(`${api.studentInfo}`, { skip, limit, ...info });
-    return res;
-  },
-  async create({ commit }, payload) {
-    const res = await this.$axios.$post(`${api.studentInfo}`, payload);
-    return res;
-  },
-  async fetch({ commit }, payload) {
-    const res = await this.$axios.$get(`${api.studentInfo}/${payload}`);
-    return res;
-  },
-  async update({ commit }, { id, ...data }) {
-    const res = await this.$axios.$post(`${api.studentInfo}/update/${id}`, data);
-    return res;
-  },
-  async delete({ commit }, payload) {
-    const res = await this.$axios.$delete(`${api.studentInfo}/${payload}`);
-    return res;
-  },
-};
-export default {
-  namespaced: true,
-  state,
-  mutations,
-  actions,
-};

+ 18 - 6
src/views/writeMessage.vue

@@ -1,5 +1,5 @@
 <template>
-  <div id="writeMessage">
+  <div id="bind">
     <el-row>
       <el-col :span="24" class="info">
         <el-col :span="24" class="top">
@@ -16,9 +16,11 @@
 <script>
 import NavBar from '@/layout/common/topInfo.vue';
 import writeStu from '@/layout/common/writeStu.vue';
-
+import _ from 'lodash';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('login');
 export default {
-  name: 'writeMessage',
+  name: 'bind',
   props: {},
   components: {
     NavBar, //底部信息
@@ -32,10 +34,20 @@ export default {
     navShow: true,
   }),
   created() {},
-  computed: {},
+  computed: {
+    openid() {
+      return this.$route.query.openid;
+    },
+  },
   methods: {
-    onSubmit(form) {
-      console.log(form);
+    ...mapActions(['login', 'bind']),
+    async onSubmit(form) {
+      form.openid = this.openid;
+      let res = await this.bind(form);
+      if (this.$checkRes(res, `绑定成功`)) {
+        sessionStorage.setItem('user', JSON.stringify(res.data));
+        this.$router.push({ path: '/' });
+      }
     },
   },
 };

+ 1 - 0
src/views/index.vue

@@ -24,6 +24,7 @@ import mainData from '@/layout/index/mainData.vue';
 const { mapActions: lesson } = createNamespacedHelpers('lesson');
 import { createNamespacedHelpers, mapGetters } from 'vuex';
 const { mapActions: mapStudent } = createNamespacedHelpers('student');
+
 export default {
   name: 'index',
   props: {},

+ 38 - 0
src/views/login.vue

@@ -0,0 +1,38 @@
+<template>
+  <div id="login">
+    <van-button type="primary" @click="toIndex" v-if="is_dev">去首页(开发用)</van-button>
+  </div>
+</template>
+
+<script>
+const jwt = require('jsonwebtoken');
+
+export default {
+  metaInfo: { title: '正在登陆...' },
+  name: 'login',
+  props: {},
+  components: {},
+  data: () => ({
+    is_dev: process.env.NODE_ENV === 'development',
+  }),
+  created() {
+    this.$toast.loading({
+      message: '登陆中...',
+      duration: 0,
+    });
+    let token = this.$route.query.token;
+    let user = jwt.decode(token);
+    localStorage.setItem('user', JSON.stringify(user));
+    this.$toast.clear();
+    if (!this.is_dev) this.toIndex();
+  },
+  computed: {},
+  methods: {
+    toIndex() {
+      this.$router.push({ path: '/' });
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 4 - 2
src/views/question/index.vue

@@ -21,7 +21,7 @@
 import NavBar from '@/layout/common/topInfo.vue';
 import footInfo from '@/layout/common/footInfo.vue';
 import questionnaireInfo from '@question/src/views/index.vue';
-import { createNamespacedHelpers, mapGetters } from 'vuex';
+import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: mapQuestion } = createNamespacedHelpers('questionnaire');
 export default {
   name: 'index',
@@ -41,7 +41,9 @@ export default {
   created() {
     this.searchNaireList();
   },
-  computed: {},
+  computed: {
+    ...mapState(['user']),
+  },
   mounted() {
     this.title = this.$route.meta.title;
     this.isleftarrow = this.$route.meta.isleftarrow;