|
|
@ -5,19 +5,17 @@ |
|
|
|
<IndicatorHome |
|
|
|
<IndicatorHome |
|
|
|
:isLight="state.subTypeVisible" |
|
|
|
:isLight="state.subTypeVisible" |
|
|
|
v-if="!state.fullScreen" |
|
|
|
v-if="!state.fullScreen" |
|
|
|
:loading="state.loading" |
|
|
|
:loading="loading" |
|
|
|
name="main" |
|
|
|
name="main" |
|
|
|
v-model:index="state.navIndex" |
|
|
|
v-model:index="state.navIndex" |
|
|
|
/> |
|
|
|
/> |
|
|
|
|
|
|
|
<div class="slide-content"> |
|
|
|
<div class="slide-content" |
|
|
|
|
|
|
|
> |
|
|
|
|
|
|
|
<SlideHorizontal class="first-horizontal-item" |
|
|
|
<SlideHorizontal class="first-horizontal-item" |
|
|
|
name="main" |
|
|
|
name="main" |
|
|
|
id="home-index" |
|
|
|
id="home-index" |
|
|
|
:change-active-index-use-anim="false" |
|
|
|
:change-active-index-use-anim="false" |
|
|
|
v-model:index="state.navIndex"> |
|
|
|
v-model:index="state.navIndex"> |
|
|
|
<SlideItem id="slide1"> |
|
|
|
<SlideItem id="slide0"> |
|
|
|
<div class="sub-type" |
|
|
|
<div class="sub-type" |
|
|
|
:class="state.subTypeIsTop?'top':''" |
|
|
|
:class="state.subTypeIsTop?'top':''" |
|
|
|
ref="subTypeRef"> |
|
|
|
ref="subTypeRef"> |
|
|
@ -62,23 +60,23 @@ |
|
|
|
v-if="state.subType===-1 && !state.subTypeVisible" |
|
|
|
v-if="state.subType===-1 && !state.subTypeVisible" |
|
|
|
@click="showSubType">附近吃喝玩乐 |
|
|
|
@click="showSubType">附近吃喝玩乐 |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
<Loading v-if="state.slide0.loading && state.slide0.list.length === 0"/> |
|
|
|
<SlideVerticalInfinite |
|
|
|
<SlideVerticalInfinite |
|
|
|
@touchstart="pageClick" |
|
|
|
@touchstart="pageClick" |
|
|
|
v-love="'home-index'" |
|
|
|
v-love="'slide0-infinite'" |
|
|
|
:style="{background: 'black',marginTop:state.subTypeVisible?state.subTypeHeight:0}" |
|
|
|
:style="{background: 'black',marginTop:state.subTypeVisible?state.subTypeHeight:0}" |
|
|
|
name="main" |
|
|
|
name="main" |
|
|
|
id="slide1-infinite" |
|
|
|
id="slide0-infinite" |
|
|
|
v-model:index="state.itemIndex" |
|
|
|
v-model:index="state.slide0.index" |
|
|
|
:render="render" |
|
|
|
:render="render" |
|
|
|
:list="state.recommendList" |
|
|
|
:list="state.slide0.list" |
|
|
|
:position="{ |
|
|
|
:position="{ |
|
|
|
baseIndex:0, |
|
|
|
baseIndex:0, |
|
|
|
navIndex:5, |
|
|
|
navIndex:0, |
|
|
|
}" |
|
|
|
}" |
|
|
|
@loadMore="loadMore" |
|
|
|
@loadMore="loadSlide1More" |
|
|
|
@refresh="() => getData(true)" |
|
|
|
@refresh="() => getSlide0Data(true)" |
|
|
|
> |
|
|
|
/> |
|
|
|
</SlideVerticalInfinite> |
|
|
|
|
|
|
|
</SlideItem> |
|
|
|
</SlideItem> |
|
|
|
<SlideItem> |
|
|
|
<SlideItem> |
|
|
|
<Community/> |
|
|
|
<Community/> |
|
|
@ -90,19 +88,20 @@ |
|
|
|
<Shop/> |
|
|
|
<Shop/> |
|
|
|
</SlideItem> |
|
|
|
</SlideItem> |
|
|
|
<SlideItem> |
|
|
|
<SlideItem> |
|
|
|
|
|
|
|
<Loading style="position: absolute" v-if="state.slide4.loading && state.slide4.list.length === 0"/> |
|
|
|
<SlideVerticalInfinite |
|
|
|
<SlideVerticalInfinite |
|
|
|
ref="recommendListRef" |
|
|
|
ref="recommendListRef" |
|
|
|
:style="{background: 'black'}" |
|
|
|
:style="{background: 'black'}" |
|
|
|
name="main" |
|
|
|
name="main" |
|
|
|
v-model:index="state.itemIndex" |
|
|
|
v-model:index="state.slide4.index" |
|
|
|
:render="render" |
|
|
|
:render="render" |
|
|
|
:list="state.recommendList" |
|
|
|
:list="state.slide4.list" |
|
|
|
:position="{ |
|
|
|
:position="{ |
|
|
|
baseIndex:0, |
|
|
|
baseIndex:0, |
|
|
|
navIndex:5, |
|
|
|
navIndex:4, |
|
|
|
}" |
|
|
|
}" |
|
|
|
@loadMore="loadMore" |
|
|
|
@loadMore="loadSlide4More" |
|
|
|
@refresh="() => getData(true)" |
|
|
|
@refresh="() => getSlide4Data(true)" |
|
|
|
> |
|
|
|
> |
|
|
|
</SlideVerticalInfinite> |
|
|
|
</SlideVerticalInfinite> |
|
|
|
</SlideItem> |
|
|
|
</SlideItem> |
|
|
@ -187,7 +186,7 @@ import BVideo from "../../components/slide/BVideo.vue"; |
|
|
|
import Comment from "../../components/Comment.vue"; |
|
|
|
import Comment from "../../components/Comment.vue"; |
|
|
|
import Share from "../../components/Share.vue"; |
|
|
|
import Share from "../../components/Share.vue"; |
|
|
|
import IndicatorHome from "./components/IndicatorHome.vue"; |
|
|
|
import IndicatorHome from "./components/IndicatorHome.vue"; |
|
|
|
import {computed, onMounted, onUnmounted, reactive, ref} from "vue"; |
|
|
|
import {computed, onMounted, onUnmounted, reactive, ref, watch} from "vue"; |
|
|
|
import bus, {EVENT_KEY} from "../../utils/bus"; |
|
|
|
import bus, {EVENT_KEY} from "../../utils/bus"; |
|
|
|
import {useNav} from "@/utils/hooks/useNav"; |
|
|
|
import {useNav} from "@/utils/hooks/useNav"; |
|
|
|
import Utils from "@/utils"; |
|
|
|
import Utils from "@/utils"; |
|
|
@ -205,6 +204,7 @@ import ShareToFriend from "@/pages/home/components/ShareToFriend.vue"; |
|
|
|
import UserPanel from "@/components/UserPanel.vue"; |
|
|
|
import UserPanel from "@/components/UserPanel.vue"; |
|
|
|
import Community from "@/pages/home/components/Community.vue"; |
|
|
|
import Community from "@/pages/home/components/Community.vue"; |
|
|
|
import Shop from "@/pages/home/components/Shop.vue"; |
|
|
|
import Shop from "@/pages/home/components/Shop.vue"; |
|
|
|
|
|
|
|
import Loading from "@/components/Loading.vue"; |
|
|
|
|
|
|
|
|
|
|
|
const nav = useNav() |
|
|
|
const nav = useNav() |
|
|
|
|
|
|
|
|
|
|
@ -221,9 +221,49 @@ const subTypeRef = ref(null) |
|
|
|
const recommendListRef = ref(null) |
|
|
|
const recommendListRef = ref(null) |
|
|
|
const state = reactive({ |
|
|
|
const state = reactive({ |
|
|
|
baseIndex: 0, |
|
|
|
baseIndex: 0, |
|
|
|
navIndex: 4, |
|
|
|
navIndex: 0, |
|
|
|
itemIndex: 0, |
|
|
|
|
|
|
|
test: '', |
|
|
|
test: '', |
|
|
|
|
|
|
|
slide0: { |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
index: 0, |
|
|
|
|
|
|
|
list: [], |
|
|
|
|
|
|
|
totalSize: 0, |
|
|
|
|
|
|
|
pageSize: 10, |
|
|
|
|
|
|
|
pageNo: 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
slide1: { |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
index: 0, |
|
|
|
|
|
|
|
list: [], |
|
|
|
|
|
|
|
totalSize: 0, |
|
|
|
|
|
|
|
pageSize: 10, |
|
|
|
|
|
|
|
pageNo: 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
slide2: { |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
index: 0, |
|
|
|
|
|
|
|
list: [], |
|
|
|
|
|
|
|
totalSize: 0, |
|
|
|
|
|
|
|
pageSize: 10, |
|
|
|
|
|
|
|
pageNo: 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
slide3: { |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
index: 0, |
|
|
|
|
|
|
|
list: [], |
|
|
|
|
|
|
|
totalSize: 0, |
|
|
|
|
|
|
|
pageSize: 10, |
|
|
|
|
|
|
|
pageNo: 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
slide4: { |
|
|
|
|
|
|
|
loading: false, |
|
|
|
|
|
|
|
index: 0, |
|
|
|
|
|
|
|
list: [], |
|
|
|
|
|
|
|
totalSize: 0, |
|
|
|
|
|
|
|
pageSize: 10, |
|
|
|
|
|
|
|
pageNo: 0, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
slideOneList: [], |
|
|
|
recommendList: [ |
|
|
|
recommendList: [ |
|
|
|
// { |
|
|
|
// { |
|
|
|
// type: 'img', |
|
|
|
// type: 'img', |
|
|
@ -240,7 +280,6 @@ const state = reactive({ |
|
|
|
], |
|
|
|
], |
|
|
|
isSharing: false, |
|
|
|
isSharing: false, |
|
|
|
canMove: true, |
|
|
|
canMove: true, |
|
|
|
loading: false, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
shareType: -1, |
|
|
|
shareType: -1, |
|
|
|
|
|
|
|
|
|
|
@ -262,36 +301,90 @@ const state = reactive({ |
|
|
|
subTypeHeight: '0', |
|
|
|
subTypeHeight: '0', |
|
|
|
//用于改变zindex的层级到上层,反正比slide高就行。不然摸不到subType. |
|
|
|
//用于改变zindex的层级到上层,反正比slide高就行。不然摸不到subType. |
|
|
|
subTypeIsTop: false, |
|
|
|
subTypeIsTop: false, |
|
|
|
totalSize: 0, |
|
|
|
|
|
|
|
pageSize: 10, |
|
|
|
|
|
|
|
pageNo: 0, |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
async function getData(refresh = false) { |
|
|
|
const loading = computed(() => { |
|
|
|
// if (process.env.NODE_ENV !== 'development') { |
|
|
|
return state[`slide${state.navIndex}`].loading |
|
|
|
// state.totalSize = 11 |
|
|
|
}) |
|
|
|
// return state.recommendVideos = resource.videos |
|
|
|
|
|
|
|
// } |
|
|
|
watch( |
|
|
|
if (state.loading) return |
|
|
|
() => state.navIndex, |
|
|
|
state.loading = true |
|
|
|
(newVal, oldValue) => { |
|
|
|
let res = await api.videos.recommended({pageNo: refresh ? 0 : state.pageNo, pageSize: state.pageSize}) |
|
|
|
if (newVal === 0 && state.slide0.list.length === 0) { |
|
|
|
console.log('loadMore-', 'refresh', refresh, res) |
|
|
|
return getSlide0Data() |
|
|
|
state.loading = false |
|
|
|
} |
|
|
|
|
|
|
|
if (newVal === 4 && state.slide4.list.length === 0) { |
|
|
|
|
|
|
|
return getSlide4Data() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (newVal === 2) return |
|
|
|
|
|
|
|
if ([0, 2, 4].includes(newVal)) { |
|
|
|
|
|
|
|
let playItemIndex = state[`slide${newVal}`].index |
|
|
|
|
|
|
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { |
|
|
|
|
|
|
|
baseIndex: state.baseIndex, |
|
|
|
|
|
|
|
navIndex: newVal, |
|
|
|
|
|
|
|
itemIndex: playItemIndex, |
|
|
|
|
|
|
|
type: EVENT_KEY.ITEM_TOGGLE |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ([0, 2, 4].includes(oldValue)) { |
|
|
|
|
|
|
|
let stopItemIndex = state[`slide${oldValue}`].index |
|
|
|
|
|
|
|
setTimeout(() => { |
|
|
|
|
|
|
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { |
|
|
|
|
|
|
|
baseIndex: state.baseIndex, |
|
|
|
|
|
|
|
navIndex: oldValue, |
|
|
|
|
|
|
|
itemIndex: stopItemIndex, |
|
|
|
|
|
|
|
type: EVENT_KEY.ITEM_STOP |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}, 200) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadSlide1More() { |
|
|
|
|
|
|
|
if (!state.loading) { |
|
|
|
|
|
|
|
state.slide0.pageNo++ |
|
|
|
|
|
|
|
getSlide0Data() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function getSlide0Data(refresh = false) { |
|
|
|
|
|
|
|
if (state.slide0.loading) return |
|
|
|
|
|
|
|
state.slide0.loading = true |
|
|
|
|
|
|
|
let res = await api.videos.recommended({pageNo: refresh ? 0 : state.slide0.pageNo, pageSize: state.slide0.pageSize}) |
|
|
|
|
|
|
|
console.log('getSlide0Data-', 'refresh', refresh, res) |
|
|
|
|
|
|
|
state.slide0.loading = false |
|
|
|
if (res.code === 200) { |
|
|
|
if (res.code === 200) { |
|
|
|
state.totalSize = res.data.total |
|
|
|
state.slide0.totalSize = res.data.total |
|
|
|
if (refresh) { |
|
|
|
if (refresh) { |
|
|
|
state.recommendList = [] |
|
|
|
state.slide0.list = [] |
|
|
|
} |
|
|
|
} |
|
|
|
state.recommendList = state.recommendList.concat(res.data.list) |
|
|
|
state.slide0.list = state.slide0.list.concat(res.data.list) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
state.pageNo-- |
|
|
|
state.slide0.pageNo-- |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function loadMore() { |
|
|
|
async function getSlide4Data(refresh = false) { |
|
|
|
|
|
|
|
if (state.slide4.loading) return |
|
|
|
|
|
|
|
state.slide4.loading = true |
|
|
|
|
|
|
|
let res = await api.videos.recommended({pageNo: refresh ? 0 : state.slide4.pageNo, pageSize: state.slide4.pageSize}) |
|
|
|
|
|
|
|
console.log('getSlide4Data-', 'refresh', refresh, res) |
|
|
|
|
|
|
|
state.slide4.loading = false |
|
|
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
|
|
state.slide4.totalSize = res.data.total |
|
|
|
|
|
|
|
if (refresh) { |
|
|
|
|
|
|
|
state.slide4.list = [] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
state.slide4.list = state.slide4.list.concat(res.data.list) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
state.slide4.pageNo-- |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadSlide4More() { |
|
|
|
if (!state.loading) { |
|
|
|
if (!state.loading) { |
|
|
|
state.pageNo++ |
|
|
|
state.pageNo++ |
|
|
|
getData() |
|
|
|
getSlide4Data() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -330,13 +423,22 @@ function end() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
onMounted(() => { |
|
|
|
getData() |
|
|
|
// getData() |
|
|
|
|
|
|
|
getSlide0Data() |
|
|
|
bus.on(EVENT_KEY.SINGLE_CLICK, () => { |
|
|
|
bus.on(EVENT_KEY.SINGLE_CLICK, () => { |
|
|
|
let id = '' |
|
|
|
let itemIndex = -1 |
|
|
|
if (state.navIndex === 4) { |
|
|
|
if (state.navIndex === 4) { |
|
|
|
id = state.recommendList[state.itemIndex].id |
|
|
|
itemIndex = state.slide4.index |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (state.navIndex === 0) { |
|
|
|
|
|
|
|
itemIndex = state.slide0.index |
|
|
|
} |
|
|
|
} |
|
|
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {id, type: EVENT_KEY.ITEM_TOGGLE}) |
|
|
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, { |
|
|
|
|
|
|
|
baseIndex: state.baseIndex, |
|
|
|
|
|
|
|
navIndex: state.navIndex, |
|
|
|
|
|
|
|
itemIndex, |
|
|
|
|
|
|
|
type: EVENT_KEY.ITEM_TOGGLE |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
bus.on('update:item', val => { |
|
|
|
bus.on('update:item', val => { |
|
|
|
const {baseIndex, navIndex, itemIndex} = val.position |
|
|
|
const {baseIndex, navIndex, itemIndex} = val.position |
|
|
@ -422,7 +524,7 @@ function render(item, itemIndex, play, position) { |
|
|
|
height: calc(100vh - @footer-height) !important; |
|
|
|
height: calc(100vh - @footer-height) !important; |
|
|
|
overflow: hidden; |
|
|
|
overflow: hidden; |
|
|
|
|
|
|
|
|
|
|
|
#slide1 { |
|
|
|
#slide0 { |
|
|
|
position: relative; |
|
|
|
position: relative; |
|
|
|
|
|
|
|
|
|
|
|
.sub-type { |
|
|
|
.sub-type { |
|
|
@ -487,7 +589,7 @@ function render(item, itemIndex, play, position) { |
|
|
|
color: white; |
|
|
|
color: white; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#slide1-infinite { |
|
|
|
#slide0-infinite { |
|
|
|
z-index: 1; |
|
|
|
z-index: 1; |
|
|
|
margin-top: 0; |
|
|
|
margin-top: 0; |
|
|
|
transition: height, margin-top .3s; |
|
|
|
transition: height, margin-top .3s; |
|
|
|