user.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /**
  2. * 授权 API
  3. */
  4. import {
  5. http
  6. } from '../request/main.js'
  7. /**
  8. * 用户登录 - 姓名登录码
  9. *
  10. * @returns {Promise}
  11. */
  12. export function loginByNameCode(name, code, wx_code) {
  13. return http.post('/user/loginByNameCode', {
  14. name,
  15. code,
  16. wx_code
  17. }, {
  18. muteLogin: true
  19. })
  20. }
  21. /**
  22. * 用户登录 - 编号登录码
  23. *
  24. * @returns {Promise}
  25. */
  26. export function loginByNumberCode(number, code, wx_code) {
  27. return http.post('/user/loginByNumberCode', {
  28. number,
  29. code,
  30. wx_code
  31. }, {
  32. muteLogin: true
  33. })
  34. }
  35. /**
  36. * 用户登录 - 手机验证码
  37. *
  38. * @returns {Promise}
  39. */
  40. export function loginByPhoneCaptcha(phone, captcha, wx_code) {
  41. return http.post('/user/loginByPhoneCaptcha', {
  42. phone,
  43. captcha,
  44. wx_code
  45. }, {
  46. muteLogin: true
  47. })
  48. }
  49. /**
  50. * 用户登录 - 微信快捷登录
  51. *
  52. * @returns {Promise}
  53. */
  54. export function loginByWechatPhone(encrypted_data, iv, code, wx_code) {
  55. return http.post('/user/loginByWechatPhone', {
  56. encrypted_data,
  57. iv,
  58. code,
  59. wx_code
  60. }, {
  61. muteLogin: true
  62. })
  63. }
  64. /**
  65. * 小程序自动登录
  66. *
  67. * @returns {Promise}
  68. */
  69. export function wechatAutoLogin(wx_code) {
  70. return http.post('/user/wechatAutoLogin', {
  71. wx_code
  72. }, {
  73. muteLogin: true
  74. })
  75. }
  76. /**
  77. * 发送手机验证吗
  78. *
  79. * @returns {Promise}
  80. */
  81. export function sendPhoneCaptcha(phone, wx_code, muteLogin) {
  82. return http.post('/user/sendPhoneCaptcha', {
  83. phone,
  84. wx_code
  85. }, {
  86. muteLogin: muteLogin
  87. })
  88. }
  89. /**
  90. * 用户登出
  91. *
  92. * @returns {Promise}
  93. */
  94. export function logout() {
  95. return http.post('/user/logout')
  96. }
  97. /**
  98. * 更新用户信息
  99. *
  100. * @returns {Promise}
  101. */
  102. export function updateUserInfo(avatar_url) {
  103. return http.post('/user/updateUserInfo', {
  104. avatar_url
  105. })
  106. }
  107. /**
  108. * 获取用户信息
  109. *
  110. * @returns {Promise}
  111. */
  112. export function getUserInfo() {
  113. return http.post('/user/getUserInfo')
  114. }
  115. /**
  116. * 修改登录码
  117. *
  118. * @returns {Promise}
  119. */
  120. export function changeCode(oldCode, newCode) {
  121. return http.post('/user/changeCode', {
  122. oldCode,
  123. newCode
  124. })
  125. }
  126. /**
  127. * 修改手机号
  128. *
  129. * @returns {Promise}
  130. */
  131. export function changePhone(phone, captcha) {
  132. return http.post('/user/changePhone', {
  133. phone,
  134. captcha
  135. })
  136. }
  137. /**
  138. * 修改手机号 - 授权微信手机号
  139. *
  140. * @returns {Promise}
  141. */
  142. export function changeWechatPhone(encrypted_data, iv, code, wx_code) {
  143. return http.post('/user/changeWechatPhone', {
  144. encrypted_data,
  145. iv,
  146. code,
  147. wx_code
  148. })
  149. }