video-details.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <template>
  2. <view>
  3. <view class="video">
  4. <video :src="data.url" :poster="data.cover_image" @timeupdate='TimeUpdate($event,data.id)' @ended="ended"
  5. controls style="width: 100%;"></video>
  6. </view>
  7. <view class="wrapper">
  8. <view class="title">
  9. {{data.title}}
  10. </view>
  11. <view class="desc" v-if='data.isGift'>
  12. 券已领取
  13. </view>
  14. <view class="desc" v-else>
  15. 奖励券:{{data.integral}}
  16. </view>
  17. <view class="details">
  18. <view class="">
  19. 视频详情:
  20. </view>
  21. <view class="content" v-html="data.content">
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </template>
  27. <script>
  28. import {
  29. seeVideoGift
  30. } from '@/api/shop.js';
  31. import {
  32. mapGetters,
  33. mapActions
  34. } from 'vuex'
  35. export default {
  36. data() {
  37. return {
  38. data: {},
  39. currentId: '',
  40. playTime: '',
  41. allTime: "",
  42. currentId: null
  43. }
  44. },
  45. onLoad(option) {
  46. // let data = JSON.parse(option.infos)
  47. // this.data = data
  48. // console.log(data)
  49. let data = uni.getStorageSync('videoData')
  50. this.data = data
  51. console.log(data)
  52. },
  53. methods: {
  54. // 看完视频获取券
  55. async getVideoGift() {
  56. const {
  57. code,
  58. data,
  59. msg
  60. } = await seeVideoGift({
  61. id: this.currentId
  62. })
  63. if (code == 1) {
  64. uni.showToast({
  65. title: msg
  66. })
  67. } else {
  68. uni.showToast({
  69. title: msg
  70. })
  71. }
  72. },
  73. TimeUpdate(e, id) {
  74. this.currentId = id
  75. this.playTime = e.detail.currentTime
  76. this.allTime = e.detail.duration
  77. // 当播放时间大于 视频总时长 即播放结束发起请求 获取券
  78. if (this.playTime >= this.allTime) {
  79. }
  80. },
  81. // 播放结束给券
  82. ended() {
  83. this.getVideoGift()
  84. }
  85. }
  86. }
  87. </script>
  88. <style lang="scss">
  89. page {
  90. height: 100vh;
  91. }
  92. .wrapper {
  93. box-sizing: border-box;
  94. background-color: #fff;
  95. padding: 20rpx 30rpx;
  96. .title {
  97. font-weight: bold;
  98. line-height: 80rpx;
  99. }
  100. .desc {
  101. font-size: 28rpx;
  102. color: #F73E33;
  103. }
  104. .details {
  105. margin: 40rpx auto;
  106. .title {
  107. font-weight: bold;
  108. }
  109. .content {
  110. margin-top: 40rpx;
  111. }
  112. }
  113. }
  114. </style>