From 2ae9ff51984ab305f81e8e7e24829ac3093c6af1 Mon Sep 17 00:00:00 2001
From: ColorWhiteDeveloper <2632970487@qq.com>
Date: 星期一, 19 九月 2022 13:35:42 +0800
Subject: [PATCH] 封装axios请求

---
 src/utils/request.js                                          |   26 +++-----
 src/views/systemSetting/baseSetting/user/createUser/index.vue |    2 
 src/views/layout/components/AsideBar/index.vue                |   16 +++--
 src/main.js                                                   |   11 ---
 src/views/login/index.vue                                     |    8 +-
 src/views/systemSetting/platform/otherInterface/index.vue     |    5 +
 src/views/systemSetting/platform/portalSetting/index.vue      |    5 +
 src/views/layout/components/Main/index.vue                    |    2 
 src/views/systemSetting/baseSetting/user/index.vue            |   44 ++++++++++++--
 src/router/index.js                                           |   21 ++++--
 10 files changed, 87 insertions(+), 53 deletions(-)

diff --git a/src/main.js b/src/main.js
index 18d7a16..9a5d68f 100644
--- a/src/main.js
+++ b/src/main.js
@@ -12,16 +12,7 @@
 import './assets/icons' 
 // 寮曞叆鍏ㄥ眬鏍峰紡
 import '@/styles/index.scss' 
-import api from "axios"
-api.interceptors.request.use((config)=>{
-  console.log(config);
-  const token = localStorage.getItem('token');
-  const tokenHead = localStorage.getItem('tokenHead');
-    if(token){
-      config.headers.Authorization = tokenHead+token;
-    }
-  return config;
-})
+import api from "./utils/request"
 Vue.prototype.$axios=api
 console.log(process.env.VUE_APP_BASE_API);
 Vue.use(ElementUI)
diff --git a/src/router/index.js b/src/router/index.js
index 7d3de8d..06199da 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -18,14 +18,9 @@
         component: () => import('@/views/systemSetting'),
         children: [
           {
-            path: "createUser",
-            name: "createUser",
-            component: () => import('@/views/systemSetting/baseSetting/user/createUser')
-          },
-          {
-            path: 'userList',
-            name: 'userList',
-            component: () => import('@/views/systemSetting/baseSetting/user/userList')
+            path: "user",
+            name: "user",
+            component: () => import('@/views/systemSetting/baseSetting/user')
           },
           {
             path:'role',
@@ -41,6 +36,16 @@
             path:'department',
             name:'department',
             component: () => import('@/views/systemSetting/baseSetting/department')
+          },
+          {
+            path:'portalSetting',
+            name:'portalSetting',
+            component: () => import('@/views/systemSetting/platform/portalSetting')
+          },
+          {
+            path:'otherInterface',
+            name:'otherInterface',
+            component: () => import('@/views/systemSetting/platform/otherInterface')
           }
         ]
       },
diff --git a/src/utils/request.js b/src/utils/request.js
index 78d1d8d..bd96090 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -1,25 +1,19 @@
 import axios from 'axios';
-const service = axios.create({
+const api = axios.create({
     baseURL: 'http://42.193.1.25:8082/', // 璇锋眰鐨勫叕鍏卞湴鍧�閮ㄥ垎
 })
 // 鎷︽埅鍣�
 // 璇锋眰
-service.interceptors.request.use(
-  // 璇锋眰涔嬪墠鐨勫洖璋冨嚱鏁�
-  function (config) {
-    const token = localStorage.getItem('token');
-    if(token){
-      config.headers.authentication = token;
+api.interceptors.request.use((config)=>{
+  const token = localStorage.getItem('token');
+  const tokenHead = localStorage.getItem('tokenHead');
+    if(token && tokenHead){
+      config.headers.Authorization = tokenHead+token;
     }
-    return config;
-  },
-  function (error) {
-    // Do something with request error
-    return Promise.reject(error);
-  }
-);
+  return config;
+})
 // 鍝嶅簲
-service.interceptors.response.use(
+api.interceptors.response.use(
   function (response) {
     return response.data;
   },
@@ -27,4 +21,4 @@
     return Promise.reject(error);
   }
 );  
-export default service;
\ No newline at end of file
+export default api;
\ No newline at end of file
diff --git a/src/views/layout/components/AsideBar/index.vue b/src/views/layout/components/AsideBar/index.vue
index e40732e..b4bbb39 100644
--- a/src/views/layout/components/AsideBar/index.vue
+++ b/src/views/layout/components/AsideBar/index.vue
@@ -27,10 +27,7 @@
             {
               name: "鍩虹璁剧疆", index: '/home/system/base', children: [
                 {
-                  name: '鐢ㄦ埛绠$悊', index: '/home/system/userList',
-                },
-                {
-                  name: '鏂板鐢ㄦ埛', index: '/home/system/createUser',
+                  name: '鐢ㄦ埛绠$悊', index: '/home/system/user',
                 },
                 {
                   name:'瑙掕壊绠$悊', index:'/home/system/role',
@@ -43,7 +40,14 @@
                 }
               ]
             },
-            { name: "骞冲彴璁剧疆", index: "/home/system/plateform", children: [] },
+            { name: "骞冲彴璁剧疆", index: "/home/system/plateform", children: [
+              {
+                name:'闂ㄦ埛璁剧疆',index:'/home/system/portalSetting'
+              },
+              {
+                name:'绗笁鏂规帴鍙g鐞�',index:'/home/system/otherInterface'
+              }
+            ] },
           ],
         }
       ],
@@ -65,11 +69,9 @@
       this.asideList = null;
       menu.forEach(item => {
         if (path.indexOf(item.name) !== -1) {
-          console.log(item.children);
           that.asideList = item.children;
         }
       })
-      console.log(this.asideList);
     },
     Jump(path) {
       this.$router.push(path);
diff --git a/src/views/layout/components/Main/index.vue b/src/views/layout/components/Main/index.vue
index 26fbaa5..f5301df 100644
--- a/src/views/layout/components/Main/index.vue
+++ b/src/views/layout/components/Main/index.vue
@@ -26,7 +26,7 @@
   padding: 0;
   .content {
     background-color: #f0f2f5;
-    padding: 20px 40px;
+    padding: 11px;
   }
 }
 </style>
diff --git a/src/views/login/index.vue b/src/views/login/index.vue
index ee4f317..d33b057 100644
--- a/src/views/login/index.vue
+++ b/src/views/login/index.vue
@@ -107,17 +107,17 @@
       const { username, password } = this.loginForm;
       const that = this;
       this.$axios
-        .post("http://42.193.1.25:8082/sccg/admin/login", {
+        .post("sccg/admin/login", {
           password,
           username,
         })
         .then(function (response) {
-          if (response.data.code === 200) {
+          if (response.code === 200) {
             // 淇濆瓨token
             console.log(response);
-            localStorage.setItem('token',response.data.data.token);
+            localStorage.setItem('token',response.data.token);
             // 淇濆瓨token
-            localStorage.setItem('tokenHead',response.data.data.tokenHead)
+            localStorage.setItem('tokenHead',response.data.tokenHead)
             // 璺宠浆鍒伴椤�
             that.$router.push("/home");
           }else{
diff --git a/src/views/systemSetting/baseSetting/user/createUser/index.vue b/src/views/systemSetting/baseSetting/user/createUser/index.vue
index c70b8e7..ff39f08 100644
--- a/src/views/systemSetting/baseSetting/user/createUser/index.vue
+++ b/src/views/systemSetting/baseSetting/user/createUser/index.vue
@@ -269,7 +269,7 @@
         }
     },
     created() { 
-        this.$axios.get("http://42.193.1.25:8082/sccg/role/listAll").then(res=>{
+        this.$axios.get("sccg/role/listAll").then(res=>{
             console.log(res);
         });
     },
diff --git a/src/views/systemSetting/baseSetting/user/userList/index.vue b/src/views/systemSetting/baseSetting/user/index.vue
similarity index 76%
rename from src/views/systemSetting/baseSetting/user/userList/index.vue
rename to src/views/systemSetting/baseSetting/user/index.vue
index 1a3b79f..f559c55 100644
--- a/src/views/systemSetting/baseSetting/user/userList/index.vue
+++ b/src/views/systemSetting/baseSetting/user/index.vue
@@ -8,7 +8,10 @@
                     <el-input placeholder="璇疯緭鍏ュ唴瀹�"></el-input>
                 </div>
                 <div class="addUser">
-                    <el-button type="primary">娣诲姞鐢ㄦ埛</el-button>
+                    <el-button type="primary" @click="dialogVisible = true">娣诲姞鐢ㄦ埛</el-button>
+                    <el-dialog :visible.sync="dialogVisible" width="45%">
+                        <createUser />
+                    </el-dialog>
                 </div>
             </div>
         </header>
@@ -45,8 +48,13 @@
                     </el-table-column>
                     <el-table-column prop="operation" label="鎿嶄綔" width="246">
                         <template slot-scope="scope">
-                            <el-button size="mini">缂栬緫</el-button>
-                            <el-button size="mini" type="danger">鍒犻櫎</el-button>
+                            <div class="operation">
+                                <span>淇敼瑙掕壊</span>
+                                <span>鏌ョ湅</span>
+                                <span>淇敼瀵嗙爜</span>
+                                <span>鍒犻櫎</span>
+                                <span>淇敼閮ㄩ棬</span>
+                            </div>
                         </template>
                     </el-table-column>
                 </el-table>
@@ -55,7 +63,11 @@
     </div>
 </template>
 <script>
+import createUser from "./createUser"
 export default {
+   components:{
+    createUser
+   },
     data() {
         return {
             tableData: [
@@ -66,9 +78,18 @@
                     role: '瓒呯骇绠$悊鍛�',
                     is_open: true,
                 }
-            ]
+            ],
+            dialogVisible:false,
         }
     },
+    created(){
+        // 鑾峰彇褰撳墠鐢ㄦ埛鐧诲綍淇℃伅
+        this.$axios.get(
+            'sccg/admin/info'
+        ).then(res=>{
+            console.log(res);
+        })
+    }
 }
 </script>
 <style lang="scss" scoped>
@@ -112,12 +133,23 @@
         background-color: #fff;
         margin-top: 20px;
         padding: 0 10px;
-
+        padding-bottom: 50px;
         .mainTitle {
             line-height: 60px;
         }
-        .el-table{
+
+        .el-table {
             font-size: 10px;
+
+            .operation {
+                display: flex;
+                justify-content: space-around;
+                color: #0079fe;
+
+                span:hover {
+                    cursor: pointer;
+                }
+            }
         }
     }
 }
diff --git a/src/views/systemSetting/platform/otherInterface/index.vue b/src/views/systemSetting/platform/otherInterface/index.vue
new file mode 100644
index 0000000..8b407a0
--- /dev/null
+++ b/src/views/systemSetting/platform/otherInterface/index.vue
@@ -0,0 +1,5 @@
+<template>
+    <div>
+        
+    </div>
+</template>
\ No newline at end of file
diff --git a/src/views/systemSetting/platform/portalSetting/index.vue b/src/views/systemSetting/platform/portalSetting/index.vue
new file mode 100644
index 0000000..8b407a0
--- /dev/null
+++ b/src/views/systemSetting/platform/portalSetting/index.vue
@@ -0,0 +1,5 @@
+<template>
+    <div>
+        
+    </div>
+</template>
\ No newline at end of file

--
Gitblit v1.8.0