yuantianjiao 6 years ago
parent
commit
eee3af0ecf

+ 2
- 1
config/index.js View File

11
     assetsPublicPath: '/',
11
     assetsPublicPath: '/',
12
     proxyTable: {
12
     proxyTable: {
13
       '/api': {
13
       '/api': {
14
-        target: 'http://192.168.0.62:8080/api', // 接口的域名
14
+        target: 'https://dp.huiju360.com.cn/hj_operations',
15
+        // target: 'http://192.168.0.62:8080/api',
15
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
16
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
16
         pathRewrite: {
17
         pathRewrite: {
17
           '^/api': ''
18
           '^/api': ''

+ 1
- 1
src/pages/system/cmsManger/newsManger/index.vue View File

28
         </el-table-column>
28
         </el-table-column>
29
         <el-table-column
29
         <el-table-column
30
           prop="isShow"
30
           prop="isShow"
31
-          label="是否显示">
31
+          label="是否发布">
32
         </el-table-column>
32
         </el-table-column>
33
         <el-table-column
33
         <el-table-column
34
           prop="toIndex"
34
           prop="toIndex"

+ 3
- 2
src/pages/test/test.vue View File

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

+ 17
- 2
src/util/ajax.js View File

10
 })
10
 })
11
 
11
 
12
 Axios.interceptors.request.use((config) => {
12
 Axios.interceptors.request.use((config) => {
13
-  console.log(config)
14
-  config.data = qs.stringify(config.data)
13
+  // 处理请求data,若为get请求,拼到url后面,若为post请求,直接添加到body中
14
+  let data = qs.stringify(config.data)
15
+  if (config.method === 'get' || config.method === 'GET') {
16
+    // 判断是通过斜杠传参还是通过query传参
17
+    if (config.url.indexOf(':') > -1) {
18
+      if (typeof config.data === 'object') {
19
+        config.url = Object.keys(config.data).reduce((url, k) => { // 此方法对每个元素进行处理
20
+          const re = new RegExp(`:${k}(?!w)`, 'i')
21
+          return url.replace(re, config.data[k])
22
+        }, config.url)
23
+      } else {
24
+        config.url = config.url.slice(0, config.url.indexOf(':')) + data
25
+      }
26
+    } else {
27
+      config.url += '?' + data
28
+    }
29
+  }
15
   return config
30
   return config
16
 }, (error) => {
31
 }, (error) => {
17
   console.log(error)
32
   console.log(error)

+ 2
- 2
src/util/api.js View File

3
 const $api = {
3
 const $api = {
4
   test: { // 测试接口
4
   test: { // 测试接口
5
     area: {
5
     area: {
6
-      method: 'get',
7
-      url: `${baseUrl}/common/goodstype`
6
+      method: 'post',
7
+      url: `${baseUrl}/machine/area`
8
     }
8
     }
9
   }
9
   }
10
 }
10
 }