index.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  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. this.shipVideoId = item.id
  129. return
  130. }
  131. const res = await getServerShipVideoUrl(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. this.isPayShow = false
  163. this.getVideoList(this.id)
  164. console.log(res);
  165. },
  166. // 观看同步
  167. async setWatch(){
  168. let params = {
  169. shipVideoId: this.shipVideoId,
  170. shipProgramId: this.id,
  171. durationSeconds: this.durationSeconds
  172. }
  173. const res = await syncWatchHistory(params)
  174. },
  175. // 获取当前播放时间
  176. handleTimeUpdate(time){
  177. this.durationSeconds = time
  178. },
  179. // 切换整集/单集
  180. changeType(type){
  181. if(type == this.type) return
  182. type?this.type = 1:this.type = 0
  183. },
  184. open() {
  185. },
  186. close() {
  187. this.show = false
  188. },
  189. closePlay() {
  190. this.isPayShow = false
  191. // this.show = true
  192. },
  193. openPlay(){
  194. this.show = false
  195. }
  196. }
  197. }
  198. </script>
  199. <style lang="scss">
  200. .play {
  201. width: 100%;
  202. height: 100%;
  203. .cover_img{
  204. width: 100%;
  205. height: 100%;
  206. }
  207. .anthologys_detail {
  208. box-sizing: border-box;
  209. width: 100%;
  210. padding: 0 24rpx 0 34rpx;
  211. display: flex;
  212. align-items: center;
  213. justify-content: space-between;
  214. color: #fff;
  215. position: absolute;
  216. bottom: calc(70rpx + constant(safe-area-inset-bottom));
  217. bottom: calc(70rpx);
  218. z-index: 99;
  219. .anthology {
  220. flex-grow: 1;
  221. display: flex;
  222. align-items: center;
  223. justify-content: space-between;
  224. // height: 72rpx;
  225. background: #1A1A1A;
  226. border-radius: 72rpx;
  227. padding: 16rpx 20rpx;
  228. font-size: 32rpx;
  229. // width: 572rpx;
  230. .ant {
  231. display: flex;
  232. align-items: center;
  233. .ant-text {
  234. margin-left: 16rpx;
  235. }
  236. }
  237. .play {
  238. width: 40rpx;
  239. height: 40rpx;
  240. }
  241. }
  242. .hot {
  243. width: 150rpx;
  244. text-align: right;
  245. text {
  246. margin-left: 8rpx;
  247. }
  248. }
  249. }
  250. .opera {
  251. padding: 20rpx 30rpx;
  252. .opera-top {
  253. display: flex;
  254. justify-content: space-between;
  255. align-items: center;
  256. margin-bottom: 10rpx;
  257. .title {
  258. display: flex;
  259. .cover {
  260. width: 80rpx;
  261. height: 108rpx;
  262. border-radius: 10rpx;
  263. margin-right: 20rpx;
  264. }
  265. .name {
  266. display: flex;
  267. flex-direction: column;
  268. justify-content: space-around;
  269. text:nth-child(1) {
  270. color: #000;
  271. font-size: 40rpx;
  272. font-weight: bold;
  273. }
  274. text:nth-child(2) {
  275. color: #999;
  276. font-size: 30rpx;
  277. }
  278. }
  279. }
  280. }
  281. .serice {
  282. overflow: hidden;
  283. .numbers {
  284. height: 500rpx;
  285. overflow: scroll;
  286. .num {
  287. display: flex;
  288. flex-wrap: wrap;
  289. .num_item_select{
  290. background: #E9F9F9 !important;
  291. .num_text {
  292. color: #62C5C6;
  293. }
  294. }
  295. .num_item {
  296. position: relative;
  297. display: flex;
  298. justify-content: center;
  299. align-items: center;
  300. width: calc(20% - 20rpx);
  301. height: 110rpx;
  302. margin: 10rpx;
  303. background: #FAFAFA;
  304. color: #000;
  305. box-sizing: border-box;
  306. .num_play {
  307. position: absolute;
  308. left: 10rpx;
  309. bottom: 10rpx;
  310. display: flex;
  311. align-items: flex-end;
  312. view {
  313. width: 6rpx;
  314. background: #62C5C6;
  315. margin-right: 6rpx;
  316. border-radius: 6rpx;
  317. }
  318. view:nth-child(1) {
  319. height: 21rpx;
  320. }
  321. view:nth-child(2) {
  322. height: 16rpx;
  323. }
  324. view:nth-child(3) {
  325. height: 18rpx;
  326. }
  327. }
  328. .lock {
  329. position: absolute;
  330. top: 0;
  331. right: 0;
  332. width: 40rpx;
  333. height: 40rpx;
  334. background: #F9E2B7;
  335. border-radius: 0rpx 12rpx 0rpx 12rpx;
  336. // text-align: center;
  337. // line-height: 40rpx;
  338. display: flex;
  339. justify-content: center;
  340. align-items: center;
  341. }
  342. }
  343. }
  344. }
  345. }
  346. }
  347. .pay_video{
  348. background: linear-gradient( 180deg, #216CFF 10%, #C7F0FF 50%);
  349. padding: 30rpx 20rpx;
  350. // margin-bottom: calc(20rpx + constant(safe-area-inset-bottom)) !important;
  351. margin-bottom: calc(env(safe-area-inset-bottom)) !important;
  352. // height: 300rpx;
  353. .tit{
  354. color: #fff;
  355. .tips{
  356. margin-left: 5rpx;
  357. }
  358. }
  359. .pays{
  360. margin: 30rpx 0;
  361. .pay_item{
  362. background: #fff;
  363. width: 40%;
  364. height: 100rpx;
  365. border-radius: 12rpx;
  366. text-align: center;
  367. line-height: 100rpx;
  368. }
  369. .pay_item_select{
  370. background: #216CFF;
  371. color: #fff;
  372. }
  373. }
  374. .btn{
  375. // margin-bottom: 30rpx;
  376. }
  377. }
  378. }
  379. </style>