Commit 16c70007 by 胡悦

修改动画效果

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