yuantianjiao před 6 roky
rodič
revize
eee3af0ecf

+ 2
- 1
config/index.js Zobrazit soubor

@@ -11,7 +11,8 @@ module.exports = {
11 11
     assetsPublicPath: '/',
12 12
     proxyTable: {
13 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 16
         changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
16 17
         pathRewrite: {
17 18
           '^/api': ''

+ 1
- 1
src/pages/system/cmsManger/newsManger/index.vue Zobrazit soubor

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

+ 3
- 2
src/pages/test/test.vue Zobrazit soubor

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

+ 17
- 2
src/util/ajax.js Zobrazit soubor

@@ -10,8 +10,23 @@ const Axios = axios.create({
10 10
 })
11 11
 
12 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 30
   return config
16 31
 }, (error) => {
17 32
   console.log(error)

+ 2
- 2
src/util/api.js Zobrazit soubor

@@ -3,8 +3,8 @@ const baseUrl = process.env.NODE_ENV === 'development' ? '/api' : 'http://192.16
3 3
 const $api = {
4 4
   test: { // 测试接口
5 5
     area: {
6
-      method: 'get',
7
-      url: `${baseUrl}/common/goodstype`
6
+      method: 'post',
7
+      url: `${baseUrl}/machine/area`
8 8
     }
9 9
   }
10 10
 }