public.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. import request from "@/utils/request.js";
  2. import wechat from "@/libs/wechat.js";
  3. import { APP_CODE } from "@/config/app.js";
  4. /**
  5. * 获取微信公众号js配置
  6. * @returns {*}
  7. */
  8. export function getWechatConfig() {
  9. return request.get(
  10. "wechat/config",
  11. { url: encodeURIComponent(wechat.signLink()) },
  12. { noAuth: true },
  13. );
  14. }
  15. /**
  16. * 获取微信sdk配置
  17. * @returns {*}
  18. */
  19. export function wechatAuth(code, spread) {
  20. var reg = /^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ,判断正整数用/^[1-9]+[0-9]*]*$/
  21. spread = reg.test(spread) ? spread : 0;
  22. return request.get(
  23. "wechat/authorize/login?code=" + code + "&spread_spid=" + spread,
  24. {},
  25. { noAuth: true },
  26. );
  27. }
  28. /**
  29. * 获取登录授权login
  30. *
  31. */
  32. export function getLogo() {
  33. // wechat/get_logo
  34. return request.get("wechat/getLogo", {}, { noAuth: true });
  35. }
  36. /**
  37. * 小程序用户登录
  38. * @param data object 小程序用户登录信息
  39. */
  40. export function login(code, data) {
  41. return request.post("wechat/authorize/program/login?code=" + code, data, {
  42. noAuth: true,
  43. });
  44. }
  45. /**
  46. * 分享
  47. * @returns {*}
  48. */
  49. export function getShare() {
  50. return request.get("share", {}, { noAuth: true });
  51. }
  52. /**
  53. * 获取关注海报
  54. * @returns {*}
  55. */
  56. export function follow() {
  57. return request.get("wechat/follow", {}, { noAuth: true });
  58. }
  59. /**
  60. * 获取图片base64
  61. * @retins {*}
  62. * */
  63. export function imageBase64(image) {
  64. return request.post("qrcode/base64", image, { noAuth: true }, 1);
  65. }
  66. /**
  67. * 自动复制口令功能
  68. * @returns {*}
  69. */
  70. export function copyWords() {
  71. return request.get("copy_words", {}, { noAuth: true });
  72. }
  73. /**
  74. * 首页 获取客服地址
  75. * @returns {*}
  76. */
  77. export function kefuConfig() {
  78. return request.get("config", {}, { noAuth: true });
  79. }
  80. /**
  81. * 微信(公众号,小程序)绑定手机号
  82. * @param {Object} data
  83. */
  84. export function getUserPhone(data) {
  85. return request.post(
  86. "wechat/register/binding/phone",
  87. { ...data, openType: APP_CODE },
  88. { noAuth: true },
  89. );
  90. }
  91. /**
  92. * APP微信登录
  93. * @param {Object} data
  94. */
  95. export function appAuth(data) {
  96. return request.post("wechat/authorize/app/login", data, { noAuth: true });
  97. }
  98. /**
  99. * 苹果登录
  100. * @param {Object} data
  101. */
  102. export function appleLogin(data) {
  103. return request.post("ios/login", data, { noAuth: true });
  104. }
  105. /**
  106. * 苹果绑定手机号
  107. * @param {Object} data
  108. */
  109. export function iosBinding(data) {
  110. return request.post("ios/binding/phone", data, { noAuth: true });
  111. }