<template>
<div class="progerss-box" show="{{ showLoading }}">
<progress class="progerss" percent="{{ progress }}"></progress>
</div>
</template>
<script>
export default {
data: {
showLoading: true,
progress: 0,
number: 0,
falg: false,
},
loadpageControl() {
const self = this
this.loadTimer = setInterval(() => {
if (self.progress < 90)
self.progress += 1
}, 10)
setTimeout(()=>{
self.finish()
},4000)
},
// 加载前
start() {
this.showLoading = true
this.progress = 0
clearInterval(this.loadTimer)
this.loadpageControl()
},
// 加载完成
finish(callback) {
if (this.falg) return
this.falg = true
const self = this
clearInterval(this.loadTimer)
// let length = 100-self.progress
// let time = Math.floor(400/length)
this.finishTimer = setInterval(() => {
if (self.progress < 100) {
self.progress += 1
} else {
clearInterval(self.finishTimer)
self.showLoading = false
}
}, 6)
// this.setNumber()
// if (this.number === 2) {
// this.number = 0
// if (!this.isError) {
// callback({ showContent: 'isWeb' })
// }
// }
this.falg = false
},
// 加载出错
async error(callback) {
this.setNumber()
this.isError = false
if (this.number === 2) {
this.number = 0
callback({ showContent: 'isWeb' })
}
},
//
set(data) {
this.isError = data.isError
},
//
setNumber() {
this.number++
}
}
</script>
<style lang="less" scoped>
.progerss-box {
height: 3px;
width: 100%;
position: fixed;
flex-direction: column;
}
.progerss {
color: #0060FF;
stroke-width: 2.5px;
width: 750px;
background-color: #fff;
}
</style>