king
2019-09-20 4e837faa0307fda4d0d3bd463c88a7ef43817443
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import axios from 'axios'
 
axios.defaults.crossDomain = true
axios.defaults.headers.common['token'] = 'token'
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
      }
    })
  }
 
  /**
   * @description 获取页面配置信息
   * @param {String} MenuNo 页面菜单参数
   */
  getMainConfigsData (MenuNo) {
    return axios({
      url: '/dostar',
      data: {
        func: 'GetMainConfigs',
        MenuNo: MenuNo
      }
    })
  }
 
  /**
   * @description 获取页面列表数据
   * @param {String} MenuNo 页面菜单参数
   */
  getMainTableData (MenuNo, pageIndex = 1, pageSize = 10, orderColumn = '', orderType = '', search) {
    return axios({
      url: '/dostar',
      data: {
        func: 'GetMainData',
        MenuNo: MenuNo,
        PageIndex: pageIndex,
        PageSize: pageSize,
        orderColumn: orderColumn,
        orderType: orderType,
        search: search
      }
    })
  }
}
 
export default new Api()