login.js 559 B

1234567891011121314151617181920
  1. import router from "../router";
  2. import store from "../store";
  3. import cookie from "@utils/store/cookie";
  4. import { isWeixin } from "@utils";
  5. import { oAuth } from "@libs/wechat";
  6. export default function toLogin(push, backUrl) {
  7. store.commit("LOGOUT");
  8. const { fullPath, name } = router.currentRoute;
  9. cookie.set("login_back_url", backUrl || fullPath);
  10. if (isWeixin()) {
  11. oAuth();
  12. } else {
  13. if (name !== "Login") {
  14. push
  15. ? router.push({ path: "/login" })
  16. : router.replace({ path: "/login" });
  17. }
  18. }
  19. }