Browse Source

refactor: ♻️ 去除顾客心声自动播放 修改自动返回时长为1分钟

pull/20/head
姜鑫 2 years ago
parent
commit
93f556e8d7
  1. 4
      src/App.vue
  2. 20
      src/components/ScrollList/ScrollList.vue

4
src/App.vue

@ -38,8 +38,8 @@ onMounted(() => {
_getCustomerList()
timer = setInterval(() => {
_getCustomerList()
scrollList.value?.start()
}, 60000 * 5)
scrollList.value?.scrollTo(0, 1000, false)
}, 1000 * 60)
})
onBeforeUnmount(() => {
clearInterval(timer)

20
src/components/ScrollList/ScrollList.vue

@ -4,7 +4,6 @@
<Swiper
v-if="chunkList.length"
rewind
:autoplay="chunkList.length > 1 ? { delay: 15000 } : false"
observer
observe-parents
observe-slide-children
@ -28,7 +27,7 @@
</template>
<script setup lang="ts">
import { ref, computed, onMounted, onBeforeUnmount } from 'vue'
import { shallowRef, computed, onMounted, onBeforeUnmount } from 'vue'
import { chunk } from 'lodash-es'
import ScrollListItem from '@/components/ScrollListItem/ScrollListItem.vue'
import SwiperCore, { Autoplay } from 'swiper'
@ -51,27 +50,14 @@ const props = withDefaults(defineProps<Props>(), {
const chunkList = computed(() => chunk(props.customerList, 6))
const swiper = ref()
const swiper = shallowRef()
function swiperInit(_swiper: any) {
swiper.value = _swiper
}
function start() {
swiper.value?.autoplay?.start()
}
function stop() {
swiper.value?.autoplay?.stop()
}
onMounted(() => {
window.addEventListener('touchend', stop)
})
onBeforeUnmount(() => {
window.removeEventListener('touchend', stop)
})
defineExpose({
start
swiper
})
</script>

Loading…
Cancel
Save