yuantianjiao 6 years ago
parent
commit
2b33792925
5 changed files with 22 additions and 16 deletions
  1. 5
    4
      config/index.js
  2. 4
    4
      src/pages/test/test.vue
  3. 6
    0
      src/router/router.js
  4. 3
    3
      src/util/ajax.js
  5. 4
    5
      src/util/api.js

+ 5
- 4
config/index.js View File

11
     assetsPublicPath: '/',
11
     assetsPublicPath: '/',
12
     proxyTable: {
12
     proxyTable: {
13
       '/api': {
13
       '/api': {
14
-        target: 'https://dp.huiju360.com.cn/hj_operations',
14
+        // target: 'https://dp.huiju360.com.cn/hj_operations',
15
         // target: 'http://192.168.0.62:8080/api',
15
         // target: 'http://192.168.0.62:8080/api',
16
+        target: 'http://192.168.0.11:8088', //zys
16
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
17
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
17
-        pathRewrite: {
18
-          '^/api': ''
19
-        },
18
+        // pathRewrite: {
19
+        //   '^/api': 'api'
20
+        // },
20
       },
21
       },
21
     },
22
     },
22
     // Various Dev Server settings
23
     // Various Dev Server settings

+ 4
- 4
src/pages/test/test.vue View File

15
   },
15
   },
16
   mounted () {
16
   mounted () {
17
     console.log(this)
17
     console.log(this)
18
-    this.$ajax(this.$api.test.area.url, {
19
-      method: this.$api.test.area.method,
18
+    this.$ajax(this.$api.test.signin.url, {
19
+      method: this.$api.test.signin.method,
20
       data: {
20
       data: {
21
-        caseid: 1,
22
-        id: 2
21
+        userName: 1,
22
+        passWord: 2
23
       }
23
       }
24
     })
24
     })
25
       .then(res => {
25
       .then(res => {

+ 6
- 0
src/router/router.js View File

1
 import login from '@/pages/login/index'
1
 import login from '@/pages/login/index'
2
 import system from '@/pages/system/page'
2
 import system from '@/pages/system/page'
3
+import test from '@/pages/test/test'
3
 
4
 
4
 const routerArr = [
5
 const routerArr = [
5
   {
6
   {
8
     component: login
9
     component: login
9
   },
10
   },
10
   ...system.router,
11
   ...system.router,
12
+  {
13
+    path: '/test',
14
+    name: 'test',
15
+    component: test
16
+  }
11
 ]
17
 ]
12
 
18
 
13
 export default routerArr
19
 export default routerArr

+ 3
- 3
src/util/ajax.js View File

34
 
34
 
35
 Axios.interceptors.response.use((res) => {
35
 Axios.interceptors.response.use((res) => {
36
   console.log(res)
36
   console.log(res)
37
-  if (res.status === 200) {
38
-    return res.data
37
+  if (res.data.code === 200) {
38
+    return res.data.result
39
   } else {
39
   } else {
40
     Message({
40
     Message({
41
-      message: res.data.msg,
41
+      message: res.data.message,
42
       type: 'error'
42
       type: 'error'
43
     })
43
     })
44
     return res.data
44
     return res.data

+ 4
- 5
src/util/api.js View File

1
-const baseUrl = process.env.NODE_ENV === 'development' ? '/api' : 'http://192.168.0.62:8080/api'
2
-// const baseUrl = '/check-api'
1
+const baseUrl = '/api'
3
 const $api = {
2
 const $api = {
4
-  test: { // 测试接口
5
-    area: {
3
+  test: { // 登陆
4
+    signin: {
6
       method: 'post',
5
       method: 'post',
7
-      url: `${baseUrl}/machine/area`
6
+      url: `${baseUrl}/guest/signin`
8
     }
7
     }
9
   }
8
   }
10
 }
9
 }