public.js 2.3 KB

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