@ -5,19 +5,17 @@
@@ -5,19 +5,17 @@
< IndicatorHome
: isLight = "state.subTypeVisible"
v - if = "!state.fullScreen"
: loading = "state. loading"
: loading = "loading"
name = "main"
v - model : index = "state.navIndex"
/ >
< div class = "slide-content"
>
< div class = "slide-content" >
< SlideHorizontal class = "first-horizontal-item"
name = "main"
id = "home-index"
: change - active - index - use - anim = "false"
v - model : index = "state.navIndex" >
< SlideItem id = "slide1 " >
< SlideItem id = "slide0 " >
< div class = "sub-type"
: class = "state.subTypeIsTop?'top':''"
ref = "subTypeRef" >
@ -62,23 +60,23 @@
@@ -62,23 +60,23 @@
v - if = "state.subType===-1 && !state.subTypeVisible"
@ click = "showSubType" > 附近吃喝玩乐
< / div >
< Loading v -if = " state.slide0.loading & & state.slide0.list.length = = = 0 " / >
< SlideVerticalInfinite
@ touchstart = "pageClick"
v - love = "'home-index '"
v - love = "'slide0-infinite '"
: style = "{background: 'black',marginTop:state.subTypeVisible?state.subTypeHeight:0}"
name = "main"
id = "slide1 -infinite"
v - model : index = "state.itemI ndex"
id = "slide0 -infinite"
v - model : index = "state.slide0.i ndex"
: render = "render"
: list = "state.recommendL ist"
: list = "state.slide0.l ist"
: position = " {
baseIndex : 0 ,
navIndex : 5 ,
navIndex : 0 ,
} "
@ loadMore = "loadMore"
@ refresh = "() => getData(true)"
>
< / SlideVerticalInfinite >
@ loadMore = "loadSlide1More"
@ refresh = "() => getSlide0Data(true)"
/ >
< / SlideItem >
< SlideItem >
< Community / >
@ -90,19 +88,20 @@
@@ -90,19 +88,20 @@
< Shop / >
< / SlideItem >
< SlideItem >
< Loading style = "position: absolute" v -if = " state.slide4.loading & & state.slide4.list.length = = = 0 " / >
< SlideVerticalInfinite
ref = "recommendListRef"
: style = "{background: 'black'}"
name = "main"
v - model : index = "state.itemI ndex"
v - model : index = "state.slide4.i ndex"
: render = "render"
: list = "state.recommendL ist"
: list = "state.slide4.l ist"
: position = " {
baseIndex : 0 ,
navIndex : 5 ,
navIndex : 4 ,
} "
@ loadMore = "loadMore"
@ refresh = "() => getData(true)"
@ loadMore = "loadSlide4 More"
@ refresh = "() => getSlide4 Data(true)"
>
< / SlideVerticalInfinite >
< / SlideItem >
@ -187,7 +186,7 @@ import BVideo from "../../components/slide/BVideo.vue";
@@ -187,7 +186,7 @@ import BVideo from "../../components/slide/BVideo.vue";
import Comment from "../../components/Comment.vue" ;
import Share from "../../components/Share.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 { useNav } from "@/utils/hooks/useNav" ;
import Utils from "@/utils" ;
@ -205,6 +204,7 @@ import ShareToFriend from "@/pages/home/components/ShareToFriend.vue";
@@ -205,6 +204,7 @@ import ShareToFriend from "@/pages/home/components/ShareToFriend.vue";
import UserPanel from "@/components/UserPanel.vue" ;
import Community from "@/pages/home/components/Community.vue" ;
import Shop from "@/pages/home/components/Shop.vue" ;
import Loading from "@/components/Loading.vue" ;
const nav = useNav ( )
@ -221,9 +221,49 @@ const subTypeRef = ref(null)
@@ -221,9 +221,49 @@ const subTypeRef = ref(null)
const recommendListRef = ref ( null )
const state = reactive ( {
baseIndex : 0 ,
navIndex : 4 ,
itemIndex : 0 ,
navIndex : 0 ,
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 : [
/ / {
/ / t y p e : ' i m g ' ,
@ -240,7 +280,6 @@ const state = reactive({
@@ -240,7 +280,6 @@ const state = reactive({
] ,
isSharing : false ,
canMove : true ,
loading : false ,
shareType : - 1 ,
@ -262,36 +301,90 @@ const state = reactive({
@@ -262,36 +301,90 @@ const state = reactive({
subTypeHeight : '0' ,
/ / 用 于 改 变 z i n d e x 的 层 级 到 上 层 , 反 正 比 s l i d e 高 就 行 。 不 然 摸 不 到 s u b T y p e .
subTypeIsTop : false ,
totalSize : 0 ,
pageSize : 10 ,
pageNo : 0 ,
} )
async function getData ( refresh = false ) {
/ / i f ( p r o c e s s . e n v . N O D E _ E N V ! = = ' d e v e l o p m e n t ' ) {
/ / s t a t e . t o t a l S i z e = 1 1
/ / r e t u r n s t a t e . r e c o m m e n d V i d e o s = r e s o u r c e . v i d e o s
/ / }
if ( state . loading ) return
state . loading = true
let res = await api . videos . recommended ( { pageNo : refresh ? 0 : state . pageNo , pageSize : state . pageSize } )
console . log ( 'loadMore-' , 'refresh' , refresh , res )
state . loading = false
const loading = computed ( ( ) => {
return state [ ` slide ${ state . navIndex } ` ] . loading
} )
watch (
( ) => state . navIndex ,
( newVal , oldValue ) => {
if ( newVal === 0 && state . slide0 . list . length === 0 ) {
return getSlide0Data ( )
}
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 ) {
state . totalSize = res . data . total
state . slide0 . totalSize = res . data . total
if ( refresh ) {
state . recommendList = [ ]
state . slide0 . l ist = [ ]
}
state . recommendList = state . recommendList . concat ( res . data . list )
state . slide0 . l ist = state . slide0 . l ist. concat ( res . data . list )
} 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 ) {
state . pageNo ++
getData ( )
getSlide4 Data ( )
}
}
@ -330,13 +423,22 @@ function end() {
@@ -330,13 +423,22 @@ function end() {
}
onMounted ( ( ) => {
getData ( )
/ / g e t D a t a ( )
getSlide0Data ( )
bus . on ( EVENT _KEY . SINGLE _CLICK , ( ) => {
let id = ''
let itemIndex = - 1
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 => {
const { baseIndex , navIndex , itemIndex } = val . position
@ -422,7 +524,7 @@ function render(item, itemIndex, play, position) {
@@ -422,7 +524,7 @@ function render(item, itemIndex, play, position) {
height : calc ( 100 vh - @ footer - height ) ! important ;
overflow : hidden ;
# slide1 {
# slide0 {
position : relative ;
. sub - type {
@ -487,7 +589,7 @@ function render(item, itemIndex, play, position) {
@@ -487,7 +589,7 @@ function render(item, itemIndex, play, position) {
color : white ;
}
# slide1 - infinite {
# slide0 - infinite {
z - index : 1 ;
margin - top : 0 ;
transition : height , margin - top .3 s ;