index.ts 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. import { request, goCommonSearchUrl, commonSearchUrl } from '@/services/request/index';
  2. import { sha256 } from 'js-sha256';
  3. import { getUserId } from '@/services/bus/account';
  4. import { UserInfoReq } from './interface';
  5. /**
  6. * 统一查询用户登录账号
  7. */
  8. export const queryLoginAccount = (logidCode: String): Promise<string> => {
  9. return new Promise((resolve, reject) => {
  10. request({
  11. method: 'get',
  12. url: goCommonSearchUrl('/User/GetLoginID'),
  13. params: { username: logidCode },
  14. })
  15. .then((value) => {
  16. console.log(value);
  17. resolve(value.data.data);
  18. })
  19. .catch((err) => {
  20. console.log(err);
  21. reject(err.message);
  22. });
  23. });
  24. };
  25. /**
  26. * 请求验证码
  27. */
  28. export const querySmsvcode = (mobile: String): Promise<string> => {
  29. return new Promise((resolve, reject) => {
  30. request({
  31. method: 'post',
  32. url: commonSearchUrl('/user/smsvcode'),
  33. data: { mobile },
  34. })
  35. .then((value) => {
  36. if (value.data.success === 'true') {
  37. resolve(value.data);
  38. } else {
  39. reject(value.data);
  40. }
  41. })
  42. .catch((err) => reject(err));
  43. });
  44. };
  45. /**
  46. * 拿登录id
  47. */
  48. export const queryLoginInfo = (mobile: String, vcode: String): Promise<string> => {
  49. return new Promise((resolve, reject) => {
  50. request({
  51. method: 'post',
  52. url: commonSearchUrl('/tradeoperation/querylogininfo'),
  53. data: { mobile, vcode },
  54. })
  55. .then((value) => {
  56. if (value.data.code === '0') {
  57. resolve(value.data.resultset);
  58. } else {
  59. reject(value.data.message);
  60. }
  61. })
  62. .catch((err) => reject(err));
  63. });
  64. };
  65. /**
  66. * 改密码
  67. */
  68. export const queryResetpwdbycardnum = (mobile: String, vcode: String, pwd: String, loginid: String): Promise<string> => {
  69. const password = sha256.hex(`${loginid}${pwd}`);
  70. console.log('password', password);
  71. return new Promise((resolve, reject) => {
  72. request({
  73. method: 'post',
  74. url: commonSearchUrl('/tradeoperation/resetpwdbycardnum'),
  75. data: { mobile, vcode, password },
  76. })
  77. .then((value: any) => {
  78. console.log(value);
  79. if (value.data.code === '500') {
  80. reject(value.data.message);
  81. } else {
  82. resolve(value.data.message);
  83. }
  84. })
  85. .catch((err) => reject(err));
  86. });
  87. };
  88. /**
  89. * 获取用户实名认证状态
  90. * @returns
  91. */
  92. export function GetUserAuthStatus(): Promise<boolean> {
  93. const params = { userID: getUserId() };
  94. return request({
  95. method: 'get',
  96. url: goCommonSearchUrl('/User/GetUserAuthStatus'),
  97. params,
  98. })
  99. .then((value: any) => {
  100. return value.data.data;
  101. })
  102. .catch((err) => Promise.reject('获取用户实名认证状态失败:' + err.message));
  103. }
  104. /**
  105. * 获取用户信息
  106. * @returns
  107. */
  108. export function QueryUserInfo(): Promise<UserInfoReq> {
  109. const params = {
  110. userID: getUserId(),
  111. isDecrypt: true,
  112. };
  113. return request({
  114. method: 'get',
  115. url: goCommonSearchUrl('/User/QueryUserInfo'),
  116. params,
  117. })
  118. .then((value: any) => {
  119. console.log(value);
  120. return value.data.data;
  121. })
  122. .catch((err) => Promise.reject('获取用户信息' + err.message));
  123. }