Browse Source

优化首页视频播放逻辑

pull/19/head
zyronon 4 years ago
parent
commit
39d74245a8
  1. 2
      src/components/Footer.vue
  2. 5
      src/components/slide/SlideColumnList.vue
  3. 56
      src/components/slide/SlideRowList.vue
  4. 4
      src/main.js
  5. 2
      src/pages/home/Index2.vue
  6. 15
      src/pages/me/Me.vue

2
src/components/Footer.vue

@ -1,5 +1,5 @@
<template> <template>
<div class="footer f16 "> <div class="footer f16 " @touchmove.stop="false">
<div class="button" @click="refresh()"> <div class="button" @click="refresh()">
<span v-if="!isRefresh" :class="{active:currentTab===1}">首页</span> <span v-if="!isRefresh" :class="{active:currentTab===1}">首页</span>
<img v-else src="../assets/img/icon/refresh.png" alt="" class="refresh"> <img v-else src="../assets/img/icon/refresh.png" alt="" class="refresh">

5
src/components/slide/SlideColumnList.vue

@ -162,7 +162,10 @@ export default {
} }
// console.log('this.isCanDownWiping') // console.log('this.isCanDownWiping')
this.$stopPropagation(e) this.$stopPropagation(e)
this.$setCss(this.slideList, 'transform', `translate3d(0px, ${-this.getHeight(this.currentSlideItemIndex) + this.moveYDistance}px, 0px)`) this.$setCss(this.slideList, 'transform', `translate3d(0px, ${-this.getHeight(this.currentSlideItemIndex) +
this.moveYDistance +
(this.isDrawDown ? this.judgeValue : -this.judgeValue)
}px, 0px)`)
} }
}, },
touchEnd(e) { touchEnd(e) {

56
src/components/slide/SlideRowList.vue

@ -40,7 +40,7 @@
<div class="indicator" ref="indicator"></div> <div class="indicator" ref="indicator"></div>
</div> </div>
<div id="base-slide-list" ref="slideList" <div id="base-slide-list" ref="slideList"
:style="{'flex-direction':direction,marginTop:indicatorFixed?'42px':'0'}" :style="{'flex-direction':'row',marginTop:indicatorFixed?'42px':'0'}"
@touchstart="touchStart($event)" @touchstart="touchStart($event)"
@touchmove="touchMove($event)" @touchmove="touchMove($event)"
@touchend="touchEnd($event)"> @touchend="touchEnd($event)">
@ -59,10 +59,6 @@ export default {
type: Boolean, type: Boolean,
default: () => true default: () => true
}, },
direction: {
type: String,
default: () => 'row'
},
showIndicator: { showIndicator: {
type: Boolean, type: Boolean,
default: () => false default: () => false
@ -79,14 +75,6 @@ export default {
type: Boolean, type: Boolean,
default: () => false default: () => false
}, },
virtual: {
type: Boolean,
default: () => false
},
total: {
type: Number,
default: () => 20
},
activeIndex: { activeIndex: {
type: Number, type: Number,
default: () => 0 default: () => 0
@ -130,7 +118,6 @@ export default {
return { return {
loading: false, loading: false,
wrapperWidth: 0, wrapperWidth: 0,
wrapperHeight: 0,
startLocationX: 0, startLocationX: 0,
startLocationY: 0, startLocationY: 0,
@ -152,7 +139,6 @@ export default {
slideItems: null, slideItems: null,
indicatorRef: null, indicatorRef: null,
slideItemsWidths: [], slideItemsWidths: [],
slideItemsHeights: [],
tabIndicatorRelationActiveIndexLefts: [],//slideItemindexleft, tabIndicatorRelationActiveIndexLefts: [],//slideItemindexleft,
indicatorSpace: 0,//indicator indicatorSpace: 0,//indicator
toolbarStyleTransitionDuration: 0, toolbarStyleTransitionDuration: 0,
@ -162,7 +148,6 @@ export default {
}, },
watch: { watch: {
activeIndex() { activeIndex() {
// console.log('activeIndex')
this.changeIndex() this.changeIndex()
}, },
}, },
@ -180,7 +165,6 @@ export default {
this.$setCss(this.indicatorRef, 'left', this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] + 'px') this.$setCss(this.indicatorRef, 'left', this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] + 'px')
} }
this.$attrs['onUpdate:active-index'] && this.$emit('update:active-index', this.currentSlideItemIndex) this.$attrs['onUpdate:active-index'] && this.$emit('update:active-index', this.currentSlideItemIndex)
}, },
initTabs() { initTabs() {
let tabs = this.$refs.tabs let tabs = this.$refs.tabs
@ -198,16 +182,14 @@ export default {
} }
}, },
async checkChildren(init) { async checkChildren(init) {
await nextTick(() => { this.slideList = this.$refs.slideList
this.slideList = this.$refs.slideList this.slideItems = this.slideList.children
this.slideItems = this.slideList.children this.wrapperWidth = this.$getCss(this.slideList, 'width')
this.wrapperWidth = this.$getCss(this.slideList, 'width') this.wrapperHeight = this.$getCss(this.slideList, 'height')
this.wrapperHeight = this.$getCss(this.slideList, 'height') for (let i = 0; i < this.slideItems.length; i++) {
for (let i = 0; i < this.slideItems.length; i++) { let el = this.slideItems[i]
let el = this.slideItems[i] this.slideItemsWidths.push(this.$getCss(el, 'width'))
this.slideItemsWidths.push(this.$getCss(el, 'width')) }
}
})
}, },
touchStart(e) { touchStart(e) {
this.$setCss(this.slideList, 'transition-duration', `0ms`) this.$setCss(this.slideList, 'transition-duration', `0ms`)
@ -228,7 +210,6 @@ export default {
this.checkDirection() this.checkDirection()
//me //me
if (!this.isDrawDown) { if (!this.isDrawDown) {
this.$attrs['onFirst'] && this.$emit('first', this.moveYDistance) this.$attrs['onFirst'] && this.$emit('first', this.moveYDistance)
@ -240,6 +221,12 @@ export default {
// y: {distance: this.moveYDistance, isDrawDown: this.isDrawDown}, // y: {distance: this.moveYDistance, isDrawDown: this.isDrawDown},
// }) // })
//this.isCanDownWiping toolbar
//slideitem使moveYDistance
if (this.isCanDownWiping && this.useHomeLoading && !this.loading) {
this.homeLoadingMoveYDistance = this.moveYDistance > 0 ? this.moveYDistance : 0
}
if (this.isCanRightWiping) { if (this.isCanRightWiping) {
// //index=0 // //index=0
if (this.currentSlideItemIndex === 0 && !this.isDrawRight) return if (this.currentSlideItemIndex === 0 && !this.isDrawRight) return
@ -247,17 +234,12 @@ export default {
if (this.currentSlideItemIndex === this.slideItems.length - 1 && this.isDrawRight) return if (this.currentSlideItemIndex === this.slideItems.length - 1 && this.isDrawRight) return
this.$stopPropagation(e) this.$stopPropagation(e)
this.$setCss(this.slideList, 'transform', `translate3d(${-this.getWidth(this.currentSlideItemIndex) + this.moveXDistance}px, 0px, 0px)`) this.$setCss(this.slideList, 'transform', `translate3d(${-this.getWidth(this.currentSlideItemIndex) +
this.moveXDistance +
(this.isDrawRight ? this.judgeValue : -this.judgeValue)}px, 0px, 0px)`)
this.showIndicator && this.$setCss(this.indicatorRef, 'left', this.showIndicator && this.$setCss(this.indicatorRef, 'left',
this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] - this.tabIndicatorRelationActiveIndexLefts[this.currentSlideItemIndex] -
this.moveXDistance / (this.$store.state.bodyWidth / this.indicatorSpace) + 'px') this.moveXDistance / (this.$store.state.bodyWidth / this.indicatorSpace) + 'px')
} else {
//this.isCanDownWiping toolbar
//slideitem使moveYDistance
if (this.useHomeLoading && !this.loading) {
this.homeLoadingMoveYDistance = this.moveYDistance > 0 ? this.moveYDistance : 0
}
} }
}, },
getData() { getData() {
@ -332,12 +314,14 @@ export default {
let angle = (Math.abs(this.moveXDistance) * 10) / (Math.abs(this.moveYDistance) * 10) let angle = (Math.abs(this.moveXDistance) * 10) / (Math.abs(this.moveYDistance) * 10)
if (angle < 0.6) { if (angle < 0.6) {
// //
this.isCanDownWiping = true
this.isCanRightWiping = false this.isCanRightWiping = false
this.isNeedCheck = false this.isNeedCheck = false
return return
} }
if (angle > 5) { if (angle > 5) {
// //
this.isCanDownWiping = false
this.isCanRightWiping = true this.isCanRightWiping = true
this.isNeedCheck = false this.isNeedCheck = false
} }

4
src/main.js

@ -14,6 +14,8 @@ import Footer from "./components/Footer";
import router from "./router"; import router from "./router";
import store from "./store"; import store from "./store";
import globalMethods from './utils/global-methods' import globalMethods from './utils/global-methods'
import SlideRowList from "./components/slide/SlideRowList";
import SlideColumnList from "./components/slide/SlideColumnList";
const mixin = { const mixin = {
methods: { methods: {
@ -25,6 +27,8 @@ app.provide('mitt', mitt())
app.component('BaseHeader', BaseHeader) app.component('BaseHeader', BaseHeader)
app.component('SlideList', SlideList) app.component('SlideList', SlideList)
app.component('SlideRowList', SlideRowList)
app.component('SlideColumnList', SlideColumnList)
app.component('SlideItem', SlideItem) app.component('SlideItem', SlideItem)
app.component('Video1', Video) app.component('Video1', Video)
app.component('Footer', Footer) app.component('Footer', Footer)

2
src/pages/home/Index2.vue

@ -404,7 +404,7 @@ export default {
isSharing: false, isSharing: false,
videoActiveIndex: 0, videoActiveIndex: 0,
baseActiveIndex: 0, baseActiveIndex: 0,
activeIndex: 0, activeIndex: 1,
render: (item, itemIndex) => { render: (item, itemIndex) => {
return ( return (
<div className="base-slide-item video-slide-item" data-index={itemIndex}> <div className="base-slide-item video-slide-item" data-index={itemIndex}>

15
src/pages/me/Me.vue

@ -1,6 +1,6 @@
<template> <template>
<div class="Me"> <div class="Me">
<SlideList style="width: 100vw;" <SlideRowList style="width: 100vw;"
@first="first" @first="first"
@end="end" @end="end"
v-model:active-index="baseActiveIndex" v-model:active-index="baseActiveIndex"
@ -58,7 +58,7 @@
</div> </div>
</div> </div>
<div ref="content" style="margin-bottom: 60px;"> <div ref="content" style="margin-bottom: 60px;">
<SlideList <SlideRowList
:show-indicator="true" :show-indicator="true"
:indicator-fixed="indicatorFixed" :indicator-fixed="indicatorFixed"
indicator-type="me" indicator-type="me"
@ -66,10 +66,8 @@
v-model:active-index="contentIndex"> v-model:active-index="contentIndex">
<SlideItem> <SlideItem>
<div ref="tab-content1"> <div ref="tab-content1">
<div class="posters"> <Posters></Posters>
<Posters></Posters> <div class="no-more">暂时没有更多了</div>
<div class="no-more">暂时没有更多了</div>
</div>
</div> </div>
</SlideItem> </SlideItem>
<SlideItem> <SlideItem>
@ -84,7 +82,7 @@
<div class="no-more">暂时没有更多了</div> <div class="no-more">暂时没有更多了</div>
</div> </div>
</SlideItem> </SlideItem>
</SlideList> </SlideRowList>
</div> </div>
<Footer v-bind:init-tab="5"/> <Footer v-bind:init-tab="5"/>
</SlideItem> </SlideItem>
@ -194,7 +192,7 @@
</div> </div>
</div> </div>
</SlideItem> </SlideItem>
</SlideList> </SlideRowList>
</div> </div>
</template> </template>
<script> <script>
@ -219,7 +217,6 @@ export default {
headerHeight: 0, headerHeight: 0,
}, },
isMoreFunction: false, isMoreFunction: false,
} }
}, },
watch: { watch: {

Loading…
Cancel
Save