Commit 16c70007 by 胡悦

修改动画效果

1 parent 3228f165
......@@ -2,7 +2,7 @@
<div class="markeing-box">
<Phone :imgName="'ai-dialogue'">
<div class="dialogue-content" slot="content">
<div v-show="showQ" class="dialog-item">
<div v-if="showQ" class="dialog-item">
<div class="user-content m-l">为什么这么贵?不就是一层塑料纸吗?</div>
<img class="avatar m-s-l" src="../../../assets//images/user-avatar.png" alt="">
</div>
......@@ -27,8 +27,6 @@
</div>
</template>
<script>
let t = null
let pNode = null
import Phone from "./Phone.vue"
export default {
name: 'MarketingQuestion',
......@@ -38,49 +36,51 @@ export default {
data() {
return {
showQ: false,
showR: false
showR: false,
pNode: null,
timer: null
}
},
mounted() {
pNode = document.getElementById('qestion-1')
this.pNode = document.getElementById('qestion-1')
// const str = '这位先生/女士/老板,一分钱一分货,就像同一款衣服,为什么有上万的,也有几百的,它材质是不一样的,表面上看它可能就是一层塑料,但是它里边的这个结构是非常复杂的,不同的结构,有的膜是五层、有的膜是七层、还有的十几层那都是有区别的,况且我们这个价格是全国统一价,你在官网是能查到的,这对车主来说是最公平合理。'
this.showText()
t = setInterval(() => {
pNode.innerHTML = ''
this.showText()
}, 10000)
// t = setInterval(this.showText, 10000)
},
methods: {
showText() {
if (!this.showQ) {
this.showQ = true
setTimeout(() => {
this.addText()
this.showR = true
}, 1000)
} else {
this.showQ = false
this.showR = false
setTimeout(() => {
this.showText()
}, 1000)
}
this.showQ = true
setTimeout(() => {
this.addText()
this.showR = true
}, 1000)
},
addText() {
const str = '这位先生/女士/老板,一分钱一分货,就像同一款衣服,为什么有上万的,也有几百的,它材质是不一样的,表面上看它可能就是一层塑料,但是它里边的这个结构是非常复杂的,不同的结构,有的膜是五层、有的膜是七层、还有的十几层那都是有区别的,况且我们这个价格是全国统一价,你在官网是能查到的,这对车主来说是最公平合理。'
let i = 0
const timer = setInterval(() => {
this.timer = setInterval(() => {
if (i < str.length - 1) {
pNode.innerHTML = pNode.innerHTML + str[i]
this.pNode.innerHTML = this.pNode.innerHTML + str[i]
i = i + 1
} else {
clearInterval(timer)
clearInterval(this.timer)
setTimeout(() => {
this.showQ = false
this.showR = false
this.pNode.innerHTML = ''
setTimeout(() => {
this.showText()
}, 1000)
}, 1000)
}
}, 50)
}
},
destroyed() {
clearInterval(t)
beforeDestroy() {
this.showQ = false
this.showR = false
this.pNode.innerHTML = ''
clearInterval(this.timer)
}
}
</script>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!