index-login-check-mixin.js 707 B

123456789101112131415161718192021222324252627
  1. import { mapGetters } from 'vuex'
  2. export default {
  3. provide() {
  4. return {
  5. loginCheck: this.loginStatusCheck
  6. }
  7. },
  8. computed: {
  9. ...mapGetters(['currentUser', 'isLogin'])
  10. },
  11. methods: {
  12. loginStatusCheck() {
  13. // 首页统一注入登陆检测方法,未登陆时直接跳至登陆框
  14. if (this.isLogin) {
  15. if (!!this.currentUser?.isBind) return Promise.resolve(true)
  16. this.dialogVisible = true
  17. this.$message.error('请先完善信息!')
  18. return Promise.reject(false)
  19. }
  20. this.$refs.loginForm?.$el?.scrollIntoView({ behavior: 'smooth' })
  21. this.$message.error('请先登陆!')
  22. return Promise.reject(false)
  23. }
  24. }
  25. }