user.ts 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import APP from '@/services';
  2. import { Arearole, Ermcp3RootUserAccount } from '../go/useInfo/interface';
  3. /**
  4. * 获取用户账户类型
  5. * @returns
  6. */
  7. export function getUserAccountType(): number {
  8. return APP.get('userAccount').usertype
  9. }
  10. /**
  11. * 获取用户
  12. */
  13. export function getUserInfo() {
  14. return APP.get('userInfo')
  15. }
  16. /**
  17. * 获取用户名
  18. * @returns
  19. */
  20. export function getUserName() {
  21. const name = APP.get('loginAccount').accountname
  22. return name ? name : getUserInfo().customername
  23. }
  24. // 公司名
  25. export function getCompanyName() {
  26. return getUserInfo().customername
  27. }
  28. /**
  29. * 获取用户id
  30. * 登录中也写了一个 获取用户id的方法,那个方法是在登录信息里面获取用户id,这个方法是在go服务修改登录请求方法,返回用户信息,后期有时间进行优化
  31. */
  32. export function getUsrId() {
  33. return getUserInfo().userid
  34. }
  35. /**
  36. * 获取所属机构id
  37. */
  38. export function getAreaUserId(): number {
  39. return APP.get('userAccount').memberuserid
  40. }
  41. /**
  42. * 获取所属机构名称
  43. */
  44. export function getAreaUserName(): number {
  45. return APP.get('userAccount').memberusername
  46. }
  47. /**
  48. * 获取角色类型, 多个已逗号隔开
  49. * 1:交易所 2:运营机构 3:营销中心 4:仓库机构 5:三方服务机构 6:自营会员 7:经纪会员 8:做市会员 9:产业会员 10:金融机构 11:商城店铺 12:子机构 13:报价商 14:积分服务商 15:供货商 16:圈内会员 17:物流机构 18:报价配置机构 19:场外期权做市商 20:组织机构 21:顶级机构 22:业务员 23:跟单员 24:交易员
  50. */
  51. export function getAoletype_string(): string {
  52. return APP.get('areaRoles').reduce((acc: string, cur: Arearole) => {
  53. return acc ? `${acc},${cur.roletype}` : `${cur.roletype}`
  54. }, '')
  55. }
  56. export function getRootUserInfo(): Ermcp3RootUserAccount | undefined {
  57. const temp = APP.get('RootUser');
  58. return temp.length ? temp[0] : undefined
  59. }