Blame view

admin-web-master/src/views/aaa/components/canvasShow/config/mixin/sendReqMixin.js 786 Bytes
3f535f30   杨鑫   '初始'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  /*
   * 发送请求 mixin
   */
  import request from './server'
  
  /* eslint-disable */
  export const sendReq = {
    data () {
      return {
        // 加载中
        loading: false,
      }
    },
    methods: {
      /*
       * 发送请求
       */
      sendReq (params, callback, errorCallback) {
        let self = this
        request({
          method: params.method || 'POST',
          url: params.url,
          data: params.data || {},
          withCredentials : true,
          headers: {
            'Content-type': params.contentType || 'application/json;charset=utf-8'
          }
        }).then((res) => {
          if (res && res.data) {
            callback && callback(res.data)
          }
        }).catch(err => {
          if (err) {
            errorCallback && errorCallback(err)
          }
        })
      }
    }
  }