king
2019-09-13 207e7ed3d871717df4a02f9b27792850beebe779
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import axios from 'axios'
 
axios.defaults.crossDomain = true
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
axios.defaults.withCredentials = true
 
axios.interceptors.request.use((config) => {
  config.url = config.url || '/dostar'
  config.method = 'post'
  config.data = config.data || {}
  if (config.url !== '/login') {
    config.data.userid = sessionStorage.getItem('UserID') || ''
  }
  config.data = JSON.stringify(config.data)
  return config
}, (error) => {
  return Promise.reject(error)
})
 
axios.interceptors.response.use((response) => {
  return Promise.resolve(response.data)
}, (error) => {
  return Promise.reject(error)
})
 
class Api {
  constructor() {
    if (process.env.NODE_ENV === 'production') {
      axios.defaults.baseURL = document.location.origin + '/' + window.Glob.Service
    } else {
      axios.defaults.baseURL = 'http://127.0.0.1:8888'
    }
  }
 
  /**
   * @description 登录系统
   */
  loginsystem (username, password) {
    return axios({
      url: '/login',
      data: {
        Username: username,
        Password: password
      }
    })
  }
  
  /**
   * @description 登出系统
   */
  logoutsystem () {
    return axios({
      url: '/dostar',
      data: {
        func: 'logout'
      }
    })
  }
  
  /**
   * @description 重置密码
   */
  resetpassword (originpwd, newpwd) {
    return axios({
      url: '/dostar',
      data: {
        func: 'ResetPassword',
        OriginPwd: originpwd,
        NewPwd: newpwd
      }
    })
  }
 
  /**
   * @description 获取主菜单数据
   */
  getMainMenuData () {
    return axios({
      url: '/dostar',
      data: {
        func: 'GetTopMenus'
      }
    })
  }
 
  /**
   * @description 获取子菜单数据
   * @param {String} menuId 主菜单Id
   */
  getSubMenuData (menuId) {
    return axios({
      url: '/dostar',
      data: {
        func: 'GetSubMenus',
        ParentID: menuId
      }
    })
  }
}
 
export default new Api()