index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <view class="play">
  3. <video-player v-if="videoUrl" :videoUrl="videoUrl" :initialTime="durationSeconds" :selanShow="selanShow" @timeUpdate="handleTimeUpdate" @chectSelanShow="chectSelanShow"></video-player>
  4. <image v-else :src="videoData.thumbnail" class="cover_img"></image>
  5. <view v-if="selanShow" class="anthologys_detail">
  6. <view class="anthology" @click="show = true">
  7. <view class="ant">
  8. <image :src="play_img" class="play"></image>
  9. <text class="ant-text">{{videoData.name}}(1/{{list.length}})</text>
  10. </view>
  11. <view class="ant">
  12. <text>选集</text>
  13. <pv-icon name="icon-shangla" color='#fff'
  14. :customStyle="{ fontSize: '32rpx',marginLeft:'8rpx'}"></pv-icon>
  15. </view>
  16. </view>
  17. <!-- <view class="hot">
  18. <pv-icon name="icon-huomiao" color='#fff' :customStyle="{ fontSize: '32rpx'}"></pv-icon>
  19. <text>12.8W</text>
  20. </view> -->
  21. </view>
  22. <u-popup :show="show" @close="close" @open="open" safeAreaInsetBottom :round="15">
  23. <view class="opera">
  24. <view class="opera-top">
  25. <view class="title">
  26. <image class="cover" :src="videoData.thumbnail"></image>
  27. <view class="name">
  28. <text>{{videoData.name}}</text>
  29. <text>共{{list.length}}集</text>
  30. </view>
  31. </view>
  32. <view @click="close">
  33. <pv-icon name="icon-xiala"
  34. :customStyle="{ fontSize: '40rpx',fontWeight: 'bold'}"></pv-icon>
  35. </view>
  36. </view>
  37. <view class="serice">
  38. <!-- <u-tabs :list="tabs" lineWidth="0" lineColor="#f56c6c" :activeStyle="{
  39. color: '#62C5C6',
  40. transform: 'scale(1)'
  41. }" :inactiveStyle="{
  42. color: '#000',
  43. transform: 'scale(1)'
  44. }" itemStyle="padding-left: 0px; padding-right: 20px; height: 34px;">
  45. </u-tabs> -->
  46. <view class="numbers">
  47. <view class="num">
  48. <view class="num_item" :class="{ num_item_select: item.sort == sort }" v-for="(item,index) in list" :key="index" @click="toPlay(item)">
  49. <text class="num_text">{{item.sort}}</text>
  50. <view v-if="item.sort === sort" class="num_play">
  51. <view></view>
  52. <view></view>
  53. <view></view>
  54. </view>
  55. <view v-if="!item.isPay" class="lock">
  56. <pv-icon name="icon-v-locked" color="#A37449"
  57. :customStyle="{ fontSize: '20rpx',fontWeight: 'bold'}"></pv-icon>
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </u-popup>
  65. <u-popup :show="isPayShow" @open="openPlay" @close="closePlay" safeAreaInsetBottom :round="15">
  66. <view class="pay_video">
  67. <view class="tit flex aic">
  68. <pv-icon name="icon-v-locked" color="#fff" :customStyle="{ fontSize: '30rpx',fontWeight: 'bold'}"></pv-icon>
  69. <text class="tips">当前视频没有播放权限</text>
  70. </view>
  71. <view class="pays flex jcsa aic">
  72. <view class="pay_item single" :class="{ pay_item_select: !type }" @click="changeType(0)">
  73. <text>单集购买</text>
  74. </view>
  75. <view class="pay_item all" :class="{ pay_item_select: type }" @click="changeType(1)">
  76. <text>整集购买</text>
  77. </view>
  78. </view>
  79. <u-button class="btn" type="primary" shape="circle" @click="confirm">确认</u-button>
  80. </view>
  81. </u-popup>
  82. </view>
  83. </template>
  84. <script>
  85. import defaultConfig from '@/config/default.js'
  86. import { getServerShipVideoUrl,getServerShipVideoList } from '@/apis/index'
  87. import { buyShipVideo,syncWatchHistory } from '@/apis/video'
  88. export default {
  89. data() {
  90. return {
  91. id:'',
  92. type: 0,
  93. watchVo:{},//点击短剧
  94. videoData:{},//传入短剧信息
  95. sort:0,//集数
  96. show: false,//集数弹窗
  97. isPayShow: false,//购买集数弹窗
  98. selanShow: true,
  99. videoUrl: '', //路径
  100. play_img: defaultConfig.ossImgUrl + '/playVideo/video/ic_search.png',
  101. coverImg: 'https://obs-fanxing.obs.cn-east-3.myhuaweicloud.com/retail/main/img_bgtop.png',
  102. tabs: [{
  103. name: '1-50',
  104. }, {
  105. name: '51-94'
  106. }],
  107. list: [],
  108. shipVideoId:'',
  109. durationSeconds:'',
  110. }
  111. },
  112. onLoad(params){
  113. this.id = params.id
  114. this.videoData = JSON.parse(params.data)
  115. this.getVideoList(this.id)
  116. },
  117. onUnload(){
  118. this.setWatch()
  119. },
  120. methods: {
  121. toPlay(item){
  122. if(item.sort === this.sort) return
  123. this.getUrl(item)
  124. },
  125. // 获取视频url
  126. async getUrl(item){
  127. if(!item.isPay){
  128. this.isPayShow = true
  129. this.shipVideoId = item.id
  130. return
  131. }
  132. const res = await getServerShipVideoUrl(item.id)
  133. this.sort = item.sort
  134. this.videoUrl = res
  135. this.show = false
  136. },
  137. // 查看视频列表
  138. async getVideoList(id){
  139. const res = await getServerShipVideoList(id)
  140. this.watchVo = res.serverVideoWatchVo
  141. // this.videoUrl = res.serverVideoWatchVo.url
  142. // this.sort = res.serverVideoWatchVo.sort
  143. this.list = res.videoVos
  144. let item
  145. if(this.watchVo){
  146. item = this.watchVo
  147. this.shipVideoId = item.shipVideoId
  148. this.sort = item.sort
  149. this.videoUrl = item.url
  150. this.durationSeconds = item.durationSeconds
  151. }else{
  152. item = this.list[0]
  153. this.getUrl(item)
  154. }
  155. },
  156. // 购买视频
  157. async confirm(){
  158. let params = {
  159. shipVideoId: this.shipVideoId,
  160. type: this.type
  161. }
  162. const res = await buyShipVideo(params)
  163. this.isPayShow = false
  164. this.getVideoList(this.id)
  165. console.log(res);
  166. },
  167. // 观看同步
  168. async setWatch(){
  169. let params = {
  170. shipVideoId: this.shipVideoId,
  171. shipProgramId: this.id,
  172. durationSeconds: this.durationSeconds
  173. }
  174. const res = await syncWatchHistory(params)
  175. },
  176. // 获取当前播放时间
  177. handleTimeUpdate(time){
  178. this.durationSeconds = time
  179. },
  180. // 切换整集/单集
  181. changeType(type){
  182. if(type == this.type) return
  183. type?this.type = 1:this.type = 0
  184. },
  185. //显示剧名集数
  186. chectSelanShow(status){
  187. this.selanShow = status
  188. },
  189. open() {
  190. },
  191. close() {
  192. this.show = false
  193. },
  194. closePlay() {
  195. this.isPayShow = false
  196. // this.show = true
  197. },
  198. openPlay(){
  199. this.show = false
  200. }
  201. }
  202. }
  203. </script>
  204. <style lang="scss">
  205. .play {
  206. width: 100%;
  207. height: 100%;
  208. .cover_img{
  209. width: 100%;
  210. height: 100%;
  211. }
  212. .anthologys_detail {
  213. box-sizing: border-box;
  214. width: 100%;
  215. padding: 0 24rpx 0 34rpx;
  216. display: flex;
  217. align-items: center;
  218. justify-content: space-between;
  219. color: #fff;
  220. position: absolute;
  221. bottom: calc(70rpx + constant(safe-area-inset-bottom));
  222. bottom: calc(70rpx);
  223. z-index: 99;
  224. .anthology {
  225. flex-grow: 1;
  226. display: flex;
  227. align-items: center;
  228. justify-content: space-between;
  229. // height: 72rpx;
  230. background: #1A1A1A;
  231. border-radius: 72rpx;
  232. padding: 16rpx 20rpx;
  233. font-size: 32rpx;
  234. // width: 572rpx;
  235. .ant {
  236. display: flex;
  237. align-items: center;
  238. .ant-text {
  239. margin-left: 16rpx;
  240. }
  241. }
  242. .play {
  243. width: 40rpx;
  244. height: 40rpx;
  245. }
  246. }
  247. .hot {
  248. width: 150rpx;
  249. text-align: right;
  250. text {
  251. margin-left: 8rpx;
  252. }
  253. }
  254. }
  255. .opera {
  256. padding: 20rpx 30rpx;
  257. .opera-top {
  258. display: flex;
  259. justify-content: space-between;
  260. align-items: center;
  261. margin-bottom: 10rpx;
  262. .title {
  263. display: flex;
  264. .cover {
  265. width: 80rpx;
  266. height: 108rpx;
  267. border-radius: 10rpx;
  268. margin-right: 20rpx;
  269. }
  270. .name {
  271. display: flex;
  272. flex-direction: column;
  273. justify-content: space-around;
  274. text:nth-child(1) {
  275. color: #000;
  276. font-size: 40rpx;
  277. font-weight: bold;
  278. }
  279. text:nth-child(2) {
  280. color: #999;
  281. font-size: 30rpx;
  282. }
  283. }
  284. }
  285. }
  286. .serice {
  287. overflow: hidden;
  288. .numbers {
  289. height: 500rpx;
  290. overflow: scroll;
  291. .num {
  292. display: flex;
  293. flex-wrap: wrap;
  294. .num_item_select{
  295. background: #E9F9F9 !important;
  296. .num_text {
  297. color: #62C5C6;
  298. }
  299. }
  300. .num_item {
  301. position: relative;
  302. display: flex;
  303. justify-content: center;
  304. align-items: center;
  305. width: calc(20% - 20rpx);
  306. height: 110rpx;
  307. margin: 10rpx;
  308. background: #FAFAFA;
  309. color: #000;
  310. box-sizing: border-box;
  311. .num_play {
  312. position: absolute;
  313. left: 10rpx;
  314. bottom: 10rpx;
  315. display: flex;
  316. align-items: flex-end;
  317. view {
  318. width: 6rpx;
  319. background: #62C5C6;
  320. margin-right: 6rpx;
  321. border-radius: 6rpx;
  322. }
  323. view:nth-child(1) {
  324. height: 21rpx;
  325. }
  326. view:nth-child(2) {
  327. height: 16rpx;
  328. }
  329. view:nth-child(3) {
  330. height: 18rpx;
  331. }
  332. }
  333. .lock {
  334. position: absolute;
  335. top: 0;
  336. right: 0;
  337. width: 40rpx;
  338. height: 40rpx;
  339. background: #F9E2B7;
  340. border-radius: 0rpx 12rpx 0rpx 12rpx;
  341. // text-align: center;
  342. // line-height: 40rpx;
  343. display: flex;
  344. justify-content: center;
  345. align-items: center;
  346. }
  347. }
  348. }
  349. }
  350. }
  351. }
  352. .pay_video{
  353. background: linear-gradient( 180deg, #216CFF 10%, #C7F0FF 50%);
  354. padding: 30rpx 20rpx;
  355. // margin-bottom: calc(20rpx + constant(safe-area-inset-bottom)) !important;
  356. margin-bottom: calc(env(safe-area-inset-bottom)) !important;
  357. // height: 300rpx;
  358. .tit{
  359. color: #fff;
  360. .tips{
  361. margin-left: 5rpx;
  362. }
  363. }
  364. .pays{
  365. margin: 30rpx 0;
  366. .pay_item{
  367. background: #fff;
  368. width: 40%;
  369. height: 100rpx;
  370. border-radius: 12rpx;
  371. text-align: center;
  372. line-height: 100rpx;
  373. }
  374. .pay_item_select{
  375. background: #216CFF;
  376. color: #fff;
  377. }
  378. }
  379. .btn{
  380. // margin-bottom: 30rpx;
  381. }
  382. }
  383. }
  384. </style>