<div class="aside-nav" v-if="btnFlag">
<el-button class="backTop" @click="backTop">
<i class="el-icon-caret-top"></i>
<div class="backTop-tt">top</div>
</el-button>
<el-button class="kefu" @click="dialogVisible = true">
<i class="iconfont icon-kefu"></i>
<div class="kefu-tt">免费咨询</div>
</el-button>
</div>
data() {
return {
key: '',
btnFlag:true,
dialogVisible:false
};
},
components: {
FormModal
},
methods: {
backTop() {
var that = this
let timer = setInterval(() => {
let ispeed = Math.floor(-that.scrollTop / 5)
document.documentElement.scrollTop = document.body.scrollTop = that.scrollTop + ispeed
if (that.scrollTop == 0) {
clearInterval(timer)
}
}, 16)
},
scrollToTop() {
var that = this
let scrollTop = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop
that.scrollTop = scrollTop
if (that.scrollTop > 0) {
that.btnFlag = true
} else {
that.btnFlag = false
}
}
},
mounted() {
new this.$wow.WOW().init();
window.addEventListener('scroll', this.scrollToTop)
},
destroyed() {
window.removeEventListener()('scroll', this.scrollToTop)
}