123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413 |
- <template>
- <view class="play">
- <video-player v-if="videoUrl" :videoUrl="videoUrl" :initialTime="durationSeconds" @timeUpdate="handleTimeUpdate"></video-player>
- <image v-else :src="videoData.thumbnail" class="cover_img"></image>
- <view class="anthologys_detail">
- <view class="anthology" @click="show = true">
- <view class="ant">
- <image :src="play_img" class="play"></image>
- <text class="ant-text">{{videoData.name}}(1/{{list.length}})</text>
- </view>
- <view class="ant">
- <text>选集</text>
- <pv-icon name="icon-shangla" color='#fff'
- :customStyle="{ fontSize: '32rpx',marginLeft:'8rpx'}"></pv-icon>
- </view>
- </view>
- <!-- <view class="hot">
- <pv-icon name="icon-huomiao" color='#fff' :customStyle="{ fontSize: '32rpx'}"></pv-icon>
- <text>12.8W</text>
- </view> -->
- </view>
- <u-popup :show="show" @close="close" @open="open" safeAreaInsetBottom :round="15">
- <view class="opera">
- <view class="opera-top">
- <view class="title">
- <image class="cover" :src="videoData.thumbnail"></image>
- <view class="name">
- <text>{{videoData.name}}</text>
- <text>共{{list.length}}集</text>
- </view>
- </view>
- <view @click="close">
- <pv-icon name="icon-xiala"
- :customStyle="{ fontSize: '40rpx',fontWeight: 'bold'}"></pv-icon>
- </view>
- </view>
- <view class="serice">
- <!-- <u-tabs :list="tabs" lineWidth="0" lineColor="#f56c6c" :activeStyle="{
- color: '#62C5C6',
- transform: 'scale(1)'
- }" :inactiveStyle="{
- color: '#000',
- transform: 'scale(1)'
- }" itemStyle="padding-left: 0px; padding-right: 20px; height: 34px;">
- </u-tabs> -->
- <view class="numbers">
- <view class="num">
- <view class="num_item" :class="{ num_item_select: item.sort == sort }" v-for="(item,index) in list" :key="index" @click="toPlay(item)">
- <text class="num_text">{{item.sort}}</text>
- <view v-if="item.sort === sort" class="num_play">
- <view></view>
- <view></view>
- <view></view>
- </view>
- <view v-if="!item.isPay" class="lock">
- <pv-icon name="icon-v-locked" color="#A37449"
- :customStyle="{ fontSize: '20rpx',fontWeight: 'bold'}"></pv-icon>
- </view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </u-popup>
- <u-popup :show="isPayShow" @open="openPlay" @close="closePlay" safeAreaInsetBottom :round="15">
- <view class="pay_video">
- <view class="tit flex aic">
- <pv-icon name="icon-v-locked" color="#fff" :customStyle="{ fontSize: '30rpx',fontWeight: 'bold'}"></pv-icon>
- <text class="tips">当前视频没有播放权限</text>
- </view>
- <view class="pays flex jcsa aic">
- <view class="pay_item single" :class="{ pay_item_select: !type }" @click="changeType(0)">
- <text>单集购买</text>
- </view>
- <view class="pay_item all" :class="{ pay_item_select: type }" @click="changeType(1)">
- <text>整集购买</text>
- </view>
- </view>
- <u-button class="btn" type="primary" shape="circle" @click="confirm">确认</u-button>
- </view>
- </u-popup>
- </view>
- </template>
- <script>
- import defaultConfig from '@/config/default.js'
- import { getServerShipVideoUrl,getServerShipVideoList } from '@/apis/index'
- import { buyShipVideo,syncWatchHistory } from '@/apis/video'
- export default {
- data() {
- return {
- id:'',
- type: 0,
- watchVo:{},
- videoData:{},
- sort:0,
- show: false,
- isPayShow: false,
- videoUrl: '', //路径
- play_img: defaultConfig.ossImgUrl + '/playVideo/video/ic_search.png',
- coverImg: 'https://obs-fanxing.obs.cn-east-3.myhuaweicloud.com/retail/main/img_bgtop.png',
- tabs: [{
- name: '1-50',
- }, {
- name: '51-94'
- }],
- list: [],
- shipVideoId:'',
- durationSeconds:'',
- }
- },
- onLoad(params){
- this.id = params.id
- this.videoData = JSON.parse(params.data)
- this.getVideoList(this.id)
- },
- onUnload(){
- this.setWatch()
- },
- methods: {
- toPlay(item){
- if(item.sort === this.sort) return
- this.getUrl(item)
- },
- // 获取视频url
- async getUrl(item){
- if(!item.isPay){
- this.isPayShow = true
- this.shipVideoId = item.id
- return
- }
- const res = await getServerShipVideoUrl(item.id)
- this.sort = item.sort
- this.videoUrl = res
- this.show = false
- },
- // 查看视频列表
- async getVideoList(id){
- const res = await getServerShipVideoList(id)
- this.watchVo = res.serverVideoWatchVo
- // this.videoUrl = res.serverVideoWatchVo.url
- // this.sort = res.serverVideoWatchVo.sort
- this.list = res.videoVos
- let item
- if(this.watchVo){
- item = this.watchVo
- this.shipVideoId = item.shipVideoId
- this.sort = item.sort
- this.videoUrl = item.url
- this.durationSeconds = item.durationSeconds
- }else{
- item = this.list[0]
- this.getUrl(item)
- }
-
-
- },
-
- // 购买视频
- async confirm(){
- let params = {
- shipVideoId: this.shipVideoId,
- type: this.type
- }
- const res = await buyShipVideo(params)
- this.isPayShow = false
- this.getVideoList(this.id)
- console.log(res);
- },
-
- // 观看同步
- async setWatch(){
- let params = {
- shipVideoId: this.shipVideoId,
- shipProgramId: this.id,
- durationSeconds: this.durationSeconds
- }
- const res = await syncWatchHistory(params)
- },
- // 获取当前播放时间
- handleTimeUpdate(time){
- this.durationSeconds = time
- },
- // 切换整集/单集
- changeType(type){
-
- if(type == this.type) return
- type?this.type = 1:this.type = 0
- },
- open() {
- },
- close() {
- this.show = false
- },
- closePlay() {
- this.isPayShow = false
- // this.show = true
- },
- openPlay(){
- this.show = false
- }
- }
- }
- </script>
- <style lang="scss">
- .play {
- width: 100%;
- height: 100%;
- .cover_img{
- width: 100%;
- height: 100%;
- }
- .anthologys_detail {
- box-sizing: border-box;
- width: 100%;
- padding: 0 24rpx 0 34rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: #fff;
- position: absolute;
- bottom: calc(70rpx + constant(safe-area-inset-bottom));
- bottom: calc(70rpx);
- z-index: 99;
- .anthology {
- flex-grow: 1;
- display: flex;
- align-items: center;
- justify-content: space-between;
- // height: 72rpx;
- background: #1A1A1A;
- border-radius: 72rpx;
- padding: 16rpx 20rpx;
- font-size: 32rpx;
- // width: 572rpx;
- .ant {
- display: flex;
- align-items: center;
- .ant-text {
- margin-left: 16rpx;
- }
- }
- .play {
- width: 40rpx;
- height: 40rpx;
- }
- }
- .hot {
- width: 150rpx;
- text-align: right;
- text {
- margin-left: 8rpx;
- }
- }
- }
- .opera {
- padding: 20rpx 30rpx;
- .opera-top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- margin-bottom: 10rpx;
- .title {
- display: flex;
- .cover {
- width: 80rpx;
- height: 108rpx;
- border-radius: 10rpx;
- margin-right: 20rpx;
- }
- .name {
- display: flex;
- flex-direction: column;
- justify-content: space-around;
- text:nth-child(1) {
- color: #000;
- font-size: 40rpx;
- font-weight: bold;
- }
- text:nth-child(2) {
- color: #999;
- font-size: 30rpx;
- }
- }
- }
- }
- .serice {
- overflow: hidden;
- .numbers {
- height: 500rpx;
- overflow: scroll;
- .num {
- display: flex;
- flex-wrap: wrap;
- .num_item_select{
- background: #E9F9F9 !important;
- .num_text {
- color: #62C5C6;
- }
- }
- .num_item {
- position: relative;
- display: flex;
- justify-content: center;
- align-items: center;
- width: calc(20% - 20rpx);
- height: 110rpx;
- margin: 10rpx;
- background: #FAFAFA;
- color: #000;
- box-sizing: border-box;
-
- .num_play {
- position: absolute;
- left: 10rpx;
- bottom: 10rpx;
- display: flex;
- align-items: flex-end;
- view {
- width: 6rpx;
- background: #62C5C6;
- margin-right: 6rpx;
- border-radius: 6rpx;
- }
- view:nth-child(1) {
- height: 21rpx;
- }
- view:nth-child(2) {
- height: 16rpx;
- }
- view:nth-child(3) {
- height: 18rpx;
- }
- }
- .lock {
- position: absolute;
- top: 0;
- right: 0;
- width: 40rpx;
- height: 40rpx;
- background: #F9E2B7;
- border-radius: 0rpx 12rpx 0rpx 12rpx;
- // text-align: center;
- // line-height: 40rpx;
- display: flex;
- justify-content: center;
- align-items: center;
- }
- }
- }
- }
- }
- }
- .pay_video{
- background: linear-gradient( 180deg, #216CFF 10%, #C7F0FF 50%);
- padding: 30rpx 20rpx;
- // margin-bottom: calc(20rpx + constant(safe-area-inset-bottom)) !important;
- margin-bottom: calc(env(safe-area-inset-bottom)) !important;
- // height: 300rpx;
- .tit{
- color: #fff;
- .tips{
- margin-left: 5rpx;
- }
- }
- .pays{
- margin: 30rpx 0;
- .pay_item{
- background: #fff;
- width: 40%;
- height: 100rpx;
- border-radius: 12rpx;
- text-align: center;
- line-height: 100rpx;
- }
- .pay_item_select{
- background: #216CFF;
- color: #fff;
- }
- }
- .btn{
- // margin-bottom: 30rpx;
- }
- }
- }
- </style>
|