third.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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. // 网页jssdk
  72. jssdk: (data) =>
  73. request({
  74. url: 'third/wechat/jssdk',
  75. method: 'GET',
  76. data,
  77. custom: {
  78. showError: false,
  79. showLoading: false,
  80. },
  81. }),
  82. // 小程序订阅消息
  83. subscribeTemplate: (params) =>
  84. request({
  85. url: 'third/wechat/subscribeTemplate',
  86. method: 'GET',
  87. params: {
  88. platform: 'miniProgram',
  89. },
  90. custom: {
  91. showError: false,
  92. showLoading: false,
  93. },
  94. }),
  95. // 获取微信小程序码
  96. getWxacode: (path) =>
  97. `${baseUrl}${apiPath}third/wechat/wxacode?platform=miniProgram&payload=${encodeURIComponent(
  98. JSON.stringify({
  99. path,
  100. }),
  101. )}`,
  102. },
  103. // 苹果相关
  104. apple: {
  105. // 第三方登录
  106. login: (data) =>
  107. request({
  108. url: 'third/apple/login',
  109. method: 'POST',
  110. data,
  111. custom: {
  112. showSuccess: true,
  113. loadingMsg: '登陆中',
  114. },
  115. }),
  116. },
  117. };