public.js 2.4 KB

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