useWechatAuth.js 675 B

1234567891011121314151617181920212223242526272829
  1. import { api_wechatAuth, api_systemConfiguration, api_getDictionary} from "@/http/api.js"
  2. import { useLoginSuccess } from '@/share/useLoginSuccess.js'
  3. const { loginSuccess, transform } = useLoginSuccess()
  4. export function useWechatAuth() {
  5. /**
  6. * 微信登录2
  7. */
  8. const wechatAuth = () => {
  9. uni.showLoading({
  10. title: "登录中",
  11. mask: true,
  12. });
  13. api_wechatAuth({
  14. redirectUrl: location.origin + location.pathname
  15. }).then(res => {
  16. uni.hideLoading();
  17. if (res.url) {
  18. window.location.href = res.url;
  19. } else {
  20. loginSuccess(res.user);
  21. transform(res.user, 'menu');
  22. }
  23. });
  24. }
  25. return {
  26. wechatAuth
  27. };
  28. }