index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412
  1. <template>
  2. <view class="play">
  3. <video-player v-if="videoUrl" :videoUrl="videoUrl" :initialTime="durationSeconds" @timeUpdate="handleTimeUpdate"></video-player>
  4. <image v-else :src="videoData.thumbnail" class="cover_img"></image>
  5. <view 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. videoUrl: '', //路径
  99. play_img: defaultConfig.ossImgUrl + '/playVideo/video/ic_search.png',
  100. coverImg: 'https://obs-fanxing.obs.cn-east-3.myhuaweicloud.com/retail/main/img_bgtop.png',
  101. tabs: [{
  102. name: '1-50',
  103. }, {
  104. name: '51-94'
  105. }],
  106. list: [],
  107. shipVideoId:'',
  108. durationSeconds:'',
  109. }
  110. },
  111. onLoad(params){
  112. this.id = params.id
  113. this.videoData = JSON.parse(params.data)
  114. this.getVideoList(this.id)
  115. },
  116. onUnload(){
  117. this.setWatch()
  118. },
  119. methods: {
  120. toPlay(item){
  121. if(item.sort === this.sort) return
  122. this.getUrl(item)
  123. },
  124. // 获取视频url
  125. async getUrl(item){
  126. if(!item.isPay){
  127. this.isPayShow = true
  128. return
  129. }
  130. const res = await getServerShipVideoUrl(item.id)
  131. this.shipVideoId = item.id
  132. this.sort = item.sort
  133. this.videoUrl = res
  134. this.show = false
  135. },
  136. // 查看视频列表
  137. async getVideoList(id){
  138. const res = await getServerShipVideoList(id)
  139. this.watchVo = res.serverVideoWatchVo
  140. // this.videoUrl = res.serverVideoWatchVo.url
  141. // this.sort = res.serverVideoWatchVo.sort
  142. this.list = res.videoVos
  143. let item
  144. if(this.watchVo){
  145. item = this.watchVo
  146. this.shipVideoId = item.shipVideoId
  147. this.sort = item.sort
  148. this.videoUrl = item.url
  149. this.durationSeconds = item.durationSeconds
  150. }else{
  151. item = this.list[0]
  152. this.getUrl(item)
  153. }
  154. },
  155. // 购买视频
  156. async confirm(){
  157. let params = {
  158. shipVideoId: this.shipVideoId,
  159. type: this.type
  160. }
  161. const res = await buyShipVideo(params)
  162. console.log(res);
  163. },
  164. // 观看同步
  165. async setWatch(){
  166. let params = {
  167. shipVideoId: this.shipVideoId,
  168. shipProgramId: this.id,
  169. durationSeconds: this.durationSeconds
  170. }
  171. const res = await syncWatchHistory(params)
  172. },
  173. // 获取当前播放时间
  174. handleTimeUpdate(time){
  175. this.durationSeconds = time
  176. },
  177. // 切换整集/单集
  178. changeType(type){
  179. if(type == this.type) return
  180. type?this.type = 1:this.type = 0
  181. },
  182. open() {
  183. },
  184. close() {
  185. this.show = false
  186. },
  187. closePlay() {
  188. this.isPayShow = false
  189. // this.show = true
  190. },
  191. openPlay(){
  192. this.show = false
  193. }
  194. }
  195. }
  196. </script>
  197. <style lang="scss">
  198. .play {
  199. width: 100%;
  200. height: 100%;
  201. .cover_img{
  202. width: 100%;
  203. height: 100%;
  204. }
  205. .anthologys_detail {
  206. box-sizing: border-box;
  207. width: 100%;
  208. padding: 0 24rpx 0 34rpx;
  209. display: flex;
  210. align-items: center;
  211. justify-content: space-between;
  212. color: #fff;
  213. position: absolute;
  214. bottom: calc(70rpx + constant(safe-area-inset-bottom));
  215. bottom: calc(70rpx);
  216. z-index: 99;
  217. .anthology {
  218. flex-grow: 1;
  219. display: flex;
  220. align-items: center;
  221. justify-content: space-between;
  222. // height: 72rpx;
  223. background: #1A1A1A;
  224. border-radius: 72rpx;
  225. padding: 16rpx 20rpx;
  226. font-size: 32rpx;
  227. // width: 572rpx;
  228. .ant {
  229. display: flex;
  230. align-items: center;
  231. .ant-text {
  232. margin-left: 16rpx;
  233. }
  234. }
  235. .play {
  236. width: 40rpx;
  237. height: 40rpx;
  238. }
  239. }
  240. .hot {
  241. width: 150rpx;
  242. text-align: right;
  243. text {
  244. margin-left: 8rpx;
  245. }
  246. }
  247. }
  248. .opera {
  249. padding: 20rpx 30rpx;
  250. .opera-top {
  251. display: flex;
  252. justify-content: space-between;
  253. align-items: center;
  254. margin-bottom: 10rpx;
  255. .title {
  256. display: flex;
  257. .cover {
  258. width: 80rpx;
  259. height: 108rpx;
  260. border-radius: 10rpx;
  261. margin-right: 20rpx;
  262. }
  263. .name {
  264. display: flex;
  265. flex-direction: column;
  266. justify-content: space-around;
  267. text:nth-child(1) {
  268. color: #000;
  269. font-size: 40rpx;
  270. font-weight: bold;
  271. }
  272. text:nth-child(2) {
  273. color: #999;
  274. font-size: 30rpx;
  275. }
  276. }
  277. }
  278. }
  279. .serice {
  280. overflow: hidden;
  281. .numbers {
  282. height: 500rpx;
  283. overflow: scroll;
  284. .num {
  285. display: flex;
  286. flex-wrap: wrap;
  287. .num_item_select{
  288. background: #E9F9F9 !important;
  289. .num_text {
  290. color: #62C5C6;
  291. }
  292. }
  293. .num_item {
  294. position: relative;
  295. display: flex;
  296. justify-content: center;
  297. align-items: center;
  298. width: calc(20% - 20rpx);
  299. height: 110rpx;
  300. margin: 10rpx;
  301. background: #FAFAFA;
  302. color: #000;
  303. box-sizing: border-box;
  304. .num_play {
  305. position: absolute;
  306. left: 10rpx;
  307. bottom: 10rpx;
  308. display: flex;
  309. align-items: flex-end;
  310. view {
  311. width: 6rpx;
  312. background: #62C5C6;
  313. margin-right: 6rpx;
  314. border-radius: 6rpx;
  315. }
  316. view:nth-child(1) {
  317. height: 21rpx;
  318. }
  319. view:nth-child(2) {
  320. height: 16rpx;
  321. }
  322. view:nth-child(3) {
  323. height: 18rpx;
  324. }
  325. }
  326. .lock {
  327. position: absolute;
  328. top: 0;
  329. right: 0;
  330. width: 40rpx;
  331. height: 40rpx;
  332. background: #F9E2B7;
  333. border-radius: 0rpx 12rpx 0rpx 12rpx;
  334. // text-align: center;
  335. // line-height: 40rpx;
  336. display: flex;
  337. justify-content: center;
  338. align-items: center;
  339. }
  340. }
  341. }
  342. }
  343. }
  344. }
  345. .pay_video{
  346. background: linear-gradient( 180deg, #216CFF 10%, #C7F0FF 50%);
  347. padding: 30rpx 20rpx;
  348. // margin-bottom: calc(20rpx + constant(safe-area-inset-bottom)) !important;
  349. margin-bottom: calc(env(safe-area-inset-bottom)) !important;
  350. // height: 300rpx;
  351. .tit{
  352. color: #fff;
  353. .tips{
  354. margin-left: 5rpx;
  355. }
  356. }
  357. .pays{
  358. margin: 30rpx 0;
  359. .pay_item{
  360. background: #fff;
  361. width: 40%;
  362. height: 100rpx;
  363. border-radius: 12rpx;
  364. text-align: center;
  365. line-height: 100rpx;
  366. }
  367. .pay_item_select{
  368. background: #216CFF;
  369. color: #fff;
  370. }
  371. }
  372. .btn{
  373. // margin-bottom: 30rpx;
  374. }
  375. }
  376. }
  377. </style>