index.nvue 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <template>
  2. <view class="">
  3. <!-- 加载中提示 -->
  4. <u-loading-page bg-color="#000000" :loading="isLoading" loading-text="加载中..." loading-mode="semicircle"
  5. loading-color="#ffffff" font-size="18" icon-size="46" color="#ffffff"></u-loading-page>
  6. <view class="content" v-if="!isLoading">
  7. <u-navbar :leftText="topTitle" @leftClick="leftClick" titleStyle="color:#fff;" bgColor="#000"
  8. leftIconColor="#fff" :autoBack="false">
  9. </u-navbar>
  10. <swiper :style="'width: '+ windowWidth +'px; height:100vh; background-color: #000;'" class="swiper"
  11. :circular='false' @change="swiperChange" :current="swiperCurrent" :vertical="true" duration="200">
  12. <block v-for="content in swiperList" :key="content">
  13. <swiper-item :key="content">
  14. <view :style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'"
  15. v-if="isShowVideo(content) && shouldRender(content)">
  16. <!-- @controlstoggle="controlstoggle" -->
  17. <video v-if="isShowVideo(content)" autoplay :key="content" id="myVideo" :controls="controls"
  18. :loop="!isplay" preload="auto" :enable-progress-gesture="true"
  19. :show-center-play-btn="false" :show-loading="false" :show-fullscreen-btn="false"
  20. :poster="videoInfo.cover_image" @ended="ended" @click="tapVides()"
  21. :style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'"
  22. :src="currentVideoInfo.video_url" class="tsvideo">
  23. </video>
  24. <view v-if="isqp" class="userInfo">
  25. <!-- 2.点赞 -->
  26. <view style="opacity: 0.9; margin-top: 17px;">
  27. <image v-if="currentVideoInfo.is_zan" src="@/static/img/video/aixinRed.png"
  28. @click="myLike(2)"
  29. style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
  30. <image v-else src="@/static/img/video/aixin.png" @click="myLike(1)"
  31. style="width: 40px; height: 40px; position: absolute; right: 6px;"></image>
  32. <text
  33. style="color: #FFFFFF; margin-top: 5px; font-size: 14px; text-align: center; margin-top: 40px; font-weight: bold;">{{currentVideoInfo.total_zan}}</text>
  34. </view>
  35. <!-- 3.分享 -->
  36. <!-- <view style="opacity: 0.9; margin-top: 17px;">
  37. <image src="@/static/img/video/share-fill.png"
  38. style="width: 40px; height: 40px; position: absolute; right: 5px;"></image>
  39. <text
  40. style="color: #FFFFFF; margin-top: 5px; font-size: 14px; text-align: center; font-weight: bold; margin-top: 40px;">分享</text>
  41. <button open-type="share"
  42. style="position: absolute; background: none; width: 100%; height: 100%;"
  43. @click.stop="share"></button>
  44. </view> -->
  45. <!-- 4.追剧 -->
  46. <view class="comment" style="opacity: 0.9; margin-top: 17px;">
  47. <view v-if="videoInfo.is_binge_watch" @click="unBingewatch">
  48. <image src="@/static/img/video/scRed.png"
  49. style="width: 40px; height: 40px; position: absolute; right: 6px;">
  50. </image>
  51. <text
  52. style="color: #ff0000; margin-top: 5px; font-size: 14px; font-weight: bold; text-align: center; margin-top: 40px;">已追</text>
  53. </view>
  54. <view v-else @click="bingewatch">
  55. <image src="@/static/img/video/sc.png"
  56. style="width: 40px; height: 40px; position: absolute; right: 6px;">
  57. </image>
  58. <text
  59. style="color: #FFFFFF; margin-top: 5px; font-size: 14px; font-weight: bold; text-align: center; margin-top: 40px;">追剧</text>
  60. </view>
  61. </view>
  62. </view>
  63. <!-- 最底下的文字部分 -->
  64. <view v-if="isqp" class="contentcd" @click.stop="sellxj()">
  65. <text class="userName">《{{videoInfo.name}}》</text>
  66. <text class="userName">更新到第{{videoInfo.updated_episode_num}}集</text>
  67. <text class="userName">|</text>
  68. <text class="userName">选集</text>
  69. </view>
  70. </view>
  71. <image v-if="shouldRender(content) && !isShowVideo(content)"
  72. :style="'width: '+ windowWidth +'px; height:'+heightxw+'vh;'" :src="videoInfo.cover_image">
  73. </image>
  74. </swiper-item>
  75. </block>
  76. </swiper>
  77. <uni-popup type="bottom" ref="select" style="z-index: 100;" :mask-click="true">
  78. <view v-if="fenji==1" class="pop-my"
  79. style=" border-top-left-radius: 10px; border-top-right-radius: 10px;">
  80. <view class="ju-top">
  81. <view style="display: flex; flex-direction: column; ">
  82. <view style="display: flex; flex-direction: column;">
  83. <view style="display: flex; flex-direction: column;">
  84. <view class="utabs-top">
  85. <u-tabs v-if="fenji==1" :activeStyle="activeStyle" lineColor="none"
  86. :inactiveStyle="inactiveStyle" class="utabs-top" :list="list1"
  87. :current="current"></u-tabs>
  88. </view>
  89. <view class="ju-top-title">
  90. {{videoInfo.name}}
  91. </view>
  92. <view class="ju-top-update"> 已更新至{{videoInfo.updated_episode_num}}集 </view>
  93. </view>
  94. <u-tabs v-if="fenji==1" :activeStyle="activeStyle" lineColor="none"
  95. :inactiveStyle="inactiveStyle" :current="tabcurrent" :list="labelList"
  96. @click="labelListClick"></u-tabs>
  97. </view>
  98. <view class="down" @click="down">
  99. <text class="down-text">收起</text>
  100. <image class="down-img" src="@/static/img/video/down.png">
  101. </image>
  102. </view>
  103. </view>
  104. </view>
  105. <scroll-view class="scroll-my" :scroll-y="true" :scroll-top="scrollTop">
  106. <view class="ju-wrapper">
  107. <block v-for="content in labelList[tabcurrent].content" :key="content">
  108. <view class="ju-content" :class="activeIndex ==content?'active':'' "
  109. @click="playVideo(content)">
  110. <!-- <view :class="isShowUpdate(content)?'lock-wrapper-no':'lock-wrapper'" -->
  111. <view class="lock-wrapper" v-if="isShowUpdate(content)">
  112. <text class="update-title">待更新</text>
  113. </view>
  114. <text class="title">第{{content}}集 </text>
  115. <view class="lock-wrapper" v-if="isShowVip(content)">
  116. <image class="lock-img" src="@/static/img/video/vip.png"></image>
  117. </view>
  118. </view>
  119. </block>
  120. </view>
  121. <view style="width: 1px; height: 1px; margin-top: 30px;"></view>
  122. </scroll-view>
  123. </view>
  124. <view v-if="fenji==2"
  125. :style="'width: '+ windowWidth +'px;height:70vh; background-color: #fff; border-top-left-radius: 10px; border-top-right-radius: 10px;'">
  126. <view class="charge-wrapper">
  127. <view class="top">
  128. <text class="charge-title">充值购买后可继续观看{{popUpTitle}} </text>
  129. <text class="charge-info">为保护创作者权益,当前内容需要付费观看。</text>
  130. <view class="charge-coin">
  131. <text class="ji">本集:</text>
  132. <text class="bi">{{videoInfo.charge_coin}}k币</text>
  133. </view>
  134. </view>
  135. <view class="ft14"
  136. style="display: flex;flex-direction: row;justify-content: flex-start;padding: 0 20px;">
  137. 账户余额<text class="ft14" style="color: #FF9800;">{{user_info.total_coin}}</text>K币</view>
  138. <scroll-view class="scroll-charge" :scroll-y="true" :scroll-top="scrollTop">
  139. <view class="pay-box">
  140. <block v-for="(item,key) in payOptions" :key="key">
  141. <view v-if="item.type =='COIN'" @click="selectPayItem(item)"
  142. :class="item.id == pay_select_id ?'pay-select' :'' " class="box pay-box-items">
  143. <view style="height: 20px;align-self: flex-end;"><text class="ft12 top-lab"
  144. v-if="item.tip_text">{{item.tip_text}}</text></view>
  145. <text class="ft18 pay-box-items-txt"
  146. style="color: #FF9800;">{{item.price}}元</text>
  147. <view class="ft14 pay-box-items-txt" style="flex-direction: row;">
  148. {{item.price_text}} <text class="ft14"
  149. style="color: #FF9800;">+{{item.given}}K币</text>
  150. </view>
  151. <view class="ft14 pay-box-items-txt"
  152. style="flex-direction: row;justify-content: space-between;"
  153. :class=" item.id == pay_select_id ?'select-text' :'given-txt'">
  154. {{item.given_amount}} <text v-if="item.id == pay_select_id"
  155. class="ft14">&#10003;️</text>
  156. </view>
  157. </view>
  158. <view v-else @click="selectPayItem(item)"
  159. :class="item.id == pay_select_id ?'pay-select' :'' " class="box pay-box-items">
  160. <view style="height: 20px;align-self: flex-end;"><text class="ft12 top-lab"
  161. v-if="item.tip_text">{{item.tip_text}}</text></view>
  162. <view class="vip-center">
  163. <view class="">
  164. <text class="ft18 pay-box-items-txt"
  165. style="color: #FF9800;">{{item.price}}元</text>
  166. <view class="ft14 pay-box-items-txt">{{item.price_text}}</text></view>
  167. </view>
  168. <image class="vip-level-icon" src="/static/icon/vip.png"></image>
  169. </view>
  170. <view class="ft14 pay-box-items-txt"
  171. style="flex-direction: row;justify-content: space-between;"
  172. :class=" item.id == pay_select_id ?'select-text' :'given-txt'">
  173. {{item.given_amount}} <text v-if="item.id == pay_select_id"
  174. class="ft14">&#10003;️</text>
  175. </view>
  176. </view>
  177. </block>
  178. </view>
  179. <view class="ft14" style="margin: 10px 0; padding: 0 20px;">付费须知</view>
  180. <view class="ft14" style="padding: 0 20px;">
  181. <text class="ft12">1、虚拟商品,一经购买不得退换</text>
  182. <text class="ft12">2、充值后K币可能有延迟,1小时未到账请在“我的”页面联系客服</text>
  183. <text class="ft12">3、未满18岁的未成年需要在监护人陪同下购买并观看短剧剧</text>
  184. <text class="ft12">4、购买成功后,“K币”仅在本小程序中使用</text>
  185. <text class="ft12">5、购买成功后可在”我的”页面订单中心进行查看</text>
  186. </view>
  187. </scroll-view>
  188. </view>
  189. </view>
  190. </uni-popup>
  191. </view>
  192. <u-overlay :show="centerShow" :duration="400" closeOnClickOverlay :z-index="999" @click="closeOverlay">
  193. <view class="warp">
  194. <view class="rect" @tap.stop>
  195. <text class="rect-text">剧集暂未更新</text>
  196. <view class="rect-button" @tap.stop @click="closeOverlay"><text class="rect-button-text">确定</text>
  197. </view>
  198. </view>
  199. </view>
  200. </u-overlay>
  201. </view>
  202. </template>
  203. <script>
  204. import {
  205. getVideoInfo,
  206. videoEpisodePlay,
  207. videoEpisodeZan,
  208. } from '@/common/apis/video.js';
  209. import {
  210. delShelf,
  211. storeshelf
  212. } from '@/common/apis/zju.js'
  213. import {
  214. getUserInfo
  215. } from "@/common/apis/my.js";
  216. import {
  217. userRanse
  218. } from "@/common/apis/common.js"
  219. import {
  220. getOptions,
  221. getPayInfo
  222. } from "@/common/apis/recharge.js"
  223. import configs from "@/common/config.js"
  224. export default {
  225. data() {
  226. return {
  227. isLoading: true, // 页面加载中的状态
  228. centerShow: false, //暂未更新弹窗
  229. limitPage: 15,
  230. top_height: 0,
  231. episode: 1,
  232. ranse_id: 0,
  233. swiperCurrent: 0,
  234. videoContext: '',
  235. currentVideoInfo: {},
  236. activeStyle: {
  237. color: '#f95d27',
  238. fontWeight: 'bold',
  239. transform: 'scale(1.05)'
  240. },
  241. inactiveStyle: {
  242. color: '#606266',
  243. transform: 'scale(1)'
  244. },
  245. activeIndex: 1,
  246. tabcurrent: 0,
  247. videoInfo: {},
  248. labelList: [],
  249. list1: [{
  250. name: '当前剧集',
  251. }],
  252. sharedata: {
  253. type: 2,
  254. strShareUrl: "",
  255. strShareTitle: "分享标题",
  256. strShareSummary: "分享总结",
  257. strShareImageUrl: ""
  258. },
  259. isShow: true,
  260. fenji: 2,
  261. pay_select_id: 0,
  262. controls: true,
  263. windowWidth: 0,
  264. windowHeight: 0,
  265. current: 0,
  266. isplay: true, //是否自动播放下一个视频
  267. duration: 500,
  268. isqp: true,
  269. urls: configs.webUrl,
  270. scrollTop: 0,
  271. video_id: 0,
  272. safeArea: 0,
  273. ttuop: 0,
  274. heightxw: 100,
  275. user_info: {},
  276. payVideoInfo: {},
  277. payOptions: []
  278. };
  279. },
  280. computed: {
  281. shouldRender(index) {
  282. return (index) => {
  283. // 判断是否应该渲染当前索引的前后各一个索引的swiper item
  284. return Math.abs(index - this.swiperCurrent) <= 1;
  285. }
  286. },
  287. swiperList() {
  288. // return Number(2800) + 1
  289. return Number(this.videoInfo.updated_episode_num) + 1
  290. },
  291. isShowVideo(item) {
  292. return (item) => {
  293. return this.swiperCurrent == item && this.isShow
  294. }
  295. },
  296. isShowVip(item) {
  297. return (item) => {
  298. return item >= this.videoInfo.charge_sequence && item <= this.videoInfo.updated_episode_num
  299. }
  300. },
  301. isShowUpdate(item) {
  302. return (item) => {
  303. return item > this.videoInfo.updated_episode_num
  304. }
  305. },
  306. popUpTitle() {
  307. return `《${this.videoInfo.name}》 第${this.episode}集`
  308. },
  309. topTitle() {
  310. return `第${this.episode}集`
  311. }
  312. },
  313. onReady: function(res) {
  314. // 将 isLoading 状态设置为 false,表示页面加载完成
  315. this.isLoading = false;
  316. this.videoContext = uni.createVideoContext('myVideo')
  317. },
  318. mounted() {
  319. getVideoInfo({
  320. video_id: this.video_id
  321. }).then(res => {
  322. // console.log(res, 'getVideoInfogetVideoInfogetVideoInfo')
  323. this.videoInfo = res.data
  324. this.initTabs();
  325. this.initSwiperData(this.swiperCurrent + 1)
  326. })
  327. },
  328. async onLoad(e) {
  329. // console.log('11111111111111111111',e)
  330. let that = this;
  331. uni.getSystemInfo({
  332. success(res) {
  333. that.top_height = res.statusBarHeight; //data中 声明 top_height:0
  334. }
  335. });
  336. if (e.video_id) {
  337. this.video_id = Number(e.video_id)
  338. }
  339. if (e.sequence && Number(e.sequence) > 0) {
  340. this.swiperCurrent = Number(e.sequence) - 1;
  341. }
  342. // 染色参数接收
  343. if (e.ranse_id && Number(e.ranse_id) > 0) {
  344. try {
  345. this.ranse_id = Number(e.ranse_id);
  346. let res = await userRanse(this.ranse_id);
  347. } catch (e) {
  348. console.log("player-errr:", e)
  349. }
  350. }
  351. uni.getSystemInfo({
  352. success: res => {
  353. this.safeArea = res.safeAreaInsets.bottom;
  354. if (this.safeArea > 0) {
  355. this.heightxw = 97
  356. }
  357. }
  358. })
  359. // #ifdef MP-TOUTIAO
  360. this.ttuop = 64
  361. // #endif
  362. this.windowWidth = uni.getSystemInfoSync().windowWidth
  363. this.windowHeight = uni.getSystemInfoSync().windowHeight - this.safeArea - this.ttuop
  364. console.log(this.windowHeight)
  365. },
  366. onShow() {
  367. },
  368. onShareAppMessage: function(res) {
  369. // #ifdef MP-WEIXIN
  370. var href = '/pages/video/index?video_id=' + this.video_id + "&"
  371. console.log(res)
  372. let that = this;
  373. const obj = {
  374. title: "发送给好友",
  375. imageUrl: '',
  376. path: href,
  377. success: function(res) {
  378. console.log(res, "转发成功")
  379. },
  380. fail: function(res) {
  381. wx.showToast({
  382. title: '发送失败',
  383. icon: 'none'
  384. })
  385. }
  386. }
  387. return obj
  388. // #endif
  389. },
  390. watch: {
  391. activeIndex: {
  392. handler(newVal, oldVal) {
  393. this.initTabs()
  394. let index = this.labelList.findIndex(el => el.content.includes(newVal))
  395. console.log(index, 'newValnewVal', this.labelList, newVal)
  396. this.tabcurrent = index
  397. },
  398. }
  399. },
  400. onBackPress() {},
  401. methods: {
  402. closeOverlay() {
  403. this.centerShow = false
  404. // console.log('open');
  405. },
  406. bingewatch() {
  407. storeshelf(this.video_id).then(res => {
  408. this.videoInfo.is_binge_watch = !Boolean(this.videoInfo.is_binge_watch)
  409. uni.showToast({
  410. title: '追剧成功',
  411. duration: 1000,
  412. icon: 'none'
  413. });
  414. })
  415. },
  416. unBingewatch() {
  417. delShelf(this.video_id).then(res => {
  418. this.videoInfo.is_binge_watch = !Boolean(this.videoInfo.is_binge_watch)
  419. })
  420. },
  421. leftClick(e) {
  422. if (!this.videoInfo?.is_binge_watch) {
  423. uni.showModal({
  424. title: '加入追剧',
  425. content: '喜欢就加入追剧吧',
  426. confirmText: '加入追剧',
  427. confirmColor: '#FFA500',
  428. cancelText: '不用了',
  429. success: (res) => {
  430. if (res.confirm) {
  431. this.bingewatch()
  432. uni.switchTab({
  433. url: '/pages/index/index'
  434. });
  435. // 用户点击了确定按钮
  436. // 执行加入追剧的逻辑
  437. } else if (res.cancel) {
  438. // 用户点击了取消按钮
  439. // 执行取消逻辑
  440. uni.switchTab({
  441. url: '/pages/index/index'
  442. });
  443. }
  444. }
  445. });
  446. } else {
  447. uni.switchTab({
  448. url: '/pages/index/index'
  449. });
  450. // uni.navigateBack()
  451. }
  452. },
  453. myLike(like) {
  454. videoEpisodeZan({
  455. episode_id: this.currentVideoInfo.id,
  456. zan: like
  457. }).then(res => {
  458. this.$nextTick(() => {
  459. this.currentVideoInfo.is_zan = !Boolean(this.currentVideoInfo.is_zan)
  460. if (this.currentVideoInfo.is_zan) {
  461. this.currentVideoInfo.total_zan++
  462. } else {
  463. this.currentVideoInfo.total_zan--
  464. }
  465. })
  466. })
  467. },
  468. initTabs() {
  469. function innit(i, num) {
  470. let arr = [];
  471. for (i; i <= num; i++) {
  472. arr.push(i)
  473. }
  474. return arr
  475. }
  476. const pageSize = this.limitPage;
  477. const total = this.videoInfo.total_episode_num;
  478. const pageCount = Math.ceil(total / pageSize);
  479. for (let i = 0; i < pageCount; i++) {
  480. const start = i * pageSize + 1;
  481. const end = i === pageCount - 1 ? total : (i + 1) * pageSize;
  482. let label;
  483. if (i === pageCount - 1) {
  484. if (start === total) {
  485. label = `${total}`
  486. } else {
  487. label = `${start}-${total}`
  488. }
  489. } else {
  490. label = `${start}-${end}`
  491. }
  492. let index;
  493. if (label.split('-')[1]) {
  494. index = label.split('-')[1]
  495. } else {
  496. index = total
  497. }
  498. this.labelList.push({
  499. name: label,
  500. page: pageCount,
  501. content: innit(start, index)
  502. })
  503. }
  504. // let index = this.labelList.findIndex(el => el.content.includes(this.activeIndex))
  505. // this.tabcurrent = index
  506. },
  507. async getPayInfo(originIndex) {
  508. let userInfores = await getUserInfo();
  509. this.user_info = userInfores.data
  510. let res = await getOptions();
  511. this.payOptions = res.data;
  512. this.payOptions.forEach((item, index) => {
  513. if (item.is_default == 1) {
  514. this.pay_select_id = item.id;
  515. }
  516. })
  517. this.payVideoInfo = {
  518. video_id: this.video_id,
  519. video_series_sequence: originIndex
  520. };
  521. },
  522. async selectPayItem(item) {
  523. this.pay_select_id = item.id;
  524. let params = {
  525. video_id: this.payVideoInfo.video_id,
  526. video_series_sequence: this.payVideoInfo.video_series_sequence,
  527. pay_proudct_id: item.id,
  528. is_first_pay: item.is_first_pay,
  529. }
  530. let res = await getPayInfo(params);
  531. if (res.data) {
  532. // #ifdef MP-WEIXIN
  533. this.wxMinPay(res.data);
  534. // #endif
  535. }
  536. },
  537. wxMinPay(param) {
  538. wx.requestPayment({
  539. timeStamp: param.timeStamp,
  540. nonceStr: param.nonceStr,
  541. package: param.package,
  542. signType: param.signType,
  543. paySign: param.paySign,
  544. success(res) {
  545. this.pay_success = true;
  546. uni.showToast({
  547. title: '支付成功',
  548. icon: "none"
  549. });
  550. // console.log('success:' + JSON.stringify(res));
  551. },
  552. fail(e) {
  553. if (e.errMsg == "requestPayment:fail cancel") {
  554. uni.showToast({
  555. title: '取消支付',
  556. icon: "none"
  557. });
  558. } else {
  559. uni.showToast({
  560. title: '支付失败',
  561. icon: "none"
  562. });
  563. }
  564. }
  565. })
  566. },
  567. playVideo(item) {
  568. if (this.isShowVip(item)) {
  569. // this.fenji = 2
  570. this.swiperCurrent = item - 1;
  571. this.getPayInfo(item);
  572. // this.activeIndex = ''
  573. } else if (this.isShowUpdate(item)) {
  574. // this.activeIndex = ''
  575. this.centerShow = true
  576. // this.swiperCurrent = this.videoInfo.updated_episode_num + 1;
  577. // uni.showToast({
  578. // title: '剧集暂未更新',
  579. // duration: 500,
  580. // icon: 'none'
  581. // });
  582. } else {
  583. this.activeIndex = item;
  584. this.swiperCurrent = item - 1;
  585. this.episode = this.swiperCurrent
  586. // this.initSwiperData(item)
  587. this.down();
  588. }
  589. },
  590. labelListClick(item) {
  591. this.tabcurrent = item.index
  592. },
  593. share() {
  594. var href = '/pages/video/index?video_id=' + this.video_id
  595. // #ifdef H5
  596. uni.setClipboardData({
  597. data: this.urls + '/h5/#' + href,
  598. complete() {
  599. uni.showToast({
  600. title: "分享连接已复制到剪贴板"
  601. })
  602. }
  603. })
  604. // #endif
  605. // #ifndef H5
  606. uni.share({
  607. provider: "weixin",
  608. scene: "WXSenceTimeline",
  609. type: 0,
  610. href: href,
  611. title: '分享标题',
  612. summary: '分享总结',
  613. imageUrl: '',
  614. success: function(res) {
  615. console.log("success:" + JSON.stringify(res));
  616. },
  617. fail: function(err) {
  618. console.log("fail:" + JSON.stringify(err));
  619. }
  620. })
  621. // #endif
  622. },
  623. down() {
  624. this.$refs.select.close();
  625. },
  626. sellxj() {
  627. this.fenji = 1
  628. this.$refs.select.open('bottom');
  629. this.$nextTick(() => {
  630. let num1 = (this.windowHeight / 1.6) * 0.85;
  631. let num2 = num1 / 4.78;
  632. this.scrollTop = num2 * Number(this.k);
  633. })
  634. },
  635. tapVideoHover(index, pays) {
  636. this.videoContext.play()
  637. // this.$refs.select.open('bottom');
  638. },
  639. tapVides() {
  640. this.isqp = !this.isqp
  641. },
  642. ended() {
  643. //console.log('isplay----',this.isplay)
  644. // 1.播放当前视频结束时触发,自动切换下一个视频
  645. if (this.isplay) {
  646. if (this.displayIndex < 2) {
  647. this.current = this.displayIndex + 1
  648. } else {
  649. this.current = 0
  650. }
  651. this.isqp = true
  652. // console.log('显示swiper Index:', this.displayIndex)
  653. }
  654. },
  655. initSwiperData(originIndex) {
  656. this.episode = originIndex;
  657. this.isqp = true
  658. console.log(this.videoInfo.updated_episode_num, 'this.swiperCurrent', this.swiperCurrent)
  659. if (this.swiperList != this.swiperCurrent + 1) {
  660. videoEpisodePlay({
  661. video_id: this.video_id,
  662. sequence: originIndex,
  663. }).then(res => {
  664. if (res.code == 0) {
  665. this.currentVideoInfo = res.data
  666. this.activeIndex = this.episode;
  667. this.isShow = true
  668. this.down();
  669. } else if (res.code == 500101) {
  670. // console.log(this.currentVideoInfo, 'res.code == 500101res.code == 500101')
  671. this.currentVideoInfo.video_url = ""
  672. this.isShow = false
  673. this.isqp = false
  674. this.fenji = 2
  675. this.getPayInfo(originIndex);
  676. this.$refs.select.open('bottom');
  677. // this.currentVideoInfo = {}
  678. } else {
  679. this.isqp = false
  680. this.currentVideoInfo.video_url = ""
  681. this.isShow = false
  682. }
  683. // console.log(res, 'getVideoEpisodePlaygetVideoEpisodePlay')
  684. })
  685. } else {
  686. this.isqp = false
  687. this.centerShow = true
  688. this.currentVideoInfo.video_url = ""
  689. this.isShow = false
  690. }
  691. },
  692. /**
  693. * swiper滑动时候
  694. */
  695. swiperChange(event) {
  696. const {
  697. current
  698. } = event.detail;
  699. this.swiperCurrent = current
  700. // console.log(this.swiperCurrent, 'this.swiperCurrentthis.swiperCurrent')
  701. this.initSwiperData(current + 1)
  702. },
  703. controlstoggle(e) {
  704. // console.log(e.detail.show);
  705. },
  706. },
  707. };
  708. </script>
  709. <style lang="scss" scoped>
  710. @import "./style/index.scss"
  711. </style>