auth.js 684 B

12345678910111213141516171819202122232425262728293031323334
  1. import request from '../utils/request';
  2. /**
  3. * 微信小程序登录
  4. * @param {Object} data - { code: wx.login的code, phoneCode: 手机号授权code }
  5. */
  6. export function wechatLogin(data) {
  7. return request({
  8. url: '/miniapp/auth/login',
  9. method: 'POST',
  10. data
  11. });
  12. }
  13. /**
  14. * 获取服务协议/隐私政策内容
  15. * @param {string} type - 'service' 或 'privacy'
  16. */
  17. export function getAgreement(type) {
  18. return request({
  19. url: `/miniapp/auth/agreement?type=${type}`,
  20. method: 'GET'
  21. });
  22. }
  23. /**
  24. * 退出登录
  25. */
  26. export function logout() {
  27. return request({
  28. url: '/miniapp/auth/logout',
  29. method: 'POST'
  30. });
  31. }