11import * as types from './mutation-types'
2+ import { Message } from 'element-ui'
23
34/**
45 * [setMainData 设置主通信数据]
@@ -7,14 +8,8 @@ import * as types from './mutation-types'
78export const setMainData = ( { commit, state } , mainData ) => {
89 commit ( types . SET_MAIN_DATA , mainData )
910}
10- export const MessageInfo = ( message , data ) => {
11- message ( {
12- message : data . message ,
13- type : data . type ,
14- } )
15- }
1611/* 公共post请求方法 */
17- export const getData = ( { commit, state } , { apiUrl = state . apiUrl , postData = null , thenFunction = null , catchFunction = null , message = null } ) => {
12+ export const getData = ( { commit, state } , { apiUrl = state . apiUrl , postData = null , thenFunction = null , catchFunction = null } ) => {
1813 let token_type = localStorage . getItem ( 'token_type' )
1914 let access_token = localStorage . getItem ( 'access_token' )
2015 let refresh_token = localStorage . getItem ( 'refresh_token' )
@@ -28,21 +23,25 @@ export const getData = ({ commit,state },{apiUrl = state.apiUrl, postData = null
2823 if ( thenFunction ) {
2924 thenFunction ( Response )
3025 }
31- if ( message && Response . data . message ) {
32- MessageInfo ( message , Response . data . message )
26+ let message = Response . data . message
27+ if ( message ) {
28+ Message ( {
29+ message : message . message ,
30+ type : message . type ,
31+ } )
3332 }
3433 } )
35- . catch ( function ( error ) {
34+ . catch ( ( error ) => {
3635 if ( catchFunction ) {
3736 catchFunction ( error )
3837 } else {
3938 commit ( types . CALLBACK_ERROR , error )
40- }
41- if ( message ) {
42- MessageInfo ( message , {
43- message : '操作失败请联系管理员!' ,
44- type : ' error' ,
45- } )
39+ // console.log(error)
40+ // console.log(error. message)
41+ // console.log(error.config)
42+ // console.log(error.code)
43+ // console.log( error.request)
44+ console . log ( error . response )
4645 }
4746 } )
4847}
0 commit comments