123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <template>
- <div id="app">
- <div class="view-container">
- <AppHeader :visible="visible"></AppHeader>
- <transition :name="transitionName">
- <router-view />
- </transition>
- <AppBackTop></AppBackTop>
- </div>
- <el-dialog width="30%" title="联系我们" :visible.sync="dialogVisible">
- <div>座机:010-82783688转122</div>
- <div>邮箱:guowl@dgtis.com</div>
- </el-dialog>
- </div>
- </template>
- <script>
- import AppHeader from '@/components/AppHeader.vue';
- import AppBackTop from '@/components/AppBackTop.vue';
- export default {
- name: 'app',
- components: {
- AppHeader,
- AppBackTop
- },
- data() {
- return {
- dialogVisible: false,
- transitionName: "",
- isGray: false,
- visible:true,
- };
- },
- created(){
- this.$store.dispatch('GetUserInfo');
- },
- methods:{
- fatherMethod() {
- this.dialogVisible = true;
- },
- // 保存滚动值,这是兼容的写法
- handleScroll () {
- var scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
- //变量scrollTop是滚动条滚动时,距离顶部的距离
- // var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
- // //变量windowHeight是可视区的高度
- // var windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
- // //变量windowHeight是可视区的高度
- // var scrollHeight =document.documentElement.scrollHeight || document.body.scrollHeight;
- // //滚动条到底部的条件
- // if(scrollTop + windowHeight == scrollHeight){
- // //你要触发的方法
- // }
- if(scrollTop >= 80){
- this.visible = false;
- }else{
- this.visible = true;
- }
- },
- },
- mounted () {
- window.addEventListener('scroll', this.handleScroll)
- },
- destroyed () {
- // 离开该页面需要移除这个监听的事件,不然会报错
- window.removeEventListener('scroll', this.handleScroll)
- },
- watch: {
- //使用watch 监听$router的变化
- $route(to, from) {
- //如果to索引大于from索引,判断为前进状态,反之则为后退状态
- console.log(to, "to");
- console.log(from, "from");
- if (to.meta.index > from.meta.index) {
- //设置动画名称
- this.transitionName = "slide-left";
- } else {
- this.transitionName = "slide-right";
- }
- },
- },
- }
- </script>
- <style>
- ::-webkit-scrollbar-track {
- background: rgba(0, 0, 0, 0.1);
- border-radius: 0;
- }
- ::-webkit-scrollbar {
- -webkit-appearance: none;
- width: 5px;
- height: 6px;
- }
- ::-webkit-scrollbar-thumb {
- cursor: pointer;
- border-radius: 5px;
- background: rgba(0, 0, 0, 0.15);
- transition: color 0.2s ease;
- }
- .el-card__body{
- padding: 0 10px !important;
- }
- .el-dialog__body{
- padding-top: 0px !important;
- }
- .view-container{
- position: relative;
- margin: 0 auto;
- width: 100%;
- max-width: 1200px;
- }
- .slide-right-enter-active,
- .slide-right-leave-active,
- .slide-left-enter-active,
- .slide-left-leave-active {
- will-change: transform;
- transition: all 80ms;
- position: fixed;
- }
-
- .slide-right-enter {
- opacity: 0;
- transform: translate3d(-100%, 0, 0);
- }
-
- .slide-right-leave-active {
- opacity: 0;
- transform: translate3d(100%, 0, 0);
- }
-
- .slide-left-enter {
- opacity: 0;
- transform: translate3d(100%, 0, 0);
- }
-
- .slide-left-leave-active {
- opacity: 0;
- transform: translate3d(-100%, 0, 0);
- }
- </style>
|