detail.nvue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. <template>
  2. <view class="content">
  3. <u-navbar :title="topTitle" @leftClick="leftClick" titleStyle="color:#fff;" bgColor="#000" leftIconColor="#fff"
  4. :autoBack="false">
  5. </u-navbar>
  6. <swiper :style="'width: '+ windowWidth +'px; height:100vh; background-color: #000;'" class="swiper"
  7. :circular='false' @change="swiperChange" :current="swiperCurrent" :vertical="true" duration="300">
  8. <block v-for="content in videoInfo.updated_episode_num">
  9. <swiper-item :key="content" v-if="content">
  10. <view :style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'">
  11. <video autoplay :key="content" id="myVideo" :controls="controls" :loop="!isplay"
  12. :enable-progress-gesture="false" :show-center-play-btn="false" :show-loading="false"
  13. :show-fullscreen-btn="false" @ended="ended" @controlstoggle="controlstoggle"
  14. @click="tapVides()" :style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'"
  15. :src="currentVideoInfo.video_url" class="tsvideo">
  16. </video>
  17. <view v-if="isqp" class="userInfo">
  18. <!-- 2.点赞 -->
  19. <view style="opacity: 0.9; margin-top: 17px;">
  20. <image v-if="currentVideoInfo.is_zan" src="@/static/aixinRed.png" @click="myLike(2)"
  21. style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
  22. <image v-else src="@/static/aixin.png" @click="myLike(1)"
  23. style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
  24. <text
  25. style="color: #FFFFFF; margin-top: 5px; font-size: 14px; text-align: center; margin-top: 40px; font-weight: bold;">{{currentVideoInfo.total_zan}}</text>
  26. </view>
  27. <!-- 3.分享 -->
  28. <!-- <view style="opacity: 0.9; margin-top: 17px;">
  29. <image src="@/static/share-fill.png"
  30. style="width: 40px; height: 40px; position: absolute; right: 5px;"></image>
  31. <text
  32. style="color: #FFFFFF; margin-top: 5px; font-size: 14px; text-align: center; font-weight: bold; margin-top: 40px;">分享</text>
  33. <button open-type="share"
  34. style="position: absolute; background: none; width: 100%; height: 100%;"
  35. @click.stop="share"></button>
  36. </view> -->
  37. <!-- 4.追剧 -->
  38. <view class="comment" @click.stop="toComment(list.iszj,list.pid,list.mid)"
  39. style="opacity: 0.9; margin-top: 17px;">
  40. <block v-if="videoInfo.is_binge_watch">
  41. <image src="@/static/scRed.png"
  42. style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
  43. <text
  44. style="color: #ff0000; margin-top: 5px; font-size: 14px; font-weight: bold; text-align: center; margin-top: 40px;">已追</text>
  45. </block>
  46. <block v-else>
  47. <image src="@/static/sc.png"
  48. style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
  49. <text
  50. style="color: #FFFFFF; margin-top: 5px; font-size: 14px; font-weight: bold; text-align: center; margin-top: 40px;">追剧</text>
  51. </block>
  52. </view>
  53. </view>
  54. <!-- 最底下的文字部分 -->
  55. <view v-if="isqp" class="contentcd" @click.stop="sellxj()">
  56. <text class="userName">《{{videoInfo.name}}》</text>
  57. <text class="userName">更新到第{{videoInfo.updated_episode_num}}集</text>
  58. <text class="userName">|</text>
  59. <text class="userName">选集</text>
  60. </view>
  61. </view>
  62. </swiper-item>
  63. </block>
  64. </swiper>
  65. <uni-popup type="bottom" ref="select" style="z-index: 100;">
  66. <view v-if="fenji==1" class="pop-my">
  67. <view class="ju-top">
  68. <view style="display: flex; flex-direction: column; ">
  69. <view style="display: flex; flex-direction: column;">
  70. <view style="display: flex; flex-direction: column;">
  71. <u-tabs v-if="fenji==1" :activeStyle="activeStyle" lineColor="none"
  72. :inactiveStyle="inactiveStyle" style="align-items: center; width: 100%;"
  73. :list="list1" :current="current" @click="click"></u-tabs>
  74. <view class="ju-top-title">
  75. {{videoInfo.name}}
  76. </view>
  77. <view class="ju-top-update"> 已更新至{{videoInfo.updated_episode_num}}集 </view>
  78. </view>
  79. <u-tabs v-if="fenji==1" :activeStyle="activeStyle" lineColor="none"
  80. :inactiveStyle="inactiveStyle" style="align-items: flex-start; width: 100%;"
  81. :list="labelList" @click="click"></u-tabs>
  82. {{labelList}}
  83. </view>
  84. <view class="down" @click="down">
  85. <text class="down-text">收起</text>
  86. <image class="down-img" src="@/static/img/index/down.png">
  87. </image>
  88. </view>
  89. </view>
  90. </view>
  91. <scroll-view class="scroll-my" :scroll-y="true" :scroll-top="scrollTop">
  92. <view class="ju-wrapper">
  93. <block v-for="content in labelList[tabcurrent].content">
  94. <view class="ju-content" :class="activeIndex ==content?'active':'' "
  95. @click="playTest(content)">
  96. <view class="lock-wrapper" v-if="isShowUpdate(content)">
  97. <text class="update-title">待更新</text>
  98. </view>
  99. <text class="title">第{{content}}集 </text>
  100. <view class="lock-wrapper" v-if="isShowVip(content)">
  101. <image class="lock-img" src="@/static/shilu-login/2.png"></image>
  102. </view>
  103. </view>
  104. </block>
  105. </view>
  106. <view style="width: 1px; height: 1px; margin-top: 30px;"></view>
  107. </scroll-view>
  108. </view>
  109. <view v-if="fenji==2"
  110. :style="'width: '+ windowWidth +'px;height:500px; background-color: #fff; border-top-left-radius: 10px; border-top-right-radius: 10px;'">
  111. <u-tabs v-if="fenji==2" :list="list1" @click="click"></u-tabs>
  112. </view>
  113. </uni-popup>
  114. </view>
  115. </template>
  116. <script>
  117. import {
  118. getVideoInfo,
  119. videoEpisodePlay,
  120. videoEpisodeZan,
  121. } from '@/common/apis/video.js'
  122. import configs from "@/common/config.js"
  123. let audo = uni.createInnerAudioContext('myVideo')
  124. export default {
  125. data() {
  126. return {
  127. top_height: 0,
  128. episode: 1,
  129. swiperCurrent: 0,
  130. videoContext: '',
  131. currentVideoInfo: {},
  132. activeStyle: {
  133. color: '#f95d27',
  134. fontWeight: 'bold',
  135. transform: 'scale(1.05)'
  136. },
  137. inactiveStyle: {
  138. color: '#606266',
  139. transform: 'scale(1)'
  140. },
  141. activeIndex: 0,
  142. tabcurrent: 0,
  143. videoInfo: {
  144. "name": "test1-112",
  145. "charge_sequence": 24,
  146. "charge_coin": 125,
  147. "total_episode_num": 98,
  148. "updated_episode_num": 24,
  149. "update_type": 1
  150. },
  151. labelList: [],
  152. list1: [{
  153. name: '当前剧集',
  154. }, {
  155. name: '相似好剧',
  156. }],
  157. sharedata: {
  158. type: 2,
  159. strShareUrl: "",
  160. strShareTitle: "分享标题",
  161. strShareSummary: "分享总结",
  162. strShareImageUrl: ""
  163. },
  164. fenji: 0,
  165. controls: true,
  166. windowWidth: 0,
  167. windowHeight: 0,
  168. current: 0,
  169. isplay: true, //是否自动播放下一个视频
  170. duration: 500,
  171. isqp: true,
  172. urls: configs.webUrl,
  173. scrollTop: 0,
  174. video_id: 0,
  175. safeArea: 0,
  176. ttuop: 0,
  177. heightxw: 100,
  178. };
  179. },
  180. computed: {
  181. isShowVip(item) {
  182. return (item) => {
  183. return item >= this.videoInfo.charge_sequence && item < this.videoInfo.updated_episode_num
  184. }
  185. },
  186. isShowUpdate(item) {
  187. return (item) => {
  188. return item >= this.videoInfo.updated_episode_num
  189. }
  190. },
  191. topTitle() {
  192. return `${this.videoInfo.name} 第${this.episode}集`
  193. }
  194. },
  195. onReady: function(res) {
  196. this.videoContext = uni.createVideoContext('myVideo')
  197. },
  198. mounted() {
  199. this.initTabs();
  200. },
  201. onLoad(e) {
  202. let that = this;
  203. uni.getSystemInfo({
  204. success(res) {
  205. that.top_height = res.statusBarHeight; //data中 声明 top_height:0
  206. }
  207. });
  208. this.initSwiperData(this.swiperCurrent + 1)
  209. if (e.video_id) {
  210. this.video_id = e.video_id
  211. }
  212. getVideoInfo({
  213. video_id: 4
  214. }).then(res => {
  215. console.log(res, 'getVideoInfogetVideoInfogetVideoInfo')
  216. this.videoInfo = res
  217. })
  218. uni.getSystemInfo({
  219. success: res => {
  220. this.safeArea = res.safeAreaInsets.bottom;
  221. if (this.safeArea > 0) {
  222. this.heightxw = 97
  223. }
  224. }
  225. })
  226. // #ifdef MP-TOUTIAO
  227. this.ttuop = 64
  228. // #endif
  229. this.windowWidth = uni.getSystemInfoSync().windowWidth
  230. this.windowHeight = uni.getSystemInfoSync().windowHeight - this.safeArea - this.ttuop
  231. console.log(this.windowHeight)
  232. },
  233. onShow() {
  234. },
  235. onShareAppMessage: function(res) {
  236. // #ifdef MP-WEIXIN
  237. var href = '/pages/client/tuan/detail?video_id=' + this.video_id
  238. console.log(res)
  239. let that = this;
  240. const obj = {
  241. title: "发送给好友",
  242. imageUrl: '',
  243. path: href,
  244. success: function(res) {
  245. console.log(res, "转发成功")
  246. },
  247. fail: function(res) {
  248. wx.showToast({
  249. title: '发送失败',
  250. icon: 'none'
  251. })
  252. }
  253. }
  254. return obj
  255. // #endif
  256. },
  257. onBackPress() {},
  258. methods: {
  259. leftClick(e) {
  260. uni.showModal({
  261. title: '加入追剧',
  262. content: '喜欢就加入追剧吧',
  263. confirmText: '加入追剧',
  264. confirmColor: '#FFA500',
  265. cancelText: '不用了',
  266. success: (res) => {
  267. if (res.confirm) {
  268. // 用户点击了确定按钮
  269. // 执行加入追剧的逻辑
  270. } else if (res.cancel) {
  271. // 用户点击了取消按钮
  272. // 执行取消逻辑
  273. uni.navigateBack()
  274. }
  275. }
  276. });
  277. return true
  278. },
  279. myLike(like) {
  280. videoEpisodeZan({
  281. episode_id: this.currentVideoInfo.id,
  282. zan: like
  283. }).then(res => {
  284. console.log(res, 'VideoEpisodeZanVideoEpisodeZanVideoEpisodeZan')
  285. this.$nextTick(() => {
  286. this.currentVideoInfo.is_zan = !Boolean(this.currentVideoInfo.is_zan)
  287. if (this.currentVideoInfo.is_zan) {
  288. this.currentVideoInfo.total_zan++
  289. } else {
  290. this.currentVideoInfo.total_zan--
  291. }
  292. })
  293. })
  294. },
  295. initTabs() {
  296. function innit(i, num) {
  297. let arr = [];
  298. for (i; i <= num; i++) {
  299. arr.push(i)
  300. }
  301. return arr
  302. }
  303. const pageSize = 15;
  304. const total = this.videoInfo.total_episode_num;
  305. const pageCount = Math.ceil(total / pageSize);
  306. for (let i = 0; i < pageCount; i++) {
  307. const start = i * pageSize + 1;
  308. const end = i === pageCount - 1 ? total : (i + 1) * pageSize;
  309. let label;
  310. if (i === pageCount - 1) {
  311. if (start === total) {
  312. label = `${total}`
  313. } else {
  314. label = `${start}-${total}`
  315. }
  316. } else {
  317. label = `${start}-${end}`
  318. }
  319. let index;
  320. if (label.split('-')[1]) {
  321. index = label.split('-')[1]
  322. } else {
  323. index = total
  324. }
  325. this.labelList.push({
  326. name: label,
  327. page: pageCount,
  328. content: innit(start, index)
  329. })
  330. }
  331. },
  332. playTest(item) {
  333. console.log(item)
  334. if (this.isShowVip(item)) {
  335. this.fenji = 2
  336. this.activeIndex = ''
  337. } else if (this.isShowUpdate(item)) {
  338. this.activeIndex = ''
  339. uni.showToast({
  340. title: '剧集暂未更新',
  341. duration: 1000,
  342. icon: 'none'
  343. });
  344. } else {
  345. this.activeIndex = item;
  346. this.swiperCurrent = item - 1;
  347. this.episode = this.swiperCurrent
  348. // this.initSwiperData(item)
  349. this.down();
  350. }
  351. },
  352. click(item) {
  353. this.tabcurrent = item.index
  354. console.log('item', item);
  355. },
  356. share() {
  357. var href = '/pages/client/tuan/detail?video_id=' + this.video_id
  358. // #ifdef H5
  359. uni.setClipboardData({
  360. data: this.urls + '/h5/#' + href,
  361. complete() {
  362. uni.showToast({
  363. title: "分享连接已复制到剪贴板"
  364. })
  365. }
  366. })
  367. // #endif
  368. // #ifndef H5
  369. uni.share({
  370. provider: "weixin",
  371. scene: "WXSenceTimeline",
  372. type: 0,
  373. href: href,
  374. title: '分享标题',
  375. summary: '分享总结',
  376. imageUrl: '',
  377. success: function(res) {
  378. console.log("success:" + JSON.stringify(res));
  379. },
  380. fail: function(err) {
  381. console.log("fail:" + JSON.stringify(err));
  382. }
  383. })
  384. // #endif
  385. },
  386. down() {
  387. this.$refs.select.close();
  388. },
  389. sellxj() {
  390. this.fenji = 1
  391. this.$refs.select.open('bottom');
  392. this.$nextTick(() => {
  393. let num1 = (this.windowHeight / 1.6) * 0.85;
  394. let num2 = num1 / 4.78;
  395. this.scrollTop = num2 * Number(this.k);
  396. })
  397. },
  398. tapVideoHover(index, pays) {
  399. this.videoContext.play()
  400. // this.$refs.select.open('bottom');
  401. },
  402. tapVides() {
  403. this.isqp = !this.isqp
  404. },
  405. ended() {
  406. //console.log('isplay----',this.isplay)
  407. // 1.播放当前视频结束时触发,自动切换下一个视频
  408. if (this.isplay) {
  409. if (this.displayIndex < 2) {
  410. this.current = this.displayIndex + 1
  411. } else {
  412. this.current = 0
  413. }
  414. this.isqp = true
  415. console.log('显示swiper Index:', this.displayIndex)
  416. }
  417. },
  418. /**
  419. * 初始一个显示的swiper数据
  420. * @originIndex 从源数据的哪个开始显示默认0,如从其他页面跳转进来,要显示第n个,这个参数就是他的下标
  421. */
  422. initSwiperData(originIndex) {
  423. this.isqp = false
  424. videoEpisodePlay({
  425. video_id: 4,
  426. sequence: originIndex
  427. }).then(res => {
  428. this.currentVideoInfo = res
  429. console.log(res, 'getVideoEpisodePlaygetVideoEpisodePlay')
  430. })
  431. },
  432. /**
  433. * swiper滑动时候
  434. */
  435. swiperChange(event) {
  436. const {
  437. current
  438. } = event.detail;
  439. this.episode = current + 1;
  440. this.activeIndex = this.episode;
  441. this.initSwiperData(current + 1)
  442. },
  443. controlstoggle(e) {
  444. console.log(e.detail.show);
  445. },
  446. },
  447. };
  448. </script>
  449. <style lang="scss" scoped>
  450. page {
  451. background: #000000;
  452. }
  453. .userInfo {
  454. position: absolute;
  455. z-index: 99;
  456. bottom: 30%;
  457. right: 10px;
  458. width: 100rpx;
  459. text-align: center;
  460. flex-direction: column;
  461. }
  462. .contentcd {
  463. background-color: rgba(255, 255, 255, .3);
  464. width: 720rpx;
  465. z-index: 99;
  466. position: absolute;
  467. bottom: 70rpx;
  468. left: 50%;
  469. transform: translateX(-50%);
  470. padding: 15rpx;
  471. border-radius: 8px;
  472. display: flex;
  473. flex-direction: row;
  474. justify-content: flex-start;
  475. align-items: center;
  476. color: #ffffff;
  477. margin: 0 auto;
  478. }
  479. .userName {
  480. color: #fff;
  481. font-size: 30rpx;
  482. color: #ffffff;
  483. margin: 0 6rpx;
  484. }
  485. .tsvideo {
  486. animation: showDivAni 2s 1;
  487. }
  488. @keyframes showDivAni {
  489. 0% {
  490. opacity: 0;
  491. }
  492. 100% {
  493. opacity: 1;
  494. }
  495. }
  496. </style>
  497. <style lang="scss" scoped>
  498. .down {
  499. display: flex;
  500. flex-direction: row;
  501. width: 60px;
  502. height: 30px;
  503. margin-top: 5px;
  504. position: absolute;
  505. right: 0px;
  506. top: 50%;
  507. transform: translateY(-50%);
  508. .down-text {
  509. font-size: 12px;
  510. color: #000;
  511. }
  512. .down-img {
  513. width: 35rpx;
  514. height: 35rpx;
  515. object-fit: contain;
  516. }
  517. }
  518. .ju-top {
  519. // background-color: ;
  520. .ju-top-title {
  521. font-size: 16px;
  522. font-weight: bold;
  523. color: #000;
  524. margin-top: 9px;
  525. height: 22px;
  526. margin-left: 20px;
  527. // width: '+ (windowWidth*0.6) +' px;
  528. overflow: hidden;
  529. }
  530. .ju-top-update {
  531. font-size: 12px;
  532. color: #000;
  533. margin-top: 9px;
  534. height: 22px;
  535. margin-left: 20px;
  536. }
  537. }
  538. .pop-my {
  539. background-color: #FFFFFF;
  540. }
  541. .scroll-my {
  542. height: 50vh;
  543. }
  544. .ju-wrapper {
  545. display: flex;
  546. flex-direction: row;
  547. flex-wrap: wrap;
  548. align-items: center;
  549. justify-content: start;
  550. width: 100%;
  551. height: 100%;
  552. background-color: #FFFFFF;
  553. // margin: 6rpx;
  554. .ju-content.active {
  555. background-color: #ff7f02;
  556. }
  557. .ju-content {
  558. flex-grow: 1;
  559. position: relative;
  560. border-radius: 12rpx;
  561. background-color: #f6f6f6;
  562. width: 31%;
  563. height: 25rpx;
  564. align-items: center;
  565. justify-content: center;
  566. padding: 45rpx 68rpx;
  567. margin: 6rpx;
  568. .lock-wrapper {
  569. position: absolute;
  570. width: 100%;
  571. height: 100%;
  572. border-radius: 12rpx;
  573. background-color: rgba(0, 0, 0, .3);
  574. .lock-img {
  575. position: absolute;
  576. left: 3rpx;
  577. top: 50%;
  578. transform: translateY(-50%);
  579. width: 50rpx;
  580. height: 50rpx;
  581. margin-left: 20rpx;
  582. }
  583. .update-title {
  584. width: fit-content;
  585. height: fit-content;
  586. border-radius: 8rpx;
  587. font-size: 10px;
  588. padding: 6rpx;
  589. background-color: #868686;
  590. color: #fff;
  591. }
  592. }
  593. .title {
  594. font-size: 16px;
  595. }
  596. }
  597. }
  598. </style>