yuantianjiao 6 年之前
父節點
當前提交
dfabdc80ab
共有 5 個檔案被更改,包括 30 行新增19 行删除
  1. 9
    4
      config/index.js
  2. 3
    4
      src/main.js
  3. 6
    11
      src/pages/test/test.vue
  4. 1
    0
      src/util/ajax.js
  5. 11
    0
      src/util/api.js

+ 9
- 4
config/index.js 查看文件

@@ -6,12 +6,18 @@ const path = require('path')
6 6
 
7 7
 module.exports = {
8 8
   dev: {
9
-
10 9
     // Paths
11 10
     assetsSubDirectory: 'static',
12 11
     assetsPublicPath: '/',
13
-    proxyTable: {},
14
-
12
+    proxyTable: {
13
+      '/api': {
14
+        target: 'https://dp.huiju360.com.cn/hj_operations', // 接口的域名
15
+        changeOrigin: true, // 如果接口跨域,需要进行这个参数配置
16
+        pathRewrite: {
17
+          '^/api': ''
18
+        },
19
+      },
20
+    },
15 21
     // Various Dev Server settings
16 22
     host: '0.0.0.0', // can be overwritten by process.env.HOST
17 23
     port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
@@ -39,7 +45,6 @@ module.exports = {
39 45
     // set this to false - it *may* help
40 46
     // https://vue-loader.vuejs.org/en/options.html#cachebusting
41 47
     cacheBusting: true,
42
-
43 48
     cssSourceMap: true
44 49
   },
45 50
 

+ 3
- 4
src/main.js 查看文件

@@ -6,12 +6,11 @@ import ElementUI from 'element-ui'
6 6
 import 'element-ui/lib/theme-chalk/index.css'
7 7
 import router from './router'
8 8
 import Ajax from './util/ajax'
9
-
9
+import api from './util/api'
10 10
 Vue.use(ElementUI)
11
-
12 11
 Vue.config.productionTip = false
13
-const http = new Ajax()
14
-Vue.prototype.$ajax = http
12
+Vue.prototype.$api = api
13
+Vue.prototype.$ajax = Ajax
15 14
 /* eslint-disable no-new */
16 15
 new Vue({
17 16
   el: '#app',

+ 6
- 11
src/pages/test/test.vue 查看文件

@@ -14,22 +14,17 @@ export default {
14 14
     }
15 15
   },
16 16
   mounted () {
17
-    this.$ajax('', {
18
-      method: this.$api.order.orderPage.method,
17
+    console.log(this)
18
+    this.$ajax(this.$api.test.area.url, {
19
+      method: 'GET',
19 20
       data: {
20
-        orderState: status,
21
-        base_pageSize: this.orderData[this.status].base_pageSize,
22
-        base_currentPage: this.orderData[this.status].base_currentPage
21
+        a: 1,
22
+        b: 2
23 23
       }
24 24
     })
25 25
       .then(res => {
26
-
26
+        console.log(res)
27 27
       }).catch(msg => {
28
-        this.$toast({
29
-          message: msg.data.message,
30
-          position: 'center',
31
-          duration: 2000
32
-        })
33 28
         return false
34 29
       })
35 30
   }

+ 1
- 0
src/util/ajax.js 查看文件

@@ -10,6 +10,7 @@ const Axios = axios.create({
10 10
 })
11 11
 
12 12
 Axios.interceptors.request.use((config) => {
13
+  console.log(config)
13 14
   config.data = qs.stringify(config.data)
14 15
   return config
15 16
 }, (error) => {

+ 11
- 0
src/util/api.js 查看文件

@@ -0,0 +1,11 @@
1
+const baseUrl = process.env.NODE_ENV === 'development' ? '/api' : 'https://dp.huiju360.com.cn/hj_operations'
2
+// const baseUrl = '/check-api'
3
+const $api = {
4
+  test: { // 测试接口
5
+    area: {
6
+      method: 'get',
7
+      url: `${baseUrl}/machine/area`
8
+    }
9
+  }
10
+}
11
+export default $api