优化
This commit is contained in:
parent
e12c0387d4
commit
e5a5516781
@ -53,8 +53,8 @@
|
|||||||
@touchend="touchend"
|
@touchend="touchend"
|
||||||
>
|
>
|
||||||
<div class="time" v-if="isMove">
|
<div class="time" v-if="isMove">
|
||||||
<span class="currentTime">{{ $duration(currentTime) }}</span>
|
<span class="currentTime">{{ LUtils.$duration(currentTime) }}</span>
|
||||||
<span class="duration"> / {{ $duration(duration) }}</span>
|
<span class="duration"> / {{ LUtils.$duration(duration) }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="bg"></div>
|
<div class="bg"></div>
|
||||||
<div class="progress-line" :style="durationStyle"></div>
|
<div class="progress-line" :style="durationStyle"></div>
|
||||||
@ -158,7 +158,7 @@ export default {
|
|||||||
height: 0,
|
height: 0,
|
||||||
width: 0,
|
width: 0,
|
||||||
isMove: false,
|
isMove: false,
|
||||||
isSingleClick: false,
|
ignoreWaiting: false,//忽略waiting事件。因为改变进度会触发waiting事件,烦的一批
|
||||||
test: [1, 2],
|
test: [1, 2],
|
||||||
localItem: this.item,
|
localItem: this.item,
|
||||||
progressBarRect: {},
|
progressBarRect: {},
|
||||||
@ -166,6 +166,7 @@ export default {
|
|||||||
videoPoster: `?vframe/jpg/offset/0/w/${document.body.clientWidth}`,
|
videoPoster: `?vframe/jpg/offset/0/w/${document.body.clientWidth}`,
|
||||||
commentVisible: false,
|
commentVisible: false,
|
||||||
isMarginTop: false,
|
isMarginTop: false,
|
||||||
|
LUtils: Utils
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -188,9 +189,10 @@ export default {
|
|||||||
|
|
||||||
let eventTester = (e, t) => {
|
let eventTester = (e, t) => {
|
||||||
video.addEventListener(e, () => {
|
video.addEventListener(e, () => {
|
||||||
|
// console.log('eventTester', e, this.item.id)
|
||||||
if (e === 'playing') this.loading = false
|
if (e === 'playing') this.loading = false
|
||||||
if (e === 'waiting') {
|
if (e === 'waiting') {
|
||||||
if (!this.paused && !this.isSingleClick) {
|
if (!this.paused && !this.ignoreWaiting) {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -283,26 +285,31 @@ export default {
|
|||||||
this.commentVisible = false
|
this.commentVisible = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
click(val) {
|
click({id, type}) {
|
||||||
if (this.item.id === val) {
|
if (this.item.id === id) {
|
||||||
|
if (type === EVENT_KEY.ITEM_TOGGLE) {
|
||||||
if (this.status === SlideItemPlayStatus.Play) {
|
if (this.status === SlideItemPlayStatus.Play) {
|
||||||
this.pause()
|
this.pause()
|
||||||
} else {
|
} else {
|
||||||
this.play()
|
this.play()
|
||||||
//这里playg事件,触发之后,会马上触发一次waiting事件。就很烦,会出现点完播放之后闪一下loading的情况,所以用一个变量来规避一下
|
|
||||||
// this.isSingleClick = true
|
|
||||||
setTimeout(() => {
|
|
||||||
// this.isSingleClick = false
|
|
||||||
}, 300)
|
|
||||||
}
|
}
|
||||||
this.loading = false
|
}
|
||||||
|
if (type === EVENT_KEY.ITEM_STOP) {
|
||||||
|
this.$refs.video.currentTime = 0
|
||||||
|
this.ignoreWaiting = true
|
||||||
|
this.pause()
|
||||||
|
setTimeout(() => this.ignoreWaiting = false, 300)
|
||||||
|
}
|
||||||
|
if (type === EVENT_KEY.ITEM_PLAY) {
|
||||||
|
this.$refs.video.currentTime = 0
|
||||||
|
this.ignoreWaiting = true
|
||||||
|
this.play()
|
||||||
|
setTimeout(() => this.ignoreWaiting = false, 300)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
play() {
|
play() {
|
||||||
this.status = SlideItemPlayStatus.Play
|
this.status = SlideItemPlayStatus.Play
|
||||||
if (this.currentTime !== -1) {
|
|
||||||
this.$refs.video.currentTime = this.currentTime
|
|
||||||
}
|
|
||||||
this.$refs.video.volume = 1
|
this.$refs.video.volume = 1
|
||||||
this.$refs.video.play()
|
this.$refs.video.play()
|
||||||
},
|
},
|
||||||
@ -310,9 +317,6 @@ export default {
|
|||||||
this.status = SlideItemPlayStatus.Pause
|
this.status = SlideItemPlayStatus.Pause
|
||||||
this.$refs.video.pause()
|
this.$refs.video.pause()
|
||||||
},
|
},
|
||||||
formatNumber(v) {
|
|
||||||
return Utils.formatNumber(v)
|
|
||||||
},
|
|
||||||
touchstart(e) {
|
touchstart(e) {
|
||||||
Utils.$stopPropagation(e)
|
Utils.$stopPropagation(e)
|
||||||
this.start.x = e.touches[0].pageX
|
this.start.x = e.touches[0].pageX
|
||||||
@ -335,6 +339,7 @@ export default {
|
|||||||
Utils.$stopPropagation(e)
|
Utils.$stopPropagation(e)
|
||||||
if (this.isPlaying) return
|
if (this.isPlaying) return
|
||||||
setTimeout(() => this.isMove = false, 1000)
|
setTimeout(() => this.isMove = false, 1000)
|
||||||
|
this.$refs.video.currentTime = this.currentTime
|
||||||
this.play()
|
this.play()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import GM from '../../utils'
|
|||||||
import {getSlideDistance, slideInit, slideReset, slideTouchEnd, slideTouchMove, slideTouchStart} from "./common";
|
import {getSlideDistance, slideInit, slideReset, slideTouchEnd, slideTouchMove, slideTouchStart} from "./common";
|
||||||
import {SlideType} from "../../utils/const_var";
|
import {SlideType} from "../../utils/const_var";
|
||||||
import SlideItem from './SlideItem'
|
import SlideItem from './SlideItem'
|
||||||
import bus from "../../utils/bus";
|
import bus, {EVENT_KEY} from "../../utils/bus";
|
||||||
import {useStore} from 'vuex'
|
import {useStore} from 'vuex'
|
||||||
import Utils from "../../utils";
|
import Utils from "../../utils";
|
||||||
import Dom from "@/utils/dom";
|
import Dom from "@/utils/dom";
|
||||||
@ -92,11 +92,18 @@ watch(
|
|||||||
)
|
)
|
||||||
watch(
|
watch(
|
||||||
() => props.index,
|
() => props.index,
|
||||||
()=>{
|
(newVal, oldVal) => {
|
||||||
// new Dom(this.wrapper).find(`.v-${this.prefix}-${newVal}-video`).trigger('play')
|
// console.log('watch-index', newVal, oldVal, props.list[newVal].id)
|
||||||
// setTimeout(() => {
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {
|
||||||
// new Dom(this.wrapper).find(`.v-${this.prefix}-${oldVal}-video`).trigger('stop')
|
id: props.list[newVal].id,
|
||||||
// }, 200)
|
type: EVENT_KEY.ITEM_PLAY
|
||||||
|
})
|
||||||
|
setTimeout(() => {
|
||||||
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {
|
||||||
|
id: props.list[oldVal].id,
|
||||||
|
type: EVENT_KEY.ITEM_STOP
|
||||||
|
})
|
||||||
|
}, 200)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@ -335,12 +335,12 @@ function end() {
|
|||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getData()
|
getData()
|
||||||
bus.on('singleClick', () => {
|
bus.on(EVENT_KEY.SINGLE_CLICK, () => {
|
||||||
let id = ''
|
let id = ''
|
||||||
if (state.navIndex === 4) {
|
if (state.navIndex === 4) {
|
||||||
id = state.recommendVideos[state.itemIndex].id
|
id = state.recommendVideos[state.itemIndex].id
|
||||||
}
|
}
|
||||||
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, id)
|
bus.emit(EVENT_KEY.SINGLE_CLICK_BROADCAST, {id, 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
|
||||||
|
|||||||
@ -42,6 +42,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const EVENT_KEY = {
|
export const EVENT_KEY = {
|
||||||
|
SINGLE_CLICK: 'SINGLE_CLICK',
|
||||||
SINGLE_CLICK_BROADCAST: 'SINGLE_CLICK_BROADCAST',
|
SINGLE_CLICK_BROADCAST: 'SINGLE_CLICK_BROADCAST',
|
||||||
ENTER_FULLSCREEN: 'ENTER_FULLSCREEN',
|
ENTER_FULLSCREEN: 'ENTER_FULLSCREEN',
|
||||||
EXIT_FULLSCREEN: 'EXIT_FULLSCREEN',
|
EXIT_FULLSCREEN: 'EXIT_FULLSCREEN',
|
||||||
@ -53,4 +54,7 @@ export const EVENT_KEY = {
|
|||||||
DIALOG_END: 'DIALOG_END',
|
DIALOG_END: 'DIALOG_END',
|
||||||
OPEN_SUB_TYPE: 'OPEN_SUB_TYPE',
|
OPEN_SUB_TYPE: 'OPEN_SUB_TYPE',
|
||||||
CLOSE_SUB_TYPE: 'CLOSE_SUB_TYPE',
|
CLOSE_SUB_TYPE: 'CLOSE_SUB_TYPE',
|
||||||
|
ITEM_TOGGLE: 'ITEM_TOGGLE',
|
||||||
|
ITEM_PLAY: 'ITEM_PLAY',
|
||||||
|
ITEM_STOP: 'ITEM_STOP',
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@ import Loading from "../components/Loading";
|
|||||||
import BaseButton from "../components/BaseButton";
|
import BaseButton from "../components/BaseButton";
|
||||||
import CONST_VAR from "./const_var";
|
import CONST_VAR from "./const_var";
|
||||||
import Dom from "./dom";
|
import Dom from "./dom";
|
||||||
import bus from "./bus";
|
import bus, {EVENT_KEY} from "./bus";
|
||||||
import {random} from "lodash";
|
import {random} from "lodash";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -152,7 +152,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
clickTimer = setTimeout(() => {
|
clickTimer = setTimeout(() => {
|
||||||
console.log('单击')
|
console.log('单击')
|
||||||
bus.emit('singleClick')
|
bus.emit(EVENT_KEY.SINGLE_CLICK)
|
||||||
}, checkTime);
|
}, checkTime);
|
||||||
}
|
}
|
||||||
lastClickTime = nowTime;
|
lastClickTime = nowTime;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user