|
@@ -7,44 +7,10 @@
|
|
:loading-color="$colors.primaryColor"
|
|
:loading-color="$colors.primaryColor"
|
|
/>
|
|
/>
|
|
<template v-if="!loading">
|
|
<template v-if="!loading">
|
|
- <!--播放数据-->
|
|
|
|
- <view class="view-num main-left cross-center">
|
|
|
|
- <u-icon name="eye-fill" :color="isCollect?$colors.primaryColor:$colors.defaultColor" size="26rpx" />
|
|
|
|
- <text>{{ episode.user_watch_record_count }}</text>
|
|
|
|
- </view>
|
|
|
|
- <!--按钮-->
|
|
|
|
- <view class="status-bar dir-top-wrap main-center">
|
|
|
|
- <!--喜欢-->
|
|
|
|
- <view
|
|
|
|
- class="item fav dir-top-wrap main-center cross-center"
|
|
|
|
- :class="{active: isFav}"
|
|
|
|
- @click="handleFavorite"
|
|
|
|
- >
|
|
|
|
- <u-icon name="heart-fill" size="58rpx" :color="isFav?$colors.primaryColor:$colors.defaultColor" />
|
|
|
|
- <text>{{ episode.user_favorite_count }}</text>
|
|
|
|
- </view>
|
|
|
|
- <!--收藏-->
|
|
|
|
- <view
|
|
|
|
- class="item collect dir-top-wrap main-center cross-center"
|
|
|
|
- :class="{active: isCollect}"
|
|
|
|
- @click="handleCollect"
|
|
|
|
- >
|
|
|
|
- <u-icon name="star-fill" size="58rpx" :color="isCollect?$colors.primaryColor:$colors.defaultColor" />
|
|
|
|
- <text>{{ episode.user_collect_count }}</text>
|
|
|
|
- </view>
|
|
|
|
- <!--分享-->
|
|
|
|
- <view class="item share dir-top-wrap main-center cross-center">
|
|
|
|
- <button open-type="share" />
|
|
|
|
- <u-icon name="share-fill" size="58rpx" :color="$colors.defaultColor" />
|
|
|
|
- <text>{{ episode.sahre_count }}</text>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
|
|
+ <!-- 剧集按钮-->
|
|
|
|
+ <episode-buttons :episode="episode" @change="handleCollectAndFavChange" />
|
|
<!--视频播放-->
|
|
<!--视频播放-->
|
|
- <view class="video-box main-center cross-center" :style="{zIndex: isPlaying?0:998}">
|
|
|
|
- <!--进度条-->
|
|
|
|
- <!-- <view v-if="isPlaying" class="progress-container">-->
|
|
|
|
- <!-- <view class="progress" :style="{width: progress+'%'}" />-->
|
|
|
|
- <!-- </view>-->
|
|
|
|
|
|
+ <view class="video-box main-center cross-center" :style="{zIndex: isPlaying ? 0 : 998}">
|
|
<!--视频容器-->
|
|
<!--视频容器-->
|
|
<swiper
|
|
<swiper
|
|
class="swiper"
|
|
class="swiper"
|
|
@@ -54,7 +20,7 @@
|
|
@change="handleSwiperChancge"
|
|
@change="handleSwiperChancge"
|
|
>
|
|
>
|
|
<swiper-item
|
|
<swiper-item
|
|
- v-for="(item,index) in episode.lists"
|
|
|
|
|
|
+ v-for="(item, index) in swiperEpisode"
|
|
:key="index"
|
|
:key="index"
|
|
>
|
|
>
|
|
<!-- #ifdef MP-TOUTIAO | MP-WEIXIN-->
|
|
<!-- #ifdef MP-TOUTIAO | MP-WEIXIN-->
|
|
@@ -63,9 +29,10 @@
|
|
<u-icon name="play-right-fill" size="100rpx" :color="$colors.defaultColor" />
|
|
<u-icon name="play-right-fill" size="100rpx" :color="$colors.defaultColor" />
|
|
</view>
|
|
</view>
|
|
<!-- 控制按钮 - 暂停 -->
|
|
<!-- 控制按钮 - 暂停 -->
|
|
- <view v-if="item.isPlaying" class="pause-layer" @tap="handlePause(item)" />
|
|
|
|
- <!-- #endif-->
|
|
|
|
|
|
+ <view v-if="item.isPlaying" class="pause-layer" @tap="handlePause(item, true)" />
|
|
|
|
+ <!-- #endif-->
|
|
<video
|
|
<video
|
|
|
|
+ v-if="Object.keys(item).length"
|
|
:id="`video${index}`"
|
|
:id="`video${index}`"
|
|
:poster="episode.cover_img"
|
|
:poster="episode.cover_img"
|
|
:src="item.url"
|
|
:src="item.url"
|
|
@@ -79,83 +46,14 @@
|
|
/>
|
|
/>
|
|
</swiper-item>
|
|
</swiper-item>
|
|
</swiper>
|
|
</swiper>
|
|
- <!-- <video-->
|
|
|
|
- <!-- id="video"-->
|
|
|
|
- <!-- :show-play-btn="video.playBtn"-->
|
|
|
|
- <!-- :show-fullscreen-btn="video.fullscreenBtn"-->
|
|
|
|
- <!-- :controls="video.controls"-->
|
|
|
|
- <!-- object-fit="contain"-->
|
|
|
|
- <!-- style="width: 100%;height: 100%;"-->
|
|
|
|
- <!-- :poster="episode.cover_img"-->
|
|
|
|
- <!-- :src="src"-->
|
|
|
|
- <!-- @timeupdate="timeupdate"-->
|
|
|
|
- <!-- />-->
|
|
|
|
</view>
|
|
</view>
|
|
<!--底部-->
|
|
<!--底部-->
|
|
- <view class="footer" :class="{episode: footerShow}">
|
|
|
|
- <view class="bar main-between cross-center" @click="footerShow = !footerShow">
|
|
|
|
- <view class="icon" />
|
|
|
|
- <view class="name">
|
|
|
|
- <u-text :text="episode.name" :color="$colors.infoColor" :lines="1" />
|
|
|
|
- <!-- <u-text text="321313" :color="$colors.infoColor" :lines="1" />-->
|
|
|
|
- </view>
|
|
|
|
- <view class="arrow">
|
|
|
|
- <u-icon name="arrow-up" :color="$colors.infoColor" size="32rpx" />
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- <view class="episode-container dir-top-wrap">
|
|
|
|
- <!--分集 横向滚动-->
|
|
|
|
- <scroll-view
|
|
|
|
- class="header-box dir-left-nowrap cross-center"
|
|
|
|
- scroll-x
|
|
|
|
- scroll-with-animation
|
|
|
|
- >
|
|
|
|
- <view
|
|
|
|
- v-for="(item,index) in episodes"
|
|
|
|
- :key="index"
|
|
|
|
- class="header-item"
|
|
|
|
- :class="{active: episodesIndex === index}"
|
|
|
|
- @click="episodesIndex=index"
|
|
|
|
- >{{ item.title }}</view>
|
|
|
|
- </scroll-view>
|
|
|
|
- <!--几集选择-->
|
|
|
|
- <view class="content dir-left-wrap main-left">
|
|
|
|
- <view
|
|
|
|
- v-for="(item, index) in episodes[episodesIndex].lists"
|
|
|
|
- :key="index"
|
|
|
|
- class="episode-item"
|
|
|
|
- @click="handleSelectEpisode(item.index)"
|
|
|
|
- >
|
|
|
|
- <image :src="episode.cover_img" />
|
|
|
|
- <text>第{{ item.sort }}集</text>
|
|
|
|
- <view v-if="currentEpisode.index === item.index && isPlaying" class="playing" />
|
|
|
|
- <view v-if="!item.is_free && buyRecord.indexOf(item.id) === -1 && !(episode.is_vip_watch && userInfo.info.is_vip)" class="lock main-center cross-center">
|
|
|
|
- <u-icon name="lock-fill" :color="$colors.defaultColor" size="46rpx" />
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- </view>
|
|
|
|
- <!--toast-->
|
|
|
|
- <view
|
|
|
|
- v-if="toast.show"
|
|
|
|
- class="toast dir-top-wrap main-center cross-center"
|
|
|
|
- :class="toast.status"
|
|
|
|
- >
|
|
|
|
- <u-icon
|
|
|
|
- :name="toast.status === 'success' ? 'checkmark-circle' : 'close-circle'"
|
|
|
|
- :color="toast.status === 'success' ? $colors.primaryColor : $colors.defaultColor"
|
|
|
|
- size="80rpx"
|
|
|
|
- />
|
|
|
|
- <text>{{ toast.text }}</text>
|
|
|
|
- </view>
|
|
|
|
- <!--购买弹窗-->
|
|
|
|
- <u-modal
|
|
|
|
- :show="modal.show"
|
|
|
|
- :content="`确定购买【第${currentEpisode.sort}集】?`"
|
|
|
|
- show-cancel-button
|
|
|
|
- @confirm="handleBuy"
|
|
|
|
- @cancel="modal.show = false"
|
|
|
|
|
|
+ <episode-part
|
|
|
|
+ :episode="episode"
|
|
|
|
+ :is-playing="isPlaying"
|
|
|
|
+ :buy-record="buyRecord"
|
|
|
|
+ :current-episode="currentEpisode"
|
|
|
|
+ @selectEpisode="handleSelectEpisode"
|
|
/>
|
|
/>
|
|
<!--充值-->
|
|
<!--充值-->
|
|
<recharge
|
|
<recharge
|
|
@@ -172,98 +70,112 @@
|
|
<script>
|
|
<script>
|
|
import { mapState } from 'vuex'
|
|
import { mapState } from 'vuex'
|
|
import Recharge from '../../components/Recharge/index'
|
|
import Recharge from '../../components/Recharge/index'
|
|
|
|
+import EpisodeButtons from './components/EpisodeButtons'
|
|
|
|
+import EpisodePart from './components/EpisodePart'
|
|
export default {
|
|
export default {
|
|
name: 'Play',
|
|
name: 'Play',
|
|
- components: { Recharge },
|
|
|
|
|
|
+ components: { EpisodePart, EpisodeButtons, Recharge },
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
- id: null,
|
|
|
|
- listId: null,
|
|
|
|
- isPlaying: false,
|
|
|
|
- progress: 0,
|
|
|
|
- episode: null,
|
|
|
|
- loading: true,
|
|
|
|
- isCollect: false,
|
|
|
|
- isFav: false,
|
|
|
|
- video: {
|
|
|
|
|
|
+ id: null, // 短剧ID
|
|
|
|
+ listId: null, // 剧集ID
|
|
|
|
+ isPlaying: false, // 是否播放
|
|
|
|
+ progress: 0, // 进度条
|
|
|
|
+ episode: {}, // 短剧信息
|
|
|
|
+ lists: [], // 剧集信息
|
|
|
|
+ loading: false, // 数据加载
|
|
|
|
+ video: { // 视频配置
|
|
controls: true,
|
|
controls: true,
|
|
- // #ifdef MP-KUAISHOU | MP-TOUTIAO
|
|
|
|
- progress: false,
|
|
|
|
- // #endif
|
|
|
|
- // #ifdef MP-TOUTIAO | MP-WEIXIN
|
|
|
|
progress: true,
|
|
progress: true,
|
|
- // #endif
|
|
|
|
fullscreenBtn: false,
|
|
fullscreenBtn: false,
|
|
playBtn: false
|
|
playBtn: false
|
|
-
|
|
|
|
- },
|
|
|
|
- toast: {
|
|
|
|
- status: 'success',
|
|
|
|
- text: '收藏成功',
|
|
|
|
- show: false
|
|
|
|
},
|
|
},
|
|
- footerShow: false,
|
|
|
|
- episodesIndex: 0,
|
|
|
|
- buyRecord: [],
|
|
|
|
- modal: {
|
|
|
|
- show: false
|
|
|
|
- },
|
|
|
|
- rechargeShow: false,
|
|
|
|
- swiperCurrent: 0,
|
|
|
|
- currentEpisode: null
|
|
|
|
|
|
+ buyRecord: [], // 购买记录
|
|
|
|
+ rechargeShow: false, // 显示充值
|
|
|
|
+ swiperCurrent: 1, // 当前滚动
|
|
|
|
+ currentEpisode: {}, // 当前播放剧集
|
|
|
|
+ swiperEpisode: { // swiper 剧集
|
|
|
|
+ prev: {},
|
|
|
|
+ current: {},
|
|
|
|
+ next: {}
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState({
|
|
...mapState({
|
|
userInfo: seate => seate.user.info
|
|
userInfo: seate => seate.user.info
|
|
}),
|
|
}),
|
|
- src() {
|
|
|
|
- if (!this.episode) return ''
|
|
|
|
- return this.currentEpisode.url
|
|
|
|
- },
|
|
|
|
- episodes() {
|
|
|
|
- const list = []
|
|
|
|
- if (this.episode) {
|
|
|
|
- let temp = []
|
|
|
|
- this.episode.lists.forEach((obj, index) => {
|
|
|
|
- temp.push(obj)
|
|
|
|
- if (temp.length === 6 || index === (this.episode.lists.length - 1)) {
|
|
|
|
- const start = list.length ? (list.length * 6) + 1 : 1
|
|
|
|
- const end = (start - 1) + temp.length
|
|
|
|
- list.push({ title: `${start}集-${end}集`, lists: temp })
|
|
|
|
- temp = []
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- return list
|
|
|
|
- },
|
|
|
|
videoContext() {
|
|
videoContext() {
|
|
- return uni.createVideoContext(`video${this.swiperCurrent}`, this)
|
|
|
|
|
|
+ const indexArr = ['prev', 'current', 'next']
|
|
|
|
+ const swiperKey = indexArr[this.swiperCurrent]
|
|
|
|
+ return uni.createVideoContext(`video${swiperKey}`, this)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
- 'toast.show'(val) {
|
|
|
|
- if (val) {
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.toast.show = false
|
|
|
|
- }, 1000)
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
|
|
+ // 进度条
|
|
progress(val) {
|
|
progress(val) {
|
|
if (val >= 100) {
|
|
if (val >= 100) {
|
|
- if ((this.swiperCurrent + 1) === this.episode.lists.length) {
|
|
|
|
|
|
+ const len = this.lists.length
|
|
|
|
+ const indexArr = ['prev', 'current', 'next']
|
|
|
|
+ const swiperKey = indexArr[this.swiperCurrent]
|
|
|
|
+ if (this.swiperEpisode[swiperKey].sort === this.lists[len - 1].sort) {
|
|
this.$u.toast('已全部播放完成')
|
|
this.$u.toast('已全部播放完成')
|
|
return 100
|
|
return 100
|
|
}
|
|
}
|
|
- this.swiperCurrent += 1
|
|
|
|
- this.currentEpisode = this.episode.lists[this.swiperCurrent]
|
|
|
|
|
|
+ // 切换
|
|
|
|
+ switch (this.swiperCurrent) {
|
|
|
|
+ case 0:
|
|
|
|
+ this.swiperCurrent = 1
|
|
|
|
+ break
|
|
|
|
+ case 1:
|
|
|
|
+ this.swiperCurrent = 2
|
|
|
|
+ break
|
|
|
|
+ case 2:
|
|
|
|
+ this.swiperCurrent = 3
|
|
|
|
+ break
|
|
|
|
+ }
|
|
this.$forceUpdate()
|
|
this.$forceUpdate()
|
|
- this.$loading('下一集加载中...')
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.$hideLoading()
|
|
|
|
- this.handlePlay(this.currentEpisode)
|
|
|
|
- }, 1000)
|
|
|
|
}
|
|
}
|
|
|
|
+ },
|
|
|
|
+ swiperCurrent(val) {
|
|
|
|
+ const indexArr = ['prev', 'current', 'next']
|
|
|
|
+ const swiperKey = indexArr[val]
|
|
|
|
+ const dataIndex = this.lists.findIndex(val => {
|
|
|
|
+ return this.swiperEpisode[swiperKey].sort === val.sort
|
|
|
|
+ })
|
|
|
|
+ const len = this.lists.length
|
|
|
|
+ let prevIndex, currentIndex, nextIndex
|
|
|
|
+ switch (swiperKey) {
|
|
|
|
+ case 'prev':
|
|
|
|
+ currentIndex = dataIndex + 1 >= len ? 0 : dataIndex + 1
|
|
|
|
+ nextIndex = dataIndex - 1 < 0 ? len - 1 : dataIndex - 1
|
|
|
|
+ this.swiperEpisode.current = this.lists[currentIndex]
|
|
|
|
+ this.swiperEpisode.next = this.lists[nextIndex]
|
|
|
|
+ break
|
|
|
|
+ case 'current':
|
|
|
|
+ prevIndex = dataIndex - 1 < 0 ? len - 1 : dataIndex - 1
|
|
|
|
+ nextIndex = dataIndex + 1 >= len ? 0 : dataIndex + 1
|
|
|
|
+ this.swiperEpisode.prev = this.lists[prevIndex]
|
|
|
|
+ this.swiperEpisode.next = this.lists[nextIndex]
|
|
|
|
+ break
|
|
|
|
+ case 'next':
|
|
|
|
+ prevIndex = dataIndex + 1 >= len ? 0 : dataIndex + 1
|
|
|
|
+ currentIndex = dataIndex - 1 < 0 ? len - 1 : dataIndex - 1
|
|
|
|
+ this.swiperEpisode.current = this.lists[currentIndex]
|
|
|
|
+ this.swiperEpisode.prev = this.lists[prevIndex]
|
|
|
|
+ break
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 暂停其他
|
|
|
|
+ this.handlePause(this.currentEpisode, false)
|
|
|
|
+
|
|
|
|
+ // 当前播放剧集
|
|
|
|
+ this.currentEpisode = this.swiperEpisode[swiperKey]
|
|
|
|
+ // 播放
|
|
|
|
+ this.handlePlay(this.currentEpisode)
|
|
|
|
+ },
|
|
|
|
+ currentEpisode(val) {
|
|
|
|
+ console.log('-->data', val.sort)
|
|
}
|
|
}
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -288,47 +200,36 @@ export default {
|
|
this.handleBuy()
|
|
this.handleBuy()
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- console.log('-->data', item)
|
|
|
|
- item.isPlaying = true
|
|
|
|
this.isPlaying = true
|
|
this.isPlaying = true
|
|
|
|
+ item.isPlaying = true
|
|
this.videoContext.play()
|
|
this.videoContext.play()
|
|
this.watched(this.id, this.currentEpisode.id)
|
|
this.watched(this.id, this.currentEpisode.id)
|
|
},
|
|
},
|
|
// 暂停
|
|
// 暂停
|
|
- handlePause(item) {
|
|
|
|
|
|
+ handlePause(item, isAll) {
|
|
if (!this.isPlaying) return
|
|
if (!this.isPlaying) return
|
|
item.isPlaying = false
|
|
item.isPlaying = false
|
|
this.isPlaying = false
|
|
this.isPlaying = false
|
|
- this.videoContext.pause()
|
|
|
|
|
|
+ // 展厅其他的
|
|
|
|
+ const indexArr = ['prev', 'current', 'next']
|
|
|
|
+ const swiperKey = indexArr[this.swiperCurrent]
|
|
|
|
+ indexArr.forEach(obj => {
|
|
|
|
+ if (swiperKey !== obj || isAll) {
|
|
|
|
+ const videoContext = uni.createVideoContext(`video${obj}`, this)
|
|
|
|
+ videoContext.pause()
|
|
|
|
+ }
|
|
|
|
+ })
|
|
},
|
|
},
|
|
// 选择剧集
|
|
// 选择剧集
|
|
handleSelectEpisode(index) {
|
|
handleSelectEpisode(index) {
|
|
// 暂停上一个
|
|
// 暂停上一个
|
|
- this.handlePause(this.currentEpisode)
|
|
|
|
- // 切换播放
|
|
|
|
- this.swiperCurrent = index
|
|
|
|
|
|
+ this.handlePause(this.currentEpisode, true)
|
|
|
|
|
|
- const item = this.episode.lists[index]
|
|
|
|
- this.currentEpisode = item
|
|
|
|
- // 检查是否购买
|
|
|
|
- if (!this.checkBeforePlay(item)) {
|
|
|
|
- // 余额是否购买
|
|
|
|
- if (!this.checkOverage(item)) {
|
|
|
|
- this.rechargeShow = true
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- // 余额足够 直接购买
|
|
|
|
- this.handleBuy(index)
|
|
|
|
- // this.modal.show = true
|
|
|
|
- return
|
|
|
|
- }
|
|
|
|
- this.footerShow = false
|
|
|
|
- this.$loading()
|
|
|
|
- setTimeout(() => {
|
|
|
|
- this.$hideLoading()
|
|
|
|
- this.handlePlay(this.currentEpisode)
|
|
|
|
- this.watched(this.id, this.currentEpisode.id)
|
|
|
|
- }, 1000)
|
|
|
|
|
|
+ const item = this.lists[index]
|
|
|
|
+
|
|
|
|
+ // 重置SwiperEpisode数据 切换播放
|
|
|
|
+ this.swiperCurrent = 1
|
|
|
|
+ this.initSwiperEpisode(item.id)
|
|
},
|
|
},
|
|
// 当前剧集购买记录
|
|
// 当前剧集购买记录
|
|
async getBuyRecord() {
|
|
async getBuyRecord() {
|
|
@@ -338,17 +239,14 @@ export default {
|
|
},
|
|
},
|
|
// 购买剧集
|
|
// 购买剧集
|
|
async handleBuy() {
|
|
async handleBuy() {
|
|
- // this.$loading('购买中...')
|
|
|
|
await this.$api.user.episode.buyHandle(this.id, this.currentEpisode.id).then(async res => {
|
|
await this.$api.user.episode.buyHandle(this.id, this.currentEpisode.id).then(async res => {
|
|
this.$hideLoading()
|
|
this.$hideLoading()
|
|
if (typeof res.overage !== 'undefined') {
|
|
if (typeof res.overage !== 'undefined') {
|
|
this.rechargeShow = true
|
|
this.rechargeShow = true
|
|
} else {
|
|
} else {
|
|
this.$u.toast('购买成功')
|
|
this.$u.toast('购买成功')
|
|
- this.modal.show = false
|
|
|
|
await this.getBuyRecord()
|
|
await this.getBuyRecord()
|
|
this.handlePlay(this.currentEpisode)
|
|
this.handlePlay(this.currentEpisode)
|
|
- this.footerShow = false
|
|
|
|
this.$api.user.info().then(res => {
|
|
this.$api.user.info().then(res => {
|
|
this.$store.dispatch('user/info', res.data)
|
|
this.$store.dispatch('user/info', res.data)
|
|
})
|
|
})
|
|
@@ -357,15 +255,9 @@ export default {
|
|
this.$hideLoading()
|
|
this.$hideLoading()
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ // 滚动 Swiper
|
|
handleSwiperChancge({ detail }) {
|
|
handleSwiperChancge({ detail }) {
|
|
- // 暂停上一个
|
|
|
|
- this.handlePause(this.currentEpisode)
|
|
|
|
-
|
|
|
|
- console.log('-->data', detail)
|
|
|
|
this.swiperCurrent = detail.current
|
|
this.swiperCurrent = detail.current
|
|
- this.currentEpisode = this.episode.lists[this.swiperCurrent]
|
|
|
|
- // 播放
|
|
|
|
- this.handlePlay(this.currentEpisode)
|
|
|
|
},
|
|
},
|
|
// 播放前检查剧集是否购买/免费
|
|
// 播放前检查剧集是否购买/免费
|
|
checkBeforePlay(item) {
|
|
checkBeforePlay(item) {
|
|
@@ -388,46 +280,6 @@ export default {
|
|
checkOverage(item) {
|
|
checkOverage(item) {
|
|
return this.userInfo.info.integral >= item.sale_price
|
|
return this.userInfo.info.integral >= item.sale_price
|
|
},
|
|
},
|
|
- // 检查是否收藏当前剧集
|
|
|
|
- checkCollect() {
|
|
|
|
- this.$api.user.collect.check(this.id).then(res => {
|
|
|
|
- this.isCollect = res.data
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // 收藏相关 处理
|
|
|
|
- handleCollect() {
|
|
|
|
- const method = this.isCollect ? 'destroy' : 'add'
|
|
|
|
- const num = this.isCollect ? -1 : 1
|
|
|
|
- this.$api.user.collect[method](this.id).then(res => {
|
|
|
|
- if (res.data) {
|
|
|
|
- this.toast.show = true
|
|
|
|
- this.toast.status = this.isCollect ? 'cancel' : 'success'
|
|
|
|
- this.toast.text = this.isCollect ? '取消收藏' : '收藏成功'
|
|
|
|
- this.episode.user_collect_count += num
|
|
|
|
- this.isCollect = !this.isCollect
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // 检查是否喜欢当前短剧
|
|
|
|
- checkFavorite() {
|
|
|
|
- this.$api.user.favorite.check(this.id).then(res => {
|
|
|
|
- this.isFav = res.data
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
- // 处理 喜欢剧集
|
|
|
|
- handleFavorite() {
|
|
|
|
- const method = this.isFav ? 'destroy' : 'add'
|
|
|
|
- const num = this.isFav ? -1 : 1
|
|
|
|
- this.$api.user.favorite[method](this.id).then(res => {
|
|
|
|
- if (res.data) {
|
|
|
|
- this.toast.show = true
|
|
|
|
- this.toast.status = this.isFav ? 'cancel' : 'success'
|
|
|
|
- this.toast.text = this.isFav ? '取消喜欢' : '喜欢成功'
|
|
|
|
- this.episode.user_favorite_count += num
|
|
|
|
- this.isFav = !this.isFav
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- },
|
|
|
|
// 记录观看记录
|
|
// 记录观看记录
|
|
watched(id, list_id) {
|
|
watched(id, list_id) {
|
|
this.$api.user.episode.watched(id, list_id).then(res => {
|
|
this.$api.user.episode.watched(id, list_id).then(res => {
|
|
@@ -435,44 +287,76 @@ export default {
|
|
})
|
|
})
|
|
},
|
|
},
|
|
// 分享
|
|
// 分享
|
|
- shared(id, list_id) {
|
|
|
|
|
|
+ handleShared(id, list_id) {
|
|
this.$api.episode.shared(id, list_id).then(res => {
|
|
this.$api.episode.shared(id, list_id).then(res => {
|
|
this.episode.share_count += 1
|
|
this.episode.share_count += 1
|
|
})
|
|
})
|
|
},
|
|
},
|
|
|
|
+ handleCollectAndFavChange(data) {
|
|
|
|
+ console.log('-->data', data)
|
|
|
|
+ if (data.type === 'collect') {
|
|
|
|
+ this.episode.user_collect_count += data.num
|
|
|
|
+ } else {
|
|
|
|
+ this.episode.user_favorite_count += data.num
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // // 初始化 Swiper 剧集
|
|
|
|
+ initSwiperEpisode(listId) {
|
|
|
|
+ let currentIndex = 0
|
|
|
|
+ if (listId) {
|
|
|
|
+ currentIndex = this.lists.findIndex(obj => {
|
|
|
|
+ return parseInt(listId) === parseInt(obj.id)
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ let prevIndex = currentIndex - 1
|
|
|
|
+ let nextIndex = currentIndex + 1
|
|
|
|
+ const len = this.lists.length
|
|
|
|
+ if (parseInt(listId) === 0 || prevIndex < 0) {
|
|
|
|
+ prevIndex = len - 1
|
|
|
|
+ }
|
|
|
|
+ //
|
|
|
|
+ if (nextIndex >= len) {
|
|
|
|
+ nextIndex = 0
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ this.swiperEpisode = {
|
|
|
|
+ prev: this.lists[prevIndex],
|
|
|
|
+ current: this.lists[currentIndex],
|
|
|
|
+ next: this.lists[nextIndex]
|
|
|
|
+ }
|
|
|
|
+ console.log('-->data', JSON.stringify(this.swiperEpisode))
|
|
|
|
+
|
|
|
|
+ this.currentEpisode = this.lists[currentIndex]
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ this.handlePlay(this.currentEpisode)
|
|
|
|
+ })
|
|
|
|
+ },
|
|
// 获取剧集详情
|
|
// 获取剧集详情
|
|
getEpisode() {
|
|
getEpisode() {
|
|
this.loading = true
|
|
this.loading = true
|
|
this.$api.episode.detail(this.id).then(res => {
|
|
this.$api.episode.detail(this.id).then(res => {
|
|
this.loading = false
|
|
this.loading = false
|
|
this.episode = res.data
|
|
this.episode = res.data
|
|
|
|
+ uni.setNavigationBarTitle({
|
|
|
|
+ title: this.episode.name + (this.episode.status === 0 ? ' | 更新中' : '已完结')
|
|
|
|
+ })
|
|
this.episode.lists.forEach((obj, index) => {
|
|
this.episode.lists.forEach((obj, index) => {
|
|
obj.isPlaying = false
|
|
obj.isPlaying = false
|
|
obj.index = index
|
|
obj.index = index
|
|
|
|
+ obj.progress = 0
|
|
})
|
|
})
|
|
- if (this.listId) {
|
|
|
|
- this.episode.lists.forEach((obj, index) => {
|
|
|
|
- if (parseInt(this.listId) === parseInt(obj.id)) {
|
|
|
|
- this.currentEpisode = obj
|
|
|
|
- this.swiperCurrent = index
|
|
|
|
- }
|
|
|
|
- })
|
|
|
|
- } else {
|
|
|
|
- this.currentEpisode = this.episode.lists[0]
|
|
|
|
- }
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
- this.handlePlay(this.currentEpisode)
|
|
|
|
- })
|
|
|
|
|
|
+ this.lists = this.episode.lists
|
|
|
|
+ // 初始化 Swiper 剧集
|
|
|
|
+ this.initSwiperEpisode(this.listId)
|
|
})
|
|
})
|
|
}
|
|
}
|
|
},
|
|
},
|
|
async onLoad(options) {
|
|
async onLoad(options) {
|
|
this.id = options.id
|
|
this.id = options.id
|
|
this.listId = options?.list_id
|
|
this.listId = options?.list_id
|
|
|
|
+ this.listId = this.listId ? this.listId : 0
|
|
await this.getBuyRecord()
|
|
await this.getBuyRecord()
|
|
this.getEpisode()
|
|
this.getEpisode()
|
|
- this.checkCollect()
|
|
|
|
- this.checkFavorite()
|
|
|
|
},
|
|
},
|
|
// 分享
|
|
// 分享
|
|
onShareAppMessage(res) {
|
|
onShareAppMessage(res) {
|
|
@@ -490,7 +374,7 @@ export default {
|
|
imageUrl: this.episode.cover_img,
|
|
imageUrl: this.episode.cover_img,
|
|
desc: this.episode.name,
|
|
desc: this.episode.name,
|
|
success: res => {
|
|
success: res => {
|
|
- this.shared(this.id, this.currentEpisode.id)
|
|
|
|
|
|
+ this.handleShared(this.id, this.currentEpisode.id)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -533,7 +417,7 @@ export default {
|
|
z-index: 99;
|
|
z-index: 99;
|
|
.swiper-item {
|
|
.swiper-item {
|
|
width: 100%;
|
|
width: 100%;
|
|
- height: 100%;
|
|
|
|
|
|
+ height: calc(100vh - #{150rpx});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
.progress-container{
|
|
.progress-container{
|
|
@@ -549,194 +433,5 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- .view-num{
|
|
|
|
- position: fixed;
|
|
|
|
- right: 20rpx;
|
|
|
|
- top: 40rpx;
|
|
|
|
- color: #fff;
|
|
|
|
- font-size: 26rpx;
|
|
|
|
- z-index: 100;
|
|
|
|
- text{
|
|
|
|
- margin-left: 10rpx;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- .status-bar{
|
|
|
|
- position: fixed;
|
|
|
|
- bottom: 300rpx;
|
|
|
|
- right: 40rpx;
|
|
|
|
- color: $default-color;
|
|
|
|
- z-index: 999;
|
|
|
|
- .item{
|
|
|
|
- margin-bottom: 40rpx;
|
|
|
|
- &.share{
|
|
|
|
- position: relative;
|
|
|
|
- button{
|
|
|
|
- position: absolute;
|
|
|
|
- background: transparent;
|
|
|
|
- top: 0;
|
|
|
|
- left: 0;
|
|
|
|
- right: 0;
|
|
|
|
- bottom: 0;
|
|
|
|
- z-index: 1;
|
|
|
|
- &:after{
|
|
|
|
- content: unset;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- &.active{
|
|
|
|
- color: $primary-color;
|
|
|
|
- }
|
|
|
|
- text{
|
|
|
|
- margin-top: 10rpx;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- .footer{
|
|
|
|
- position: fixed;
|
|
|
|
- width: 95vw;
|
|
|
|
- height: 76rpx;
|
|
|
|
- background: rgba(24, 28, 47, 0.8);
|
|
|
|
- // #ifdef MP-KUAISHOU
|
|
|
|
- bottom: 150rpx;
|
|
|
|
- // #endif
|
|
|
|
- // #ifdef MP-TOUTIAO | MP-WEIXIN
|
|
|
|
- bottom: 100rpx;
|
|
|
|
- // #endif
|
|
|
|
- left: 50%;
|
|
|
|
- transform: translateX(-50%);
|
|
|
|
- font-size: 26rpx;
|
|
|
|
- color: $info-color;
|
|
|
|
- border-radius: 20rpx;
|
|
|
|
- z-index: 999;
|
|
|
|
- transition: .3s;
|
|
|
|
- &.episode{
|
|
|
|
- bottom: 700rpx;
|
|
|
|
- margin-top: -4rpx;
|
|
|
|
- border-bottom-left-radius: 0;
|
|
|
|
- border-bottom-right-radius: 0;
|
|
|
|
- .episode-container{
|
|
|
|
- display: flex;
|
|
|
|
- margin-top: -4rpx;
|
|
|
|
- border-bottom-left-radius: 20px;
|
|
|
|
- border-bottom-right-radius: 20px;
|
|
|
|
- }
|
|
|
|
- .bar{
|
|
|
|
- .arrow{
|
|
|
|
- transform: rotate(180deg);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- .bar{
|
|
|
|
- padding: 0 20rpx;
|
|
|
|
- .icon{
|
|
|
|
- background: url("/static/image/video.png") no-repeat center;
|
|
|
|
- background-size: 70%;
|
|
|
|
- width: 80rpx;
|
|
|
|
- height: 80rpx;
|
|
|
|
- }
|
|
|
|
- .name{
|
|
|
|
- text-align: left;
|
|
|
|
- flex: 1;
|
|
|
|
- padding: 0 30rpx;
|
|
|
|
- }
|
|
|
|
- .arrow{
|
|
|
|
- transition: .3s;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- .episode-container{
|
|
|
|
- display: none;
|
|
|
|
- background: inherit;
|
|
|
|
- min-height: 620rpx;
|
|
|
|
- .header-box{
|
|
|
|
- white-space: nowrap;
|
|
|
|
- margin: 20rpx 0;
|
|
|
|
- .header-item{
|
|
|
|
- margin-right: 20rpx;
|
|
|
|
- border-radius: 20rpx;
|
|
|
|
- display: inline-block;
|
|
|
|
- width: 200rpx;
|
|
|
|
- border: 1rpx solid $default-color;
|
|
|
|
- text-align: center;
|
|
|
|
- padding: 10rpx 0;
|
|
|
|
- color: $default-color;
|
|
|
|
- &.active{
|
|
|
|
- border-color: $primary-color;
|
|
|
|
- color: $primary-color;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- .content{
|
|
|
|
- margin-top: 20rpx;
|
|
|
|
- .episode-item{
|
|
|
|
- position: relative;
|
|
|
|
- width: calc((100% - #{40rpx}) / 3);
|
|
|
|
- margin-right: 20rpx;
|
|
|
|
- margin-bottom: 20rpx;
|
|
|
|
- overflow: hidden;
|
|
|
|
- border-radius: 18rpx;
|
|
|
|
- &:nth-child(3n){
|
|
|
|
- margin-right: 0;
|
|
|
|
- }
|
|
|
|
- .playing{
|
|
|
|
- position: absolute;
|
|
|
|
- top: 0;
|
|
|
|
- left: 0;
|
|
|
|
- bottom: 0;
|
|
|
|
- right: 0;
|
|
|
|
- background: rgba(0,0,0,.5) url("/static/image/playing.png") no-repeat center;
|
|
|
|
- background-size: 40rpx;
|
|
|
|
- z-index: 2;
|
|
|
|
- }
|
|
|
|
- image{
|
|
|
|
- width: 100%;
|
|
|
|
- height: 260rpx;
|
|
|
|
- }
|
|
|
|
- text{
|
|
|
|
- position: absolute;
|
|
|
|
- left: 0;
|
|
|
|
- bottom: 0;
|
|
|
|
- right: 0;
|
|
|
|
- color: $default-color;
|
|
|
|
- padding: 20rpx 0;
|
|
|
|
- text-align: center;
|
|
|
|
- background: rgba(0,0,0,.3);
|
|
|
|
- z-index: 1;
|
|
|
|
- }
|
|
|
|
- .lock{
|
|
|
|
- position: absolute;
|
|
|
|
- top: 0;
|
|
|
|
- left: 0;
|
|
|
|
- bottom: 0;
|
|
|
|
- right: 0;
|
|
|
|
- background: rgba(0,0,0,.5);
|
|
|
|
- z-index: 2;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- .toast{
|
|
|
|
- position: fixed;
|
|
|
|
- width: 60vw;
|
|
|
|
- background: rgba(0,0,0,.5);
|
|
|
|
- height: 300rpx;
|
|
|
|
- top: 50%;
|
|
|
|
- left: 50%;
|
|
|
|
- transform: translate(-50%,-50%);
|
|
|
|
- border-radius: 20rpx;
|
|
|
|
- font-size: 36rpx;
|
|
|
|
- color: $default-color;
|
|
|
|
- &.success{
|
|
|
|
- color: $primary-color;
|
|
|
|
- }
|
|
|
|
- text{
|
|
|
|
- margin-top: 20rpx;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|