app.vue 2.47 KB
<template>
  <div id="app" :style="{height: 'calc(' + windowHeight + ' + env(safe-area-inset-bottom))' }">
    <keep-alive :max="20">
      <router-view :key="routerViewKey"></router-view>
    </keep-alive>
  </div>
</template>

<script>
import { mapState, mapMutations, mapActions } from 'vuex';

export default {
  name: 'App',
  computed: {
    ...mapState(['yoho']),
    routerViewKey() {
      if (this.$route.meta && this.$route.meta.routerViewKey) {
        return this.$route.meta.routerViewKey;
      } else {
        return this.$route.fullPath;
      }
    },
    windowHeight() {
      if (typeof window !== 'undefined') {
        console.log(window);
        return window.innerHeight + 'px';
      } else {
        return '100%';
      }
    }
  },
  mounted() {
    if (this.yoho.context.needLogin) {
      this.$yoho.auth();
    }

    // this.$xianyu.setXianyuWebview();
    this.$xianyu.setXianyuNav();

    this.$sdk.getUser().then(user => {
      if (user && user.uid) {
        this.SET_LOGIN_INFO(user);
      } else {
        // queryString中携带bind_code,则弹出绑定弹框
        if (this.$route.query.bind_code) {
          this.$root.$createThirdBind().open();
        }
      }
    });

    this.getZkConfig();
  },
  watch: {
    'yoho.context.needLogin': function(newVal) {
      if (newVal) {
        this.$yoho.auth({ needLogin: newVal });
      }
    },
  },
  methods: {
    ...mapMutations(['SET_LOGIN_INFO']),
    ...mapActions(['getZkConfig'])
  }
};
</script>

<style lang="scss">
.route-view-forword-enter-active,
.route-view-forword-leave-active,
.route-view-back-enter-active,
.route-view-back-leave-active {
  will-change: transform;
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  perspective: 1000;
}

.route-view-forword-leave-active,
.route-view-back-leave-active {
  transition: all 300ms ease;
}

.route-view-forword-enter-active,
.route-view-back-enter-active {
  transition: all 300ms cubic-bezier(0.165, 0.84, 0.44, 1);
}

.route-view-forword-enter {
  transform: translate3d(100%, 0, 0);
}

.route-view-forword-enter-active {
  z-index: 2;
}

.route-view-forword-leave-active {
  z-index: -1;
  transform: translate3d(-30%, 0, 0);
}

.route-view-back-enter {
  transform: translate3d(-30%, 0, 0);
}

.route-view-back-enter-active {
  z-index: -1;
}

.route-view-back-leave-active {
  transform: translate3d(100%, 0, 0);
  z-index: 2;
}

.cube-safe-area-pb {
  border-top-left-radius: 25px;
  border-top-right-radius: 25px;
}

</style>