Browse Source

登陆功能完成

caipin 5 năm trước cách đây
mục cha
commit
254cb6de6f
3 tập tin đã thay đổi với 12 bổ sung18 xóa
  1. 1 1
      config/webpack.prod.config.js
  2. 9 3
      src/common/axios_auth.js
  3. 2 14
      src/login/store/actionCreators.js

+ 1 - 1
config/webpack.prod.config.js

@@ -134,7 +134,7 @@ module.exports = merge(common, {
     new HtmlWebpackPlugin({
       template: 'public/index.html',
       filename: 'index.html',
-      chunks: ['login', 'framework'],
+      chunks: ['workbench', 'framework'],
       // inject: 'body',
       // minify: {
       //   removeComments: true,

+ 9 - 3
src/common/axios_auth.js

@@ -41,8 +41,14 @@ axios.interceptors.request.use(config => {
 // respone拦截器
 axios.interceptors.response.use(
     response => {
-        // const res = response.data;
- 
+        const res = response.data;
+
+        if(res.code===201||res.code===202){
+            window.location.href = '/login.html';
+        }else{
+            return response
+        }
+        
         // //这里根据后台返回来设置
         // if (res.msg === "success") {
         //     return response.data;
@@ -51,7 +57,7 @@ axios.interceptors.response.use(
         // }
         //window.location.href = '/login';
 
-        return response
+        
     },
     error => {
         return Promise.reject(error)

+ 2 - 14
src/login/store/actionCreators.js

@@ -35,21 +35,9 @@ export const login = (parameter) => {
         }).then((res) => {
             const data = res.data;
             if (data.code === 200) {
-
-                //window.location.href = '/contact/company';
-                //let d2=JSON.parse(data.list);
-                // console.log(data.data);
-                // dispatch(changeList(data.data));
-                //dispatch(changeList(JSON.parse(data.list)));
-                // dispatch({
-                //     type: constants.CHANGE_CLIENT_DATA,
-                //     data: fromJS(d2),
-                // });
-            } else {
-                console.log(data);
-            }
+                window.location.href = '/contact/company';
+            } 
         }).catch((e) => {
-            console.log(e);
             console.log('error');
         })
     }