third.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. import request from '@/sheep/request';
  2. import { baseUrl, apiPath } from '@/sheep/config';
  3. export default {
  4. // 微信相关
  5. wechat: {
  6. // 第三方登录
  7. login: (data) =>
  8. request({
  9. url: 'third/wechat/login',
  10. method: 'POST',
  11. data,
  12. custom: {
  13. showSuccess: true,
  14. loadingMsg: '登陆中',
  15. },
  16. }),
  17. // 绑定微信
  18. bind: (data) =>
  19. request({
  20. url: 'third/wechat/bind',
  21. method: 'POST',
  22. data,
  23. custom: {
  24. showSuccess: true,
  25. loadingMsg: '绑定中',
  26. },
  27. }),
  28. // 解除绑定微信
  29. unbind: (data) =>
  30. request({
  31. url: 'third/wechat/unbind',
  32. method: 'POST',
  33. data,
  34. custom: {
  35. showSuccess: true,
  36. loadingMsg: '解除绑定',
  37. },
  38. }),
  39. // 公众号授权
  40. oauthLogin: (data) =>
  41. request({
  42. url: 'third/wechat/oauthLogin',
  43. method: 'GET',
  44. data,
  45. custom: {
  46. showSuccess: true,
  47. loadingMsg: '登陆中',
  48. },
  49. }),
  50. // 获取小程序sessionKey(后端不会给前端返回真实的sessionKey)
  51. getSessionId: (data) =>
  52. request({
  53. url: 'third/wechat/getSessionId',
  54. method: 'POST',
  55. data,
  56. custom: {
  57. showLoading: false,
  58. },
  59. }),
  60. // 微信小程序 绑定一键获取的手机号
  61. bindUserPhoneNumber: (data) =>
  62. request({
  63. url: 'third/wechat/bindUserPhoneNumber',
  64. method: 'POST',
  65. data,
  66. custom: {
  67. showSuccess: true,
  68. loadingMsg: '获取中',
  69. },
  70. }),
  71. // 小程序订阅消息
  72. subscribeTemplate: (params) =>
  73. request({
  74. url: 'third/wechat/subscribeTemplate',
  75. method: 'GET',
  76. params: {
  77. platform: 'miniProgram',
  78. },
  79. custom: {
  80. showError: false,
  81. showLoading: false,
  82. },
  83. }),
  84. // 获取微信小程序码
  85. getWxacode: (path) =>
  86. `${baseUrl}${apiPath}third/wechat/wxacode?platform=miniProgram&payload=${encodeURIComponent(
  87. JSON.stringify({
  88. path,
  89. }),
  90. )}`,
  91. },
  92. // 苹果相关
  93. apple: {
  94. // 第三方登录
  95. login: (data) =>
  96. request({
  97. url: 'third/apple/login',
  98. method: 'POST',
  99. data,
  100. custom: {
  101. showSuccess: true,
  102. loadingMsg: '登陆中',
  103. },
  104. }),
  105. },
  106. };