|
@@ -1,376 +1,591 @@
|
|
|
-import { useEffect, useState, useCallback } from 'react'
|
|
|
-import Taro, { useReady } from '@tarojs/taro'
|
|
|
+import { useEffect, useState, useImperativeHandle, memo, forwardRef } from 'react'
|
|
|
+import Taro, { useLoad, useReady } from '@tarojs/taro'
|
|
|
import {
|
|
|
- Swiper, SwiperItem, Video,
|
|
|
- View, Image, Button
|
|
|
+ Swiper, SwiperItem, Video,
|
|
|
+ View, Image, Button, Progress
|
|
|
} from '@tarojs/components'
|
|
|
-import { DETAIL_PAGESOURCE, CATEGORY_PAGESOURCE, LIKE_ICON, DEFAULT_ICON, VIEW_AUTO_TYPE } from '@/const'
|
|
|
-import { favoriteUrl, unfavoriteUrl } from '@/http/api'
|
|
|
+import { DETAIL_PAGESOURCE, CATEGORY_PAGESOURCE, VIEW_AUTO_TYPE } from '@/const'
|
|
|
+// import { favoriteUrl, unfavoriteUrl } from '@/http/api'
|
|
|
import Route from '@/class/Route'
|
|
|
import { videoViewReport, videoPlayReport, videoActionReport } from '@/logger'
|
|
|
-import { once } from '@/utils'
|
|
|
+import { once, formatSecondsAsTime } from '@/utils'
|
|
|
import './index.less'
|
|
|
+import { PlayState } from '@/constants/commentTypes'
|
|
|
|
|
|
|
|
|
let activeIndex = 0
|
|
|
-let favoritePending = false
|
|
|
+let lastSwiperItemIndex = 0 // 上个 item 索引
|
|
|
+let currentListIndex = 0 // 大视频列表的索引
|
|
|
+let isUp = false
|
|
|
+
|
|
|
const videoViewedMap = new Map()
|
|
|
|
|
|
-export default function VideoSwiper({ list, onFinish, circular, onFavorited }) {
|
|
|
- const [currentIndex, setCurrentIndex] = useState(0)
|
|
|
-
|
|
|
- useReady(() => {
|
|
|
- activeIndex = 0
|
|
|
- videoViewedMap.clear()
|
|
|
- })
|
|
|
-
|
|
|
- function onSwiperChange(res) {
|
|
|
- const { detail } = res || {}
|
|
|
- const { current } = detail || {}
|
|
|
- activeIndex = current
|
|
|
- }
|
|
|
-
|
|
|
- function onAnimationFinish() {
|
|
|
- onFinish(activeIndex)
|
|
|
- setCurrentIndex(activeIndex)
|
|
|
- }
|
|
|
-
|
|
|
- return (
|
|
|
- <Swiper
|
|
|
- className='video-swiper'
|
|
|
- vertical
|
|
|
- circular={circular}
|
|
|
- current={currentIndex}
|
|
|
- onChange={onSwiperChange}
|
|
|
- onAnimationFinish={onAnimationFinish}
|
|
|
- >
|
|
|
- {list.map((video, index) => {
|
|
|
- return (
|
|
|
- <SwiperItem className='video-swiper-item' key={video.id}>
|
|
|
- <CustomVideo video={video} current={currentIndex} index={index}/>
|
|
|
- <VideoIntroduce detail={video} />
|
|
|
- <VideoBar video={video} onFavorited={onFavorited}/>
|
|
|
- </SwiperItem>
|
|
|
- )
|
|
|
- })}
|
|
|
- </Swiper>
|
|
|
- )
|
|
|
+export default function VideoSwiper({ list, onFinish, needResumePlay }) {
|
|
|
+ const [currentIndex, setCurrentIndex] = useState(0)
|
|
|
+ const [circular, setCircular] = useState(false)
|
|
|
+ const [showRedShareBtn, setShowRedShareBtn] = useState(false)
|
|
|
+ const [seekProgress, setSeekProgress] = useState(false)
|
|
|
+ const [needPlayerResume, setNeedPlayerResume] = useState(false)
|
|
|
+
|
|
|
+
|
|
|
+ const [videoList, setVideoList] = useState<VideoInfo[]>(list.slice(0, 3))
|
|
|
+ useReady(() => {
|
|
|
+ activeIndex = 0
|
|
|
+ videoViewedMap.clear()
|
|
|
+ })
|
|
|
+
|
|
|
+ useLoad(() => {
|
|
|
+
|
|
|
+ })
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @description: 进度回调。秒单位
|
|
|
+ * @param {*} e
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ function didTimeUpdate(e) {
|
|
|
+ // console.log(e)
|
|
|
+ let { currentTime = 0, duration = 1000000 } = e
|
|
|
+ if (!showRedShareBtn && currentTime / duration >= 0.1) {
|
|
|
+ setShowRedShareBtn(true)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ function onProgressMove(e) {
|
|
|
+ setSeekProgress(e || false)
|
|
|
+ }
|
|
|
+
|
|
|
+ function onSwiperChange(res) {
|
|
|
+ const { detail } = res || {}
|
|
|
+ const { current } = detail || {}
|
|
|
+ isUp = (lastSwiperItemIndex + 1) % 3 == current
|
|
|
+ lastSwiperItemIndex = current
|
|
|
+
|
|
|
+ if (isUp) {
|
|
|
+ currentListIndex += 1
|
|
|
+ } else {
|
|
|
+ currentListIndex -= 1
|
|
|
+ if (currentListIndex < 0) {
|
|
|
+ currentListIndex += 3
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('hhz- currentListIndex:', currentListIndex)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function onAnimationFinish(e) {
|
|
|
+ const { detail } = e || {}
|
|
|
+ const { current } = detail || {}
|
|
|
+
|
|
|
+ if (activeIndex == current) {
|
|
|
+ if (currentListIndex == 0) {
|
|
|
+ onFinish(-99)
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ activeIndex = current
|
|
|
+
|
|
|
+ if (isUp) {
|
|
|
+ if (!circular && currentListIndex > 0) {
|
|
|
+ setCircular(true)
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (circular && currentListIndex < 2) {
|
|
|
+ setCircular(false)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ let changed = false
|
|
|
+ let nextSwiperItemIndex = (current + 1) % 3
|
|
|
+ if (currentListIndex < list.length - 1) {
|
|
|
+ let nextVideo = list[currentListIndex + 1]
|
|
|
+ let replaceVideo = videoList[nextSwiperItemIndex]
|
|
|
+ if (nextVideo && nextVideo.id != replaceVideo.id) {
|
|
|
+ videoList[nextSwiperItemIndex] = nextVideo
|
|
|
+ changed = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ let preSwiperItemIndex = (current - 1 + 3) % 3
|
|
|
+ if (currentListIndex > 0) {
|
|
|
+ let nextVideo = list[currentListIndex - 1]
|
|
|
+ let replaceVideo = videoList[preSwiperItemIndex]
|
|
|
+ if (nextVideo && nextVideo.id != replaceVideo.id) {
|
|
|
+ videoList[preSwiperItemIndex] = nextVideo
|
|
|
+ changed = true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ changed && setVideoList(videoList)
|
|
|
+ onFinish(currentListIndex)
|
|
|
+ setCurrentIndex(activeIndex)
|
|
|
+ }
|
|
|
+
|
|
|
+ function replayCurrentVideo() {
|
|
|
+ setNeedPlayerResume(true)
|
|
|
+ setTimeout(() => {
|
|
|
+ setNeedPlayerResume(false)
|
|
|
+ }, 1000);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ if (list.length > 0 && videoList.length == 0) {
|
|
|
+ setVideoList(list.slice(0, 3))
|
|
|
+ }
|
|
|
+ }, [list])
|
|
|
+ useEffect(() => {
|
|
|
+ if (needResumePlay) {
|
|
|
+ replayCurrentVideo()
|
|
|
+ }
|
|
|
+ }, [needResumePlay])
|
|
|
+
|
|
|
+ return (
|
|
|
+ <Swiper
|
|
|
+ className='video-swiper'
|
|
|
+ vertical
|
|
|
+ circular={circular}
|
|
|
+ current={currentIndex}
|
|
|
+ onChange={onSwiperChange}
|
|
|
+ onAnimationFinish={onAnimationFinish}
|
|
|
+ >
|
|
|
+ {videoList.map((video, index) => {
|
|
|
+ return (
|
|
|
+ <SwiperItem className='video-swiper-item' key={video.id}>
|
|
|
+ <CustomVideo
|
|
|
+ video={video}
|
|
|
+ current={currentIndex}
|
|
|
+ index={index}
|
|
|
+ needResumePlay={needPlayerResume}
|
|
|
+ onTimeUpdate={didTimeUpdate}
|
|
|
+ onProgressMove={onProgressMove} />
|
|
|
+ {!seekProgress && <VideoIntroduce detail={video} showRedShareBtn={showRedShareBtn} />}
|
|
|
+ {!seekProgress && <VideoBar video={video} />}
|
|
|
+ </SwiperItem>
|
|
|
+ )
|
|
|
+ })}
|
|
|
+ </Swiper>
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
-function CustomVideo({ video, current, index }) {
|
|
|
- const [showEndCover, setShowEndCover] = useState(false)
|
|
|
- let videoContext = Taro.createVideoContext(`${video.id}`)
|
|
|
- const logReportVideoPlaySuccessOnce = once(logReportVideoPlaySuccess)
|
|
|
- const logReportVideoRealPlayOnce = once(logReportVideoRealPlay)
|
|
|
- const logReportVideoPlayEndOnce = once(logReportVideoPlayEnd)
|
|
|
-
|
|
|
- useEffect(() => {
|
|
|
- logReportVideoView(video, current, index)
|
|
|
-
|
|
|
- if (current === index) {
|
|
|
- videoContext.play()
|
|
|
-
|
|
|
- logReportVideoPlay(video)
|
|
|
- } else {
|
|
|
- videoContext.pause()
|
|
|
+function CustomVideo({ video, current, index, onTimeUpdate, onProgressMove, needResumePlay }) {
|
|
|
+ const [showEndCover, setShowEndCover] = useState(false)
|
|
|
+ const [durPersec, setDurPersec] = useState(1)
|
|
|
+ const [showProgressIndicator, setShowProgressIndicator] = useState(false)
|
|
|
+ const [playerState, setPlayerState] = useState(0)
|
|
|
+ const [isPlaying, setIsPlaying] = useState(false)
|
|
|
+ const [seekTime, setSeekTime] = useState(0)
|
|
|
+ const [videoDuraing, setVideoDuraing] = useState(0)
|
|
|
+ const [playTimeWhenMove, setPlayTimeWhenMove] = useState(0)
|
|
|
+ const [currentPlayTime, setCurrentPlayTime] = useState(0)
|
|
|
+ const [startMoveX, setStartMoveX] = useState(0)
|
|
|
+
|
|
|
+ let videoContext = Taro.createVideoContext(`${video.id}`)
|
|
|
+ const logReportVideoPlaySuccessOnce = once(logReportVideoPlaySuccess)
|
|
|
+ const logReportVideoRealPlayOnce = once(logReportVideoRealPlay)
|
|
|
+ const logReportVideoPlayEndOnce = once(logReportVideoPlayEnd)
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ logReportVideoView(video, current, index)
|
|
|
+
|
|
|
+ if (current === index) {
|
|
|
+ playerPlay()
|
|
|
+
|
|
|
+ logReportVideoPlay(video)
|
|
|
+ } else {
|
|
|
+ playerPause()
|
|
|
+ }
|
|
|
+ }, [current, video])
|
|
|
+
|
|
|
+ useEffect(() => {
|
|
|
+ setShowEndCover(false)
|
|
|
+ }, [current])
|
|
|
+ useEffect(() => {
|
|
|
+ if (needResumePlay && current == index){
|
|
|
+ playerPlay()
|
|
|
+ }
|
|
|
+ }, [current, needResumePlay])
|
|
|
+
|
|
|
+ function playerPlay() {
|
|
|
+ videoContext.play()
|
|
|
+ setPlayerState(PlayState.playing)
|
|
|
+
|
|
|
+ setIsPlaying(true)
|
|
|
}
|
|
|
- }, [current, video])
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- setShowEndCover(false)
|
|
|
- }, [current])
|
|
|
+ function playerPause() {
|
|
|
+ videoContext.pause()
|
|
|
+ setPlayerState(PlayState.pause)
|
|
|
+ setIsPlaying(false)
|
|
|
+ }
|
|
|
|
|
|
- function onTimeUpdate(evt) {
|
|
|
- if (current !== index)
|
|
|
- return
|
|
|
-
|
|
|
- const { detail } = evt || {}
|
|
|
- const { currentTime, duration } = detail || {}
|
|
|
-
|
|
|
- logReportVideoPlaySuccessOnce(video)
|
|
|
-
|
|
|
- if (currentTime / duration >= 0.3 || currentTime >= 20)
|
|
|
- logReportVideoRealPlayOnce(video)
|
|
|
- }
|
|
|
-
|
|
|
- function onEnded() {
|
|
|
- logReportVideoPlayEndOnce(video)
|
|
|
- current === index && setShowEndCover(true)
|
|
|
- }
|
|
|
-
|
|
|
- function onRePlay() {
|
|
|
- setShowEndCover(false)
|
|
|
- videoContext.seek(0)
|
|
|
- videoContext.play()
|
|
|
-
|
|
|
- logReportVideoPlay(video)
|
|
|
- }
|
|
|
-
|
|
|
- return (
|
|
|
- <View className='custom-video'>
|
|
|
- <Video
|
|
|
- className='video'
|
|
|
- id={`${video.id}`}
|
|
|
- src={video.videoPath || ''}
|
|
|
- controls
|
|
|
- autoplay={false}
|
|
|
- showCenterPlayBtn={false}
|
|
|
- poster={video.videoCoverSnapshotPath}
|
|
|
- onTimeUpdate={onTimeUpdate}
|
|
|
- onEnded={onEnded}
|
|
|
- />
|
|
|
-
|
|
|
- {showEndCover && <VideoPlayEndCover onRePlay={onRePlay} />}
|
|
|
- </View>
|
|
|
- )
|
|
|
+ function didLoadedMeta(e) {
|
|
|
+ let { duration = 0 } = e.detail || {}
|
|
|
+ setVideoDuraing(duration)
|
|
|
+ }
|
|
|
+
|
|
|
+ function onSeekCom(e) {
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+
|
|
|
+ function didTimeUpdate(evt) {
|
|
|
+ if (current !== index)
|
|
|
+ return
|
|
|
+
|
|
|
+ const { detail } = evt || {}
|
|
|
+ const { currentTime, duration } = detail || {}
|
|
|
+ setCurrentPlayTime(currentTime)
|
|
|
+
|
|
|
+ onTimeUpdate(detail)
|
|
|
+ setDurPersec(currentTime / duration)
|
|
|
+
|
|
|
+ logReportVideoPlaySuccessOnce(video)
|
|
|
+ if (durPersec >= 0.3 || currentTime >= 20)
|
|
|
+ logReportVideoRealPlayOnce(video)
|
|
|
+ }
|
|
|
+
|
|
|
+ function didPaused() {
|
|
|
+ console.log('didPaused', index)
|
|
|
+ }
|
|
|
+ function onEnded() {
|
|
|
+ setPlayerState(PlayState.stoped)
|
|
|
+ current === index && setShowEndCover(true)
|
|
|
+ logReportVideoPlayEndOnce(video)
|
|
|
+ setIsPlaying(false)
|
|
|
+
|
|
|
+ // 自动重播
|
|
|
+ videoContext.seek(0)
|
|
|
+ playerPlay()
|
|
|
+ }
|
|
|
+
|
|
|
+ function onTapVideo() {
|
|
|
+ if (playerState != PlayState.playing) {
|
|
|
+ playerPlay()
|
|
|
+ } else if (playerState == PlayState.playing) {
|
|
|
+ playerPause()
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ function onRePlay() {
|
|
|
+ setShowEndCover(false)
|
|
|
+ videoContext.seek(0)
|
|
|
+ playerPlay()
|
|
|
+ logReportVideoPlay(video)
|
|
|
+ }
|
|
|
+
|
|
|
+ function onTouchStart(e) {
|
|
|
+ console.log('hhz- start ', e)
|
|
|
+ let { clientX = 0 } = (e.changedTouches || [])[0]
|
|
|
+ setStartMoveX(clientX)
|
|
|
+ onProgressMove(true)
|
|
|
+ setShowProgressIndicator(true)
|
|
|
+ setPlayTimeWhenMove(currentPlayTime)
|
|
|
+ }
|
|
|
+
|
|
|
+ function onTouchMove(e) {
|
|
|
+ let { clientX = 0 } = (e.changedTouches || [])[0]
|
|
|
+ let rate = coculationRate(clientX - startMoveX)
|
|
|
+
|
|
|
+ changeIndicator(rate)
|
|
|
+ // 移动中
|
|
|
+ //计算 seek 进度,并设置播放器 seek。 等比设置:拖动屏幕宽距离,偏移 50% 进度
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function onTouchEnd(e) {
|
|
|
+ let { clientX = 0 } = (e.changedTouches || [])[0]
|
|
|
+
|
|
|
+ onProgressMove(false)
|
|
|
+ setShowProgressIndicator(false)
|
|
|
+
|
|
|
+ let rate = coculationRate(clientX - startMoveX)
|
|
|
+ let t = Math.min(Math.max(0, playTimeWhenMove + videoDuraing * rate), videoDuraing)
|
|
|
+ videoContext.seek(t)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ function changeIndicator(rate) {
|
|
|
+ let t = Math.min(Math.max(0, playTimeWhenMove + videoDuraing * rate), videoDuraing)
|
|
|
+ setSeekTime(t)
|
|
|
+ }
|
|
|
+
|
|
|
+ function coculationRate(distance) {
|
|
|
+ const systemInfo = Taro.$global.get('systemInfo')
|
|
|
+ let { width = 375 } = systemInfo.safeArea
|
|
|
+
|
|
|
+ // 移动中
|
|
|
+ //计算 seek 进度,并设置播放器 seek。 等比设置:拖动屏幕宽距离,偏移 50% 进度
|
|
|
+ let rate = distance / width * 0.5
|
|
|
+ return rate
|
|
|
+ }
|
|
|
+
|
|
|
+ return (
|
|
|
+ <View className='custom-video'>
|
|
|
+ <Video
|
|
|
+ className='video'
|
|
|
+ id={`${video.id}`}
|
|
|
+ src={video.videoPath || ''}
|
|
|
+ controls={false}
|
|
|
+ autoplay={false}
|
|
|
+ showCenterPlayBtn={false}
|
|
|
+ showBottomProgress={true}
|
|
|
+ poster={video.videoCoverSnapshotPath}
|
|
|
+ onTimeUpdate={didTimeUpdate}
|
|
|
+ onEnded={onEnded}
|
|
|
+ onPause={didPaused}
|
|
|
+ onLoadedMetaData={didLoadedMeta}
|
|
|
+ onSeekComplete={onSeekCom}
|
|
|
+ onTap={onTapVideo}
|
|
|
+ />
|
|
|
+ <View className='progress-bg'
|
|
|
+ onTouchStart={onTouchStart}
|
|
|
+ onTouchMove={onTouchMove}
|
|
|
+ onTouchEnd={onTouchEnd}
|
|
|
+ >
|
|
|
+ <View className='progress-container'>
|
|
|
+ <View className='progress' style={{ width: `${durPersec * 100}%;` }}>
|
|
|
+
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+
|
|
|
+ </View>
|
|
|
+ {showProgressIndicator && <View className='progress-indicator'>
|
|
|
+ <View className='showInfo'>
|
|
|
+ <View className='showInfo-a'>{formatSecondsAsTime(seekTime)}</View>
|
|
|
+ <View className='showInfo-m'></View>
|
|
|
+ <View className='showInfo-b'>{formatSecondsAsTime(videoDuraing)}</View>
|
|
|
+ </View>
|
|
|
+ <View className='indicator-bg'>
|
|
|
+ <View className='indcator-active' style={{ width: `${seekTime / videoDuraing * 100}%;` }}></View>
|
|
|
+ <View className='indicator-dot'>
|
|
|
+
|
|
|
+ </View>
|
|
|
+ </View>
|
|
|
+ </View>}
|
|
|
+ {showEndCover && <VideoPlayEndCover onRePlay={onRePlay} />}
|
|
|
+ </View>
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
-function VideoIntroduce({detail}) {
|
|
|
- return (
|
|
|
- <View className='video-introduce'>
|
|
|
- <View className='video-user-info'>
|
|
|
- <Image className='avatar' src={detail.avatarUrl} />
|
|
|
- {detail.nickName}
|
|
|
- </View>
|
|
|
- <View className='video-title'>
|
|
|
- {detail.title}
|
|
|
- </View>
|
|
|
- <View className='video-play-count'>
|
|
|
- 播放{detail.playCount}次
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- )
|
|
|
+function VideoIntroduce({ detail, showRedShareBtn }) {
|
|
|
+ return (
|
|
|
+ <View className='video-introduce'>
|
|
|
+ <View className='video-user-info'>
|
|
|
+ <Image className='avatar' src={detail.user.avatarUrl} />
|
|
|
+ {detail.user.nickName}
|
|
|
+ </View>
|
|
|
+ <View className='video-title'>
|
|
|
+ {detail.title}
|
|
|
+ </View>
|
|
|
+ {showRedShareBtn && <Button className='redShareBtn' openType='share' data-button-type={2}>分享给群友</Button>}
|
|
|
+ </View>
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
-function VideoBar({ video, onFavorited }) {
|
|
|
- const [likeIcon, setLikeIcon] = useState(video.favorited ? LIKE_ICON : DEFAULT_ICON)
|
|
|
- const [showTips, setShowTips] = useState(false)
|
|
|
+function VideoBar({ video }) {
|
|
|
+ const [showTips, setShowTips] = useState(false)
|
|
|
|
|
|
- useEffect(() => {
|
|
|
- setLikeIcon(video.favorited ? LIKE_ICON : DEFAULT_ICON)
|
|
|
- }, [video.favorited])
|
|
|
+ function clickOperationBar(e) {
|
|
|
+ e.stopPropagation()
|
|
|
+ setShowTips(!showTips)
|
|
|
+ }
|
|
|
|
|
|
- function clickLikeIcon(favorite) {
|
|
|
- if (favoritePending)
|
|
|
- return
|
|
|
+ function shareToPyq() {
|
|
|
+ /// TODO:
|
|
|
+ console.log('share to pyq')
|
|
|
+ }
|
|
|
|
|
|
- favoritePending = true
|
|
|
+ function shareToFriend() {
|
|
|
+ /// TODO:
|
|
|
+ console.log('share to friend')
|
|
|
+ }
|
|
|
|
|
|
- const url = favorite ? favoriteUrl : unfavoriteUrl
|
|
|
- onFavorited(video.id, favorite)
|
|
|
-
|
|
|
- Taro.$http.post(url, {
|
|
|
- videoId: video.id
|
|
|
- }).then((res: RequestType) => {
|
|
|
- const { code } = res
|
|
|
+ /**
|
|
|
+ * @description: 举报按钮
|
|
|
+ * @return {*}
|
|
|
+ */
|
|
|
+ function clickTips() {
|
|
|
+ const route = new Route()
|
|
|
+ route.push({
|
|
|
+ url: '/subPackages/safe/complaining/index',
|
|
|
+ query: {
|
|
|
+ videoId: video.id
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
|
|
|
- favoritePending = false
|
|
|
+ function clickVideoBar(e) {
|
|
|
+ e.stopPropagation()
|
|
|
+ setShowTips(false)
|
|
|
+ }
|
|
|
|
|
|
- if (code !== 0) {
|
|
|
- onFavorited(video.id, !favorite)
|
|
|
- Taro.showToast({
|
|
|
- title: '收藏失败',
|
|
|
- icon: 'error'
|
|
|
- })
|
|
|
- return
|
|
|
- }
|
|
|
- }).catch(() => {
|
|
|
- favoritePending = false
|
|
|
- onFavorited(video.id, !favorite)
|
|
|
- Taro.showToast({
|
|
|
- title: '收藏失败',
|
|
|
- icon: 'error'
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- function clickOperationBar(e) {
|
|
|
- e.stopPropagation()
|
|
|
- setShowTips(!showTips)
|
|
|
- }
|
|
|
-
|
|
|
- function clickTips() {
|
|
|
- const route = new Route()
|
|
|
- route.push({
|
|
|
- url: '/pages/complaining/index',
|
|
|
- query: {
|
|
|
- videoId: video.id
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
- function clickVideoBar(e) {
|
|
|
- e.stopPropagation()
|
|
|
- setShowTips(false)
|
|
|
- }
|
|
|
-
|
|
|
- return (
|
|
|
- <View className='video-bar' onClick={clickVideoBar}>
|
|
|
- <View className='operation' onClick={clickOperationBar}>
|
|
|
- <View className='bot'></View>
|
|
|
- <View className='bot margin10'></View>
|
|
|
- <View className='bot'></View>
|
|
|
- {showTips && <View className='tips' onClick={clickTips}>
|
|
|
- <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_jubao.png' />
|
|
|
- 举报
|
|
|
- </View>}
|
|
|
- </View>
|
|
|
- <View className='right'>
|
|
|
- <View className='like'>
|
|
|
- <Image className='like-icon' src={likeIcon} onClick={() => clickLikeIcon(!video.favorited)}/>
|
|
|
+ return (
|
|
|
+ <View className='video-bar' onClick={clickVideoBar}>
|
|
|
+ <Button className='friend' onClick={shareToFriend} openType='share' data-button-type={6}>
|
|
|
+ <Image src="http://weapppiccdn.yishihui.com/wxicon/common/icon_point_share_wechat.png" />
|
|
|
+ <View className='text'>分享</View>
|
|
|
+ </Button>
|
|
|
+ <Button className='pyq' onClick={shareToPyq} openType='contact'>
|
|
|
+ <Image src="http://weapppiccdn.yishihui.com/wxicon/common/icon_point_share_pyq.png" />
|
|
|
+ <View className='text'>朋友圈</View>
|
|
|
+
|
|
|
+ </Button>
|
|
|
+
|
|
|
+ <View className='more' onClick={clickOperationBar}>
|
|
|
+ <View className='bot'></View>
|
|
|
+ <View className='bot margin10'></View>
|
|
|
+ <View className='bot'></View>
|
|
|
+ {showTips && <View className='tips' onClick={clickTips}>
|
|
|
+ <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_jubao.png' />
|
|
|
+ 投诉
|
|
|
+ </View>}
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- <Button className='share-btn-f' openType='share' data-button-type={6}>
|
|
|
- <View className='wechat-icon' />
|
|
|
- 发给好友
|
|
|
- </Button>
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- )
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
function VideoPlayEndCover({ onRePlay }) {
|
|
|
- return (
|
|
|
- <View className='video-play-end-cover'>
|
|
|
- <View className='container'>
|
|
|
- <View className='item left'>
|
|
|
- <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_replay_01.png' onClick={onRePlay} />
|
|
|
- 重播
|
|
|
+ return (
|
|
|
+ <View className='video-play-end-cover'>
|
|
|
+ <View className='container'>
|
|
|
+ <View className='item left'>
|
|
|
+ <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_replay_01.png' onClick={onRePlay} />
|
|
|
+ 重播
|
|
|
+ </View>
|
|
|
+ <Button className='item right' openType='share' data-button-type={10}>
|
|
|
+ <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_share_wechat_01.png' />
|
|
|
+ 发给好友
|
|
|
+ </Button>
|
|
|
+ </View>
|
|
|
+ <View className='more-video'>
|
|
|
+ <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_slide_tips.png' />
|
|
|
+ 上滑看更多精彩视频
|
|
|
+ </View>
|
|
|
</View>
|
|
|
- <Button className='item right' openType='share' data-button-type={10}>
|
|
|
- <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_share_wechat_01.png' />
|
|
|
- 发给好友
|
|
|
- </Button>
|
|
|
- </View>
|
|
|
- <View className='more-video'>
|
|
|
- <Image src='http://weapppiccdn.yishihui.com/wxicon/common/icon_slide_tips.png' />
|
|
|
- 上滑看更多精彩视频
|
|
|
- </View>
|
|
|
- </View>
|
|
|
- )
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
// 视频曝光
|
|
|
function logReportVideoView(video, current, index) {
|
|
|
- if (videoViewedMap.has(video.id))
|
|
|
- return
|
|
|
-
|
|
|
- if (current !== index)
|
|
|
- return
|
|
|
-
|
|
|
- if (video.type === 'temp')
|
|
|
- return
|
|
|
-
|
|
|
- videoViewReport({
|
|
|
- actionPosition: index,
|
|
|
- autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
- extParams: JSON.stringify({
|
|
|
- recomTraceId: video.recomTraceId,
|
|
|
- }),
|
|
|
- viewId: video.viewId,
|
|
|
- flowPool: video.flowPool || '',
|
|
|
- measureId: video.measure,
|
|
|
- measureType: video.measureType,
|
|
|
- pageSource: DETAIL_PAGESOURCE,
|
|
|
- recommendLogVO: video.recommendLogVO || '',
|
|
|
- recommendSource: video.recommendSource,
|
|
|
- rootPageSource: '', // TODO: 分享之后加上
|
|
|
- rootPageTimestamp: '', // TODO: 分享之后加上
|
|
|
- shareDepth: '', // TODO: 分享之后加上
|
|
|
- videoIds: [video.id]
|
|
|
- }).then(() => videoViewedMap.set(video.id, video.id))
|
|
|
+ if (videoViewedMap.has(video.id))
|
|
|
+ return
|
|
|
+
|
|
|
+ if (current !== index)
|
|
|
+ return
|
|
|
+
|
|
|
+ if (video.type === 'temp')
|
|
|
+ return
|
|
|
+
|
|
|
+ videoViewReport({
|
|
|
+ actionPosition: index,
|
|
|
+ autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
+ extParams: JSON.stringify({
|
|
|
+ recomTraceId: video.recomTraceId,
|
|
|
+ }),
|
|
|
+ viewId: video.viewId,
|
|
|
+ flowPool: video.flowPool || '',
|
|
|
+ measureId: video.measure,
|
|
|
+ measureType: video.measureType,
|
|
|
+ pageSource: DETAIL_PAGESOURCE,
|
|
|
+ recommendLogVO: video.recommendLogVO || '',
|
|
|
+ recommendSource: video.recommendSource,
|
|
|
+ rootPageSource: '', // TODO: 分享之后加上
|
|
|
+ rootPageTimestamp: '', // TODO: 分享之后加上
|
|
|
+ shareDepth: '', // TODO: 分享之后加上
|
|
|
+ videoIds: [video.id]
|
|
|
+ }).then(() => videoViewedMap.set(video.id, video.id))
|
|
|
}
|
|
|
// 视频播放
|
|
|
function logReportVideoPlay(video) {
|
|
|
- if (video.type === 'temp')
|
|
|
- return
|
|
|
-
|
|
|
- videoPlayReport({
|
|
|
- videoId: video.id,
|
|
|
- pageSource: DETAIL_PAGESOURCE,
|
|
|
- rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
- shareDepth: '', // TODO: 分享之后
|
|
|
- rootPageTimestamp: '', // TODO: 分享之后
|
|
|
- rootMid: '', // TODO: 分享之后
|
|
|
- recommendSource: video.recommendSource || 0,
|
|
|
- autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
- playId: video.playId,
|
|
|
- viewId: video.viewId,
|
|
|
- measureType: video.measureType || 0,
|
|
|
- measureId: video.measure,
|
|
|
- flowPool: video.flowPool || '',
|
|
|
- recommendId: video.recommendId || '',
|
|
|
- recommendLogVO: video.recommendLogVO || ''
|
|
|
- })
|
|
|
+ if (video.type === 'temp')
|
|
|
+ return
|
|
|
+
|
|
|
+ videoPlayReport({
|
|
|
+ videoId: video.id,
|
|
|
+ pageSource: DETAIL_PAGESOURCE,
|
|
|
+ rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
+ shareDepth: '', // TODO: 分享之后
|
|
|
+ rootPageTimestamp: '', // TODO: 分享之后
|
|
|
+ rootMid: '', // TODO: 分享之后
|
|
|
+ recommendSource: video.recommendSource || 0,
|
|
|
+ autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
+ playId: video.playId,
|
|
|
+ viewId: video.viewId,
|
|
|
+ measureType: video.measureType || 0,
|
|
|
+ measureId: video.measure,
|
|
|
+ flowPool: video.flowPool || '',
|
|
|
+ recommendId: video.recommendId || '',
|
|
|
+ recommendLogVO: video.recommendLogVO || ''
|
|
|
+ })
|
|
|
}
|
|
|
// 播放成功
|
|
|
function logReportVideoPlaySuccess(video) {
|
|
|
- if (video.type === 'temp')
|
|
|
- return
|
|
|
-
|
|
|
- videoActionReport({
|
|
|
- businessType: 'videoPlaySuccess',
|
|
|
- videoId: video.id,
|
|
|
- pageSource: DETAIL_PAGESOURCE,
|
|
|
- rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
- shareDepth: '', // TODO: 分享之后
|
|
|
- rootPageTimestamp: '', // TODO: 分享之后
|
|
|
- rootMid: '', // TODO: 分享之后
|
|
|
- recommendSource: video.recommendSource || 0,
|
|
|
- autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
- playId: video.playId,
|
|
|
- viewId: video.viewId,
|
|
|
- measureType: video.measureType || 0,
|
|
|
- measureId: video.measure,
|
|
|
- flowPool: video.flowPool || '',
|
|
|
- recommendId: video.recommendId || '',
|
|
|
- recommendLogVO: video.recommendLogVO || ''
|
|
|
- })
|
|
|
+ if (video.type === 'temp')
|
|
|
+ return
|
|
|
+
|
|
|
+ videoActionReport({
|
|
|
+ businessType: 'videoPlaySuccess',
|
|
|
+ videoId: video.id,
|
|
|
+ pageSource: DETAIL_PAGESOURCE,
|
|
|
+ rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
+ shareDepth: '', // TODO: 分享之后
|
|
|
+ rootPageTimestamp: '', // TODO: 分享之后
|
|
|
+ rootMid: '', // TODO: 分享之后
|
|
|
+ recommendSource: video.recommendSource || 0,
|
|
|
+ autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
+ playId: video.playId,
|
|
|
+ viewId: video.viewId,
|
|
|
+ measureType: video.measureType || 0,
|
|
|
+ measureId: video.measure,
|
|
|
+ flowPool: video.flowPool || '',
|
|
|
+ recommendId: video.recommendId || '',
|
|
|
+ recommendLogVO: video.recommendLogVO || ''
|
|
|
+ })
|
|
|
}
|
|
|
// 真实播放
|
|
|
function logReportVideoRealPlay(video) {
|
|
|
- if (video.type === 'temp')
|
|
|
- return
|
|
|
-
|
|
|
- videoActionReport({
|
|
|
- businessType: 'videoRealPlay',
|
|
|
- videoId: video.id,
|
|
|
- pageSource: DETAIL_PAGESOURCE,
|
|
|
- rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
- shareDepth: '', // TODO: 分享之后
|
|
|
- rootPageTimestamp: '', // TODO: 分享之后
|
|
|
- rootMid: '', // TODO: 分享之后
|
|
|
- recommendSource: video.recommendSource || 0,
|
|
|
- autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
- playId: video.playId,
|
|
|
- viewId: video.viewId,
|
|
|
- measureType: video.measureType || 0,
|
|
|
- measureId: video.measure,
|
|
|
- flowPool: video.flowPool || '',
|
|
|
- recommendId: video.recommendId || '',
|
|
|
- recommendLogVO: video.recommendLogVO || ''
|
|
|
- })
|
|
|
+ if (video.type === 'temp')
|
|
|
+ return
|
|
|
+
|
|
|
+ videoActionReport({
|
|
|
+ businessType: 'videoRealPlay',
|
|
|
+ videoId: video.id,
|
|
|
+ pageSource: DETAIL_PAGESOURCE,
|
|
|
+ rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
+ shareDepth: '', // TODO: 分享之后
|
|
|
+ rootPageTimestamp: '', // TODO: 分享之后
|
|
|
+ rootMid: '', // TODO: 分享之后
|
|
|
+ recommendSource: video.recommendSource || 0,
|
|
|
+ autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
+ playId: video.playId,
|
|
|
+ viewId: video.viewId,
|
|
|
+ measureType: video.measureType || 0,
|
|
|
+ measureId: video.measure,
|
|
|
+ flowPool: video.flowPool || '',
|
|
|
+ recommendId: video.recommendId || '',
|
|
|
+ recommendLogVO: video.recommendLogVO || ''
|
|
|
+ })
|
|
|
}
|
|
|
// 播放结束
|
|
|
function logReportVideoPlayEnd(video) {
|
|
|
- if (video.type === 'temp')
|
|
|
- return
|
|
|
-
|
|
|
- videoActionReport({
|
|
|
- businessType: 'videoPlayEnd',
|
|
|
- videoId: video.id,
|
|
|
- pageSource: DETAIL_PAGESOURCE,
|
|
|
- rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
- shareDepth: '', // TODO: 分享之后
|
|
|
- rootPageTimestamp: '', // TODO: 分享之后
|
|
|
- rootMid: '', // TODO: 分享之后
|
|
|
- recommendSource: video.recommendSource || 0,
|
|
|
- autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
- playId: video.playId,
|
|
|
- viewId: video.viewId,
|
|
|
- measureType: video.measureType || 0,
|
|
|
- measureId: video.measure,
|
|
|
- flowPool: video.flowPool || '',
|
|
|
- recommendId: video.recommendId || '',
|
|
|
- recommendLogVO: video.recommendLogVO || ''
|
|
|
- })
|
|
|
+ if (video.type === 'temp')
|
|
|
+ return
|
|
|
+
|
|
|
+ videoActionReport({
|
|
|
+ businessType: 'videoPlayEnd',
|
|
|
+ videoId: video.id,
|
|
|
+ pageSource: DETAIL_PAGESOURCE,
|
|
|
+ rootPageSource: CATEGORY_PAGESOURCE,
|
|
|
+ shareDepth: '', // TODO: 分享之后
|
|
|
+ rootPageTimestamp: '', // TODO: 分享之后
|
|
|
+ rootMid: '', // TODO: 分享之后
|
|
|
+ recommendSource: video.recommendSource || 0,
|
|
|
+ autoType: VIEW_AUTO_TYPE.clickView,
|
|
|
+ playId: video.playId,
|
|
|
+ viewId: video.viewId,
|
|
|
+ measureType: video.measureType || 0,
|
|
|
+ measureId: video.measure,
|
|
|
+ flowPool: video.flowPool || '',
|
|
|
+ recommendId: video.recommendId || '',
|
|
|
+ recommendLogVO: video.recommendLogVO || ''
|
|
|
+ })
|
|
|
}
|