user.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  1. import request from '@/utils/request'
  2. import qs from 'qs'
  3. import {
  4. getToken
  5. } from '@/utils/auth'
  6. import {
  7. method
  8. } from 'lodash';
  9. export const getUsers = (params) => {
  10. return new request({
  11. url: './sys/authUsers',
  12. method: 'get',
  13. params: params
  14. });
  15. }
  16. export const updatePwd = (params, token) => {
  17. return new request({
  18. url: './sys/authUsers/updatePwd',
  19. method: 'post',
  20. headers: {
  21. token
  22. },
  23. data: qs.stringify(Object.assign({
  24. rm: 1,
  25. }, params))
  26. });
  27. }
  28. export const updatePwdLogout = () => {
  29. return new request({
  30. url: './ums/logout',
  31. method: 'delete',
  32. });
  33. }
  34. export const getMenus = () => {
  35. return new request({
  36. url: './sys/menus',
  37. method: 'get',
  38. params: {
  39. applicationId: 2
  40. }
  41. });
  42. }
  43. export const getMyMenuTreeData = () => {
  44. return new request({
  45. url: './sys/menus/myTreeData',
  46. method: 'get',
  47. });
  48. }
  49. export const getChildrenMenuNum = (menuName) => {
  50. return new request({
  51. url: './sys/menus/getChildrenMenuNum',
  52. method: 'get',
  53. params: {
  54. menuName
  55. }
  56. });
  57. }
  58. export const getUserAuthorities = (userId) => {
  59. return new request({
  60. url: './uua/' + userId + '/authorities',
  61. method: 'get',
  62. });
  63. }
  64. export const getEmailCode = (account, email) => {
  65. return new request({
  66. url: './sys/authUsers/emailCode',
  67. method: 'get',
  68. params: {
  69. account,
  70. email
  71. }
  72. });
  73. }
  74. export const getSmsCode = (account, service) => {
  75. return new request({
  76. url: './sys/authUsers/smsCode',
  77. method: 'get',
  78. params: {
  79. account,
  80. service
  81. }
  82. });
  83. }
  84. export const getMobileSmsCode = (mobile, service) => {
  85. return new request({
  86. url: './sys/authUsers/mobile/smsCode',
  87. method: 'get',
  88. params: {
  89. mobile,
  90. service
  91. }
  92. });
  93. }
  94. export const getCaptcha = (uid) => {
  95. if (uid) {
  96. return new request({
  97. url: './sys/captcha',
  98. method: 'get',
  99. headers: {
  100. 'Captcha-Uid': uid
  101. },
  102. responseType: 'blob'
  103. });
  104. } else {
  105. return new request({
  106. url: './sys/captcha',
  107. method: 'get',
  108. responseType: 'blob'
  109. });
  110. }
  111. }
  112. export const resetPwd = (account, newPwd, surePwd, code) => {
  113. return new request({
  114. url: './sys/authUsers/resetPwd',
  115. method: 'post',
  116. data: qs.stringify({
  117. account,
  118. newPwd,
  119. surePwd,
  120. code
  121. })
  122. });
  123. }
  124. export const addToUserGroup = (userUid, groupKey, token) => {
  125. return new request({
  126. url: './sys/authUsers/' + userUid + "/group",
  127. method: 'post',
  128. headers: {
  129. token
  130. },
  131. data: qs.stringify({
  132. groupKey
  133. })
  134. });
  135. }
  136. export const findBasicInfo = () => {
  137. return new request({
  138. url: './uc/userCenter/findBasicInfo',
  139. method: 'get'
  140. });
  141. }
  142. export const findUserInfo = () => {
  143. return new request({
  144. url: './uc/userCenter/userInfo',
  145. method: 'get'
  146. })
  147. }
  148. export const saveUserInfo = (userNickName, basePersonnelInfo) => {
  149. return new request({
  150. url: './uc/userCenter/updateUserInfo',
  151. method: 'post',
  152. data: {
  153. basePersonnelInfo,
  154. userNickName
  155. }
  156. })
  157. }
  158. export const removeFromUserGroup = (userUid, groupKey) => {
  159. return new request({
  160. url: './sys/authUsers/' + userUid + "/group",
  161. method: 'delete',
  162. params: {
  163. groupKey
  164. }
  165. });
  166. }
  167. export function sendTelCode(account, service, language) {
  168. return new request({
  169. url: './ums/umsUsers/registCode',
  170. method: 'get',
  171. headers: {
  172. ANON: true
  173. },
  174. params: {
  175. account,
  176. service,
  177. language
  178. }
  179. });
  180. }
  181. export function registerByTel(umsUser, code, language) {
  182. return new request({
  183. url: './ums/umsUsers/regist',
  184. method: 'post',
  185. headers: {
  186. ANON: true,
  187. "Content-Type": "application/json"
  188. },
  189. data: {
  190. umsUser,
  191. code,
  192. language
  193. }
  194. })
  195. }
  196. export function checkCodeLogin(mobile, checkCode) {
  197. console.log('mobile,checkCode:', mobile, checkCode)
  198. return new request({
  199. url: './uc/userRegisterAndLogin/checkCodeLogin?mobile=' + mobile + '&checkCode=' + checkCode,
  200. method: 'get'
  201. });
  202. console.log(new request({
  203. url: './uc/userRegisterAndLogin/checkCodeLogin?mobile=' + mobile + '&checkCode=' + checkCode,
  204. method: 'get'
  205. }))
  206. }
  207. export const setPwd = (param) => {
  208. param = JSON.parse(param)
  209. let token = getToken()
  210. param.Authorization = token;
  211. param = JSON.stringify(param);
  212. return new request({
  213. url: './ums/umsUsers/changePassword',
  214. method: 'post',
  215. headers: {
  216. ANON: true
  217. },
  218. data: {
  219. param
  220. }
  221. })
  222. }
  223. export const updatePrsonnelInfo = (umsUser) => {
  224. return new request({
  225. url: './uc/userRegisterAndLogin/updatePrsonnelInfo',
  226. method: 'post',
  227. headers: {
  228. ANON: true,
  229. },
  230. data: {
  231. umsUser,
  232. language
  233. }
  234. })
  235. }
  236. export const updateEmail = (email, code) => {
  237. return new request({
  238. url: './uc/securitySetting/updateEmail',
  239. method: 'get',
  240. params: {
  241. email,
  242. code
  243. }
  244. })
  245. }
  246. //根据用户id获取用户信息
  247. export const getUserInfoById = (id) => {
  248. return new request({
  249. url: './uc/securitySetting/getUserInfoById',
  250. method: 'get'
  251. })
  252. }
  253. export const validCheckCode = (mobile, code) => {
  254. return new request({
  255. url: './uc/securitySetting/validCode',
  256. method: 'get',
  257. params: {
  258. mobile,
  259. code
  260. }
  261. })
  262. }
  263. export const updateMobile = (mobile, code) => {
  264. return new request({
  265. url: './uc/securitySetting/updateMobile',
  266. method: 'get',
  267. params: {
  268. mobile,
  269. code
  270. }
  271. })
  272. }