useWechatAuth.js 773 B

12345678910111213141516171819202122232425262728293031323334
  1. import { api_wechatAuth, api_systemConfiguration} from "@/http/api.js"
  2. import { useLoginSuccess } from '@/share/useLoginSuccess.js'
  3. const { loginSuccess } = 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. api_systemConfiguration({
  22. idx: 0,
  23. sum: 9999,
  24. }).then(res2=>{
  25. uni.setStorageSync('sysData',JSON.stringify(res2.list))
  26. })
  27. }
  28. });
  29. }
  30. return {
  31. wechatAuth
  32. };
  33. }