wangwei 4 rokov pred
rodič
commit
5365bfe3e7

+ 3 - 1
src/api/require.js

@@ -1,8 +1,10 @@
 // 导入封装好的网络请求类工具
 import http from './http';
 import urls from './urls'
+
 // 封装各种接口请求
 export default require = {
-  test: (params) => http.get(urls.test_url, params),
+  test: (params) => http.get(urls.login_url, params),
   login: (params) => http.post(urls.login_url, params),
+  register: (params) => http.post(urls.register_url, params),
 }

+ 2 - 1
src/api/urls.js

@@ -1,4 +1,5 @@
-export default urls = {
+export default {
   login_url: '/login',
+  register_url: '/register',
   test_url: '/test',
 }

+ 0 - 2
src/components/Login.vue

@@ -50,8 +50,6 @@ export default {
       // console.log(`init===`, this.$socket.id);
     },
     login() {
-      console.log(`process`, process.env)
-      console.log(`process`, process.env.API_URL)
       const apiurl = process.env.API_URL
       console.log(`apiurl`, apiurl)
       if (this.$socket.id) {

+ 1 - 4
src/store/modules/app/actions.js

@@ -2,13 +2,10 @@
 import require from '@/api/require'
 import { processReturn } from '@/utils/common';
 import { SET_USER, SET_TOKEN, SET_LOADING } from './mutation-types';
-
 const actions = {
   async register({ commit }, payload) {
     commit(SET_LOADING, true);
-    const res = await axios.post('/auth/register', {
-      ...payload,
-    });
+    const res = await require.register({...payload})
     const data = processReturn(res);
     commit(SET_LOADING, false);
     if (data) {