|
|
|
@ -1,16 +1,15 @@
@@ -1,16 +1,15 @@
|
|
|
|
|
<template> |
|
|
|
|
<SlideVerticalInfinite |
|
|
|
|
ref="listRef" |
|
|
|
|
v-love="htmlId" |
|
|
|
|
v-love="state.uniqueId" |
|
|
|
|
:id="state.uniqueId" |
|
|
|
|
:uniqueId="state.uniqueId" |
|
|
|
|
name="main" |
|
|
|
|
:id="htmlId" |
|
|
|
|
:active="props.active" |
|
|
|
|
:loading="loading" |
|
|
|
|
v-model:index="state.index" |
|
|
|
|
:render="render" |
|
|
|
|
:list="state.list" |
|
|
|
|
:position="{ |
|
|
|
|
baseIndex:0, |
|
|
|
|
navIndex:0, |
|
|
|
|
}" |
|
|
|
|
@loadMore="loadMore" |
|
|
|
|
@refresh="() => getData(true)" |
|
|
|
|
/> |
|
|
|
@ -18,11 +17,13 @@
@@ -18,11 +17,13 @@
|
|
|
|
|
|
|
|
|
|
<script setup lang="jsx"> |
|
|
|
|
import SlideVerticalInfinite from '@/components/slide/SlideVerticalInfinite.vue' |
|
|
|
|
import {onMounted, onUnmounted, reactive, ref, watch} from "vue"; |
|
|
|
|
import {computed, onMounted, onUnmounted, reactive, ref, watch} from "vue"; |
|
|
|
|
import bus, {EVENT_KEY} from "@/utils/bus"; |
|
|
|
|
import Utils from "@/utils"; |
|
|
|
|
import {useSlideListItemRender} from "@/utils/hooks/useSlideListItemRender"; |
|
|
|
|
import Loading from "@/components/Loading.vue"; |
|
|
|
|
import {useStore} from "vuex"; |
|
|
|
|
import {uniqueId} from "lodash"; |
|
|
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
|
cbs: { |
|
|
|
@ -39,10 +40,6 @@ const props = defineProps({
@@ -39,10 +40,6 @@ const props = defineProps({
|
|
|
|
|
type: Function, |
|
|
|
|
default: void 0 |
|
|
|
|
}, |
|
|
|
|
htmlId: { |
|
|
|
|
type: String, |
|
|
|
|
default: 'guid' |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
const emit = defineEmits([ |
|
|
|
|
'update:item', |
|
|
|
@ -52,6 +49,9 @@ const emit = defineEmits([
@@ -52,6 +49,9 @@ const emit = defineEmits([
|
|
|
|
|
'goMusic', |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
const store = useStore() |
|
|
|
|
const loading = computed(() => store.state.loading) |
|
|
|
|
|
|
|
|
|
function stop(e) { |
|
|
|
|
e.stopPropagation() |
|
|
|
|
} |
|
|
|
@ -62,31 +62,9 @@ const p = {
@@ -62,31 +62,9 @@ const p = {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
watch( |
|
|
|
|
() => props.active, |
|
|
|
|
(newVal, oldVal) => { |
|
|
|
|
console.log('newVal', newVal, 'oldVal', oldVal) |
|
|
|
|
if (newVal === false) { |
|
|
|
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { |
|
|
|
|
baseIndex: 0, |
|
|
|
|
navIndex: 0, |
|
|
|
|
itemIndex: state.index, |
|
|
|
|
type: EVENT_KEY.ITEM_STOP |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { |
|
|
|
|
baseIndex: 0, |
|
|
|
|
navIndex: 0, |
|
|
|
|
itemIndex: state.index, |
|
|
|
|
type: EVENT_KEY.ITEM_PLAY |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
const render = useSlideListItemRender({...props.cbs, ...p}) |
|
|
|
|
const subTypeRef = ref(null) |
|
|
|
|
const listRef = ref(null) |
|
|
|
|
const state = reactive({ |
|
|
|
|
loading: false, |
|
|
|
|
index: 0, |
|
|
|
|
list: [ |
|
|
|
|
// { |
|
|
|
@ -94,24 +72,25 @@ const state = reactive({
@@ -94,24 +72,25 @@ const state = reactive({
|
|
|
|
|
// src: `http://douyin.ttentau.top/0.mp4?vframe/jpg/offset/0/w/${document.body.clientWidth}` |
|
|
|
|
// }, |
|
|
|
|
], |
|
|
|
|
uniqueId: uniqueId('uniqueId_'), |
|
|
|
|
totalSize: 0, |
|
|
|
|
pageSize: 10, |
|
|
|
|
pageNo: 0, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
function loadMore() { |
|
|
|
|
if (!state.loading) { |
|
|
|
|
if (!loading.value) { |
|
|
|
|
state.pageNo++ |
|
|
|
|
getData() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function getData(refresh = false) { |
|
|
|
|
if (state.loading) return |
|
|
|
|
state.loading = true |
|
|
|
|
if (loading.value) return |
|
|
|
|
store.commit('setLoading', true) |
|
|
|
|
let res = await props.api({pageNo: refresh ? 0 : state.pageNo, pageSize: state.pageSize}) |
|
|
|
|
console.log('getSlide0Data-', 'refresh', refresh, res) |
|
|
|
|
state.loading = false |
|
|
|
|
store.commit('setLoading', false) |
|
|
|
|
if (res.code === 200) { |
|
|
|
|
state.totalSize = res.data.total |
|
|
|
|
if (refresh) { |
|
|
|
@ -133,22 +112,29 @@ function end() {
@@ -133,22 +112,29 @@ function end() {
|
|
|
|
|
// this.$notice('暂时没有更多了') |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function click(htmlId) { |
|
|
|
|
if (htmlId !== props.htmlId) return |
|
|
|
|
function click(uniqueId) { |
|
|
|
|
if (uniqueId !== state.uniqueId) return |
|
|
|
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { |
|
|
|
|
baseIndex: 0, |
|
|
|
|
navIndex: 0, |
|
|
|
|
itemIndex: state.index, |
|
|
|
|
uniqueId, |
|
|
|
|
index: state.index, |
|
|
|
|
type: EVENT_KEY.ITEM_TOGGLE |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function updateItem({position, item}) { |
|
|
|
|
console.log('po', position) |
|
|
|
|
if (position.uniqueId === state.uniqueId) { |
|
|
|
|
state.list[position.index] = item |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
// getData() |
|
|
|
|
getData() |
|
|
|
|
bus.on(EVENT_KEY.SINGLE_CLICK, click) |
|
|
|
|
bus.on(EVENT_KEY.UPDATE_ITEM, updateItem) |
|
|
|
|
}) |
|
|
|
|
onUnmounted(() => { |
|
|
|
|
bus.off(EVENT_KEY.SINGLE_CLICK, click) |
|
|
|
|
bus.on(EVENT_KEY.UPDATE_ITEM, updateItem) |
|
|
|
|
}) |
|
|
|
|
</script> |
|
|
|
|