liveDetail.nvue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <member-base :show="false" class="wrapper">
  3. <cover-view class="div room-bg">
  4. <video v-if="liveApplyInfo" class="bg-img" :style="'width:'+getBannerStyle.width+'px;height:'+getBannerStyle.height+'px'" id="id_test_video" ref="id_test_video" :src="liveApplyInfo.live_apply_play_rtmp_url" @play="videoPlay"
  5. @pause="videoPause" @ended="videoEnded">
  6. </video>
  7. <main-content v-if="isTest || isPlay" :liveApplyInfo="liveApplyInfo" :onlineInfo="onlineInfo"></main-content>
  8. </cover-view>
  9. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  10. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content"
  11. :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  12. </uni-popup>
  13. </member-base>
  14. </template>
  15. <script>
  16. import {getFontSize} from '@/util/common'
  17. import {
  18. mapState,
  19. mapActions
  20. } from 'vuex'
  21. import MemberBase from '../MemberBase'
  22. import mainContent from './child/main-content'
  23. import {
  24. getLiveInfo
  25. } from '../../../api/memberLive'
  26. export default {
  27. data() {
  28. return {
  29. dialog: {},
  30. isTest: 0,
  31. live_apply_id: 0,
  32. isPlay: false,
  33. liveApplyInfo: false,
  34. onlineInfo:false
  35. }
  36. },
  37. computed: {
  38. ...mapState({
  39. config: state => state.config.config,
  40. }),
  41. getBannerStyle: function () {
  42. const res = uni.getSystemInfoSync()
  43. var width = res.windowWidth
  44. var height = res.windowHeight
  45. let itemWidth = width
  46. let itemHeight = height
  47. return {
  48. width: itemWidth,
  49. height: itemHeight
  50. }
  51. },
  52. },
  53. components: {
  54. MemberBase,
  55. mainContent
  56. },
  57. onLoad: function(option) {
  58. this.isTest = option.test ? 1 : 0
  59. this.fetchConfig({})
  60. this.live_apply_id = option.live_apply_id
  61. if (!this.live_apply_id) {
  62. uni.showToast({
  63. icon: 'none',
  64. title: '参数错误'
  65. })
  66. }
  67. const res = uni.getSystemInfoSync()
  68. var width = res.windowWidth
  69. var height = res.windowHeight
  70. getLiveInfo(this.live_apply_id).then(res => {
  71. this.liveApplyInfo = res.result.live_apply_info
  72. this.onlineInfo=res.result.online_info
  73. this.$nextTick(() => {
  74. var player = uni.createVideoContext("id_test_video", this)
  75. player.play()
  76. })
  77. }).catch(res => {
  78. if(res.result.live_apply_info){
  79. this.isTest=1
  80. this.liveApplyInfo = res.result.live_apply_info
  81. }
  82. uni.showToast({
  83. icon: 'none',
  84. title: res.message
  85. })
  86. })
  87. },
  88. methods: {
  89. closeDialog() {},
  90. confirmDialog(value) {
  91. switch (this.dialog.condition) {
  92. case 1:
  93. uni.navigateTo({
  94. url: '/pages/member/live/LiveList'
  95. })
  96. break
  97. }
  98. },
  99. videoPlay() {
  100. this.isPlay = true
  101. },
  102. videoPause() {
  103. this.isPlay = false
  104. },
  105. videoEnded(type) {
  106. this.dialog = {
  107. condition: 1,
  108. content: '主播已离开,是否要看看其他直播?'
  109. }
  110. this.$refs.confirm.open()
  111. },
  112. ...mapActions({
  113. fetchConfig: 'fetchConfig'
  114. }),
  115. }
  116. }
  117. </script>
  118. <style lang="scss" scoped>
  119. .wrapper{
  120. }
  121. .room-bg {
  122. position: relative;
  123. }
  124. .bg-img {
  125. position: fixed;
  126. top: 0;
  127. left: 0;
  128. z-index: 0;
  129. }
  130. </style>