liveDetail.nvue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="container" :style="'height: '+windowHeight+'px;'">
  3. <jhlive
  4. ref="jhlive"
  5. class="jhlive"
  6. :sdkAppID="sdkAppID"
  7. :secretKey="secretKey"
  8. :userId="userId"
  9. :roomId="roomId"
  10. :isAuthor="isAuthor"
  11. :linkMic="linkMic"
  12. :avatar="avatar"
  13. :num="num"
  14. :likes="likes"
  15. :name="name" />
  16. <jhimlive
  17. ref="jhimlive"
  18. class="jhimlive"
  19. :sdkAppID="sdkAppID"
  20. :secretKey="secretKey"
  21. :userId="userId"
  22. :roomId="roomId"
  23. :isAuthor="isAuthor"
  24. :avatar="avatar"
  25. :name="name"
  26. @onMemberCount="num=$event"/>
  27. </view>
  28. </template>
  29. <script>
  30. import jhlive from "@/jhlive/jhlive";
  31. import jhimlive from "@/jhim/jhimlive";
  32. const NET = require('@/utils/request')
  33. const API = require('@/config/api')
  34. export default {
  35. components: { jhlive, jhimlive },
  36. data() {
  37. return {
  38. isAuthor: true,
  39. linkMic: false,
  40. sdkAppID:API.sdkAppID,
  41. secretKey:API.secretKey,
  42. windowWidth: 0,
  43. windowHeight: 0,
  44. userId: '',
  45. roomId: '',
  46. liveId: '',
  47. num: 0,
  48. likes: 0,
  49. name:"",
  50. avatar:"../static/images/loginLogo.png",
  51. userData: {},
  52. enabledIM: false,
  53. imReady: false,
  54. imMsgs: [],
  55. }
  56. },
  57. onLoad(options) {
  58. this.liveId = options.liveId
  59. this.userData = uni.getStorageSync("userData");
  60. this.userId = this.userData.userId;
  61. let info = uni.getSystemInfoSync();
  62. this.windowWidth = info.windowWidth;
  63. this.windowHeight = info.windowHeight;
  64. },
  65. onReady() {
  66. // this.isAuthor = false;
  67. // this.linkMic = true;
  68. // this.userId = "123";
  69. // this.name = 'test';
  70. // this.roomId = '1';
  71. // this.$nextTick(() => this.enterRoom());
  72. // return;
  73. this.init();
  74. },
  75. onUnload() {
  76. this.exitRoom();
  77. },
  78. methods: {
  79. init() {
  80. NET.request(API.startStream+2, 'GET').then(res => {
  81. this.avatar = res.data.imgUrl;
  82. this.name = res.data.liveName;
  83. this.roomId = Number(res.data.roomId);
  84. this.$nextTick(() => this.enterRoom());
  85. }).catch(res => {
  86. uni.showToast({
  87. title: error.data.msg,
  88. duration: 2000
  89. });
  90. })
  91. },
  92. enterRoom() {
  93. this.$refs.jhimlive&&this.$refs.jhimlive.enterRoom();
  94. this.$refs.jhlive&&this.$refs.jhlive.enterRoom();
  95. },
  96. exitRoom() {
  97. this.$refs.jhimlive&&this.$refs.jhimlive.exitRoom();
  98. this.$refs.jhlive&&this.$refs.jhlive.exitRoom();
  99. NET.request(API.creatLive, {
  100. liveId: this.liveId,
  101. liveStatus: 2
  102. }, 'GET');
  103. },
  104. handleShop(msg) {
  105. }
  106. },
  107. }
  108. </script>
  109. <style lang="less" scoped>
  110. .container {
  111. position: relative;
  112. display: flex;
  113. flex-direction: column;
  114. align-items: stretch;
  115. width: 750rpx;
  116. }
  117. .jhlive {
  118. width: 750rpx;
  119. flex: 1;
  120. }
  121. .jhimlive {
  122. width: 400rpx;
  123. position: absolute;
  124. bottom: 10px;
  125. left: 10px;
  126. background-color: blue;
  127. }
  128. </style>