safe.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * 安全相关API
  3. */
  4. import {http,Method} from '@/utils/request.js';
  5. import storage from "@/utils/storage.js"
  6. import { md5 } from '@/utils/md5.js'
  7. /**
  8. * 发送绑定手机验证码
  9. * @param mobile
  10. * @param captcha
  11. */
  12. export function sendBindMobileSms(mobile, captcha) {
  13. return http.request({
  14. url: `members/security/bind/send/${mobile}`,
  15. method: Method.POST,
  16. needToken: true,
  17. header:{'content-type':"application/x-www-form-urlencoded"},
  18. data: {
  19. uuid: storage.getUuid(),
  20. captcha,
  21. },
  22. });
  23. }
  24. /**
  25. * 绑定手机号
  26. * @param mobile
  27. * @param sms_code
  28. */
  29. export function bindMobile(mobile, sms_code) {
  30. return http.request({
  31. url: `members/security/bind/${mobile}`,
  32. method: Method.PUT,
  33. needToken: true,
  34. data: {sms_code},
  35. });
  36. }
  37. /**
  38. * 发送手机验证码
  39. * 在修改手机号和更改密码时通用
  40. * @param captcha
  41. */
  42. export function sendMobileSms(captcha) {
  43. return http.request({
  44. url: 'members/security/send',
  45. method: Method.POST,
  46. needToken: true,
  47. header:{'content-type':"application/x-www-form-urlencoded"},
  48. data: {
  49. uuid: storage.getUuid(),
  50. captcha,
  51. },
  52. });
  53. }
  54. /**
  55. * 验证更换手机号短信
  56. * @param sms_code
  57. */
  58. export function validChangeMobileSms(sms_code) {
  59. return http.request({
  60. url: 'members/security/exchange-bind',
  61. method: Method.GET,
  62. needToken: true,
  63. params: {sms_code},
  64. });
  65. }
  66. /**
  67. * 更换手机号
  68. * @param mobile
  69. * @param sms_code
  70. */
  71. export function changeMobile(mobile, sms_code) {
  72. return http.request({
  73. url: `members/security/exchange-bind/${mobile}`,
  74. method: Method.PUT,
  75. header:{'content-type':"application/x-www-form-urlencoded"},
  76. needToken: true,
  77. data: {sms_code},
  78. });
  79. }
  80. /**
  81. * 更改密码
  82. * @param captcha
  83. * @param password
  84. */
  85. export function changePassword(captcha, password) {
  86. return http.request({
  87. url: 'members/security/password',
  88. method: Method.PUT,
  89. header:{'content-type':"application/x-www-form-urlencoded"},
  90. needToken: true,
  91. data: {
  92. uuid: storage.getUuid(),
  93. captcha,
  94. password: md5(password),
  95. },
  96. });
  97. }
  98. /**
  99. * 获取当前实名认证进度
  100. * @param email
  101. * @param email_code
  102. */
  103. export function contractStep() {
  104. return http.request({
  105. url: `members/contract/step`,
  106. method: Method.GET,
  107. needToken: true
  108. })
  109. }
  110. /**
  111. * 实名认证
  112. * @param email
  113. * @param email_code
  114. */
  115. export function authentication(params) {
  116. return http.request({
  117. url: `members/contract/authentication`,
  118. method: Method.POST,
  119. needToken: true,
  120. header:{'content-type':"application/x-www-form-urlencoded"},
  121. data: params
  122. })
  123. }