checkauth.ts 430 B

1234567891011121314151617181920212223
  1. import Navi from './navi'
  2. import { getUser } from './util'
  3. const checkauth = Behavior({
  4. methods: {
  5. afterAuth(callback: Function) {
  6. const info = getUser()
  7. const self = this
  8. if (info != null) {
  9. callback && callback()
  10. } else {
  11. self.gotoLogin()
  12. }
  13. },
  14. gotoLogin() {
  15. Navi.navigateTo({
  16. url: '/pages/login/index',
  17. })
  18. },
  19. },
  20. })
  21. export default checkauth