index.ts 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. import APP from '@/services';
  2. import { getLongTypeLoginID } from '@/services/bus/login';
  3. import { getUsrId } from '@/services/bus/user';
  4. import { commonSearch_go } from '../index';
  5. import * as type from './interface';
  6. /**
  7. * 获取登录ID
  8. * @param username 可传入“登录账号”、“登录代码”和“手机号码”
  9. * @returns
  10. */
  11. export function GetLoginID(username: string): Promise<string> {
  12. return commonSearch_go('/User/GetLoginID', { username })
  13. }
  14. /**
  15. * 获取用户账号信息
  16. * @param username 用户ID
  17. * @returns
  18. */
  19. export function GetUserAccount(userID: number): Promise<type.GetUserAccount> {
  20. return commonSearch_go('/User/GetUserAccount', { userID })
  21. }
  22. /**
  23. * 账户登录后信息查询
  24. * @param loginID 登录账号
  25. * @returns
  26. */
  27. export function LoginQuery(): Promise<type.LoginQueryRsp> {
  28. const id = getLongTypeLoginID();
  29. return commonSearch_go('/User/LoginQuery', { loginID: Number(id) }).then(res => {
  30. const {
  31. areaRoles,
  32. externalExchanges,
  33. goodsgroups,
  34. loginAccount,
  35. markets,
  36. systemParams,
  37. userAccount,
  38. userInfo,
  39. username } = res;
  40. areaRoles && APP.set('areaRoles', areaRoles);
  41. externalExchanges && APP.set('externalexchange', externalExchanges);
  42. goodsgroups && APP.set('goodsgroups', goodsgroups);
  43. loginAccount && APP.set('loginAccount', loginAccount);
  44. markets && APP.set('markets', markets);
  45. systemParams && APP.set('systemParams', systemParams);
  46. userAccount && APP.set('userAccount', userAccount);
  47. userInfo && APP.set('userInfo', userInfo);
  48. username && APP.set('username', username);
  49. console.log('LoginQuery', res);
  50. QueryRootUserAccount()
  51. return res
  52. })
  53. }
  54. /**
  55. * 获取用户信息
  56. * @param loginID 登录账号
  57. * @returns
  58. */
  59. export function QueryUserInfo(userID: number, isDecrypt?: boolean): Promise<type.Userinfo> {
  60. const param = isDecrypt ? { isDecrypt, userID } : { userID }
  61. return commonSearch_go('/User/QueryUserInfo', param)
  62. }
  63. /**
  64. * 查询顶级用户信息
  65. * /Ermcp3/QueryRootUserAccount
  66. */
  67. export function QueryRootUserAccount(): Promise<string> {
  68. const userid = getUsrId()
  69. return commonSearch_go('/Ermcp3/QueryRootUserAccount', { userid }).then(res => {
  70. APP.set('RootUser', res);
  71. return 'ok'
  72. }).catch((err) => {
  73. throw new Error(`查询顶级用户信息: ${err}`);
  74. });
  75. }