lrf 11 tháng trước cách đây
mục cha
commit
0fbce91033
2 tập tin đã thay đổi với 50 bổ sung3 xóa
  1. 47 0
      src/store/exam/examinee.js
  2. 3 3
      src/store/login.js

+ 47 - 0
src/store/exam/examinee.js

@@ -0,0 +1,47 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/examinee`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.interface}`, {
+      skip,
+      limit,
+      ...info,
+    });
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    console.log(payload);
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async update({ commit }, { _id, ...info } = {}) {
+    const res = await this.$axios.$post(`${api.interface}/update/${_id}`, info);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+  async getExam({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}/getExamQuestion`, payload);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 3 - 3
src/store/login.js

@@ -9,11 +9,11 @@ const state = () => ({});
 const mutations = {};
 
 const actions = {
-  async login({ commit }, { table, phone, password, openid }) {
+  async login({ commit }, { table, phone, password, type, openid }) {
     let body = {};
     if (openid) body.openid = openid;
-    else body = { phone, password };
-    const res = await this.$axios.$post(`${api.uri}/${table}`, body);
+    else body = { phone, password, type };
+    const res = await this.$axios.$post(`${api.uri}`, body);
     if (res.errcode === 0) {
       const token = res.data;
       if (localStorage) localStorage.setItem('token', token);