third.js 2.9 KB

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