third.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. oauthLogin: (data) =>
  30. request({
  31. url: 'third/wechat/oauthLogin',
  32. method: 'GET',
  33. data,
  34. custom: {
  35. showSuccess: true,
  36. loadingMsg: '登陆中',
  37. },
  38. }),
  39. // 获取小程序sessionKey(后端不会给前端返回真实的sessionKey)
  40. getSessionId: (data) =>
  41. request({
  42. url: 'third/wechat/getSessionId',
  43. method: 'POST',
  44. data,
  45. custom: {
  46. showLoading: false,
  47. },
  48. }),
  49. // 微信小程序 绑定一键获取的手机号
  50. bindUserPhoneNumber: (data) =>
  51. request({
  52. url: 'third/wechat/bindUserPhoneNumber',
  53. method: 'POST',
  54. data,
  55. custom: {
  56. showSuccess: true,
  57. loadingMsg: '获取中',
  58. },
  59. }),
  60. // 小程序订阅消息
  61. subscribeTemplate: (params) =>
  62. request({
  63. url: 'third/wechat/subscribeTemplate',
  64. method: 'GET',
  65. params: {
  66. platform: 'miniProgram',
  67. },
  68. custom: {
  69. showError: false,
  70. showLoading: false,
  71. },
  72. }),
  73. // 获取微信小程序码
  74. getWxacode: (path) =>
  75. `${baseUrl}${apiPath}third/wechat/wxacode?platform=miniProgram&payload=${encodeURIComponent(
  76. JSON.stringify({
  77. path,
  78. }),
  79. )}`,
  80. },
  81. // 苹果相关
  82. apple: {
  83. // 第三方登录
  84. login: (data) =>
  85. request({
  86. url: 'third/apple/login',
  87. method: 'POST',
  88. data,
  89. custom: {
  90. showSuccess: true,
  91. loadingMsg: '登陆中',
  92. },
  93. }),
  94. },
  95. };