gg.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <template>
  2. <view class="content">
  3. <view class="djs">
  4. 观看完视频后,可获得奖励
  5. </view>
  6. <video src="../../static/video/v1.mp4" class="gsjs" autoplay :muted="true" :controls="false"
  7. :enable-progress-gesture="false" @play="vPlay" ref="vgg" @ended="vEnd"></video>
  8. </view>
  9. </template>
  10. <script>
  11. import {
  12. ggGive
  13. } from '@/api/zero.js'
  14. export default {
  15. data() {
  16. return {
  17. djs: 15,
  18. isEnd: false,
  19. id:0
  20. }
  21. },
  22. onLoad(opt) {
  23. this.id = opt.id
  24. },
  25. onShow() {
  26. },
  27. onReachBottom() {
  28. },
  29. onReady() {
  30. },
  31. onBackPress(event) {
  32. console.log(event, 'black')
  33. let that = this
  34. if (!that.isEnd) {
  35. that.$refs.vgg.pause()
  36. uni.showModal({
  37. title: '温馨提醒',
  38. content: '观看完视频后,可获得奖励',
  39. cancelText: '跳过视频',
  40. confirmText: '继续观看',
  41. complete(e) {
  42. console.log(e)
  43. if (e.confirm) {
  44. // return
  45. that.$refs.vgg.play()
  46. } else {
  47. uni.redirectTo({
  48. url: '/pages/zero/ren'
  49. })
  50. }
  51. }
  52. })
  53. return true
  54. }
  55. },
  56. methods: {
  57. vPlay(e) {
  58. console.log(e, '开始播放')
  59. },
  60. vEnd() {
  61. this.isEnd = true
  62. console.log(this.id)
  63. //发放奖励
  64. ggGive({
  65. id: this.id
  66. }).then(res => {
  67. uni.showToast({
  68. title:'奖励发放成功',
  69. duration:2000
  70. });
  71. setTimeout(()=> {
  72. uni.navigateBack({
  73. fail() {
  74. uni.redirectTo({
  75. url: '/pages/zero/ren'
  76. })
  77. }
  78. })
  79. },1500)
  80. })
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. page {
  87. background-color: #000;
  88. height: 100%;
  89. }
  90. .gsjs {
  91. width: 750rpx;
  92. position: absolute;
  93. top: 0;
  94. bottom: 0;
  95. margin: auto;
  96. }
  97. .djs {
  98. position: absolute;
  99. top: 20rpx;
  100. left: 20rpx;
  101. color: #fff;
  102. font-size: 28rpx;
  103. padding: 5rpx 10rpx;
  104. border: 1px solid #fff;
  105. border-radius: 20rpx;
  106. }
  107. </style>