useWechatAuth.js 1021 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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);
  22. api_systemConfiguration({
  23. idx: 0,
  24. sum: 9999,
  25. }).then(res2=>{
  26. uni.setStorageSync('sysData',JSON.stringify(res2.list))
  27. })
  28. let postData = {
  29. "key": 'usertype',
  30. "type": "list",
  31. };
  32. api_getDictionary(postData).then((data) => {
  33. uni.setStorageSync('groupData',JSON.stringify(data))
  34. });
  35. }
  36. });
  37. }
  38. return {
  39. wechatAuth
  40. };
  41. }