detail.nvue 17 KB

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