jhlive.nvue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. <template>
  2. <view class="container-jhlive" data-type="jhlive">
  3. <liveView
  4. class="liveView"
  5. ref="liveView"
  6. :sdkAppID="sdkAppID"
  7. :userSig="userSig"
  8. :userid="userid"
  9. :roomid="roomid"
  10. :isAuthor="isAuthor"
  11. :linkMic="linkMic" />
  12. <view class="top_left_box">
  13. <image class="top_left_box_img" :src="avtar"></image>
  14. <view class="top_left_box_text">
  15. <text class="top_left_box_text1">{{name}}</text>
  16. <text class="top_left_box_text2" >{{num||1}}</text>
  17. </view>
  18. </view>
  19. <view class="top-right-box">
  20. <view class="top-right-box-btn" v-if="isAuthor" @click="btnChangeCamera">
  21. <text class="top-right-box-btn-text">切换</text>
  22. </view>
  23. </view>
  24. <view class="bottom-left-box" v-if="!imReady">
  25. <view class="bottom-left-box-login"><text>登录中...</text></view>
  26. </view>
  27. <view class="bottom-left-box" v-if="imReady">
  28. <view class="bottom-left-box-messages" v-for="(item, index) in imMsgs" :key="index">
  29. <view class="bottom-left-box-message">
  30. <image :src="item.avatar" />
  31. <text>{{item.name}}:{{item.text}}</text>
  32. </view>
  33. </view>
  34. <view class="bottom-left-box-input-box">
  35. <input
  36. class="bottom-left-box-input"
  37. placeholder="说点什么..." placeholder-style="color:#fff"
  38. v-model="imMsgInput"
  39. confirm-type="send" @confirm="btnImSend" />
  40. </view>
  41. </view>
  42. <view class="bottom-right-box">
  43. <view class="bottom-right-box-btn" @click="btnShop">
  44. <text class="bottom-right-box-btn-text">商品</text>
  45. </view>
  46. <view class="bottom-right-box-btn" @click="btnLike">
  47. <text class="bottom-right-box-btn-text">点赞</text>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import LibGenerateTestUserSig from "./lib-generate-test-usersig-es.min";
  54. // #ifdef MP-WEIXIN
  55. import liveView from './live-wechat';
  56. //#endif
  57. // #ifdef H5
  58. import liveView from './live-wechat';
  59. //#endif
  60. // #ifdef APP-PLUS
  61. import liveView from './live-app';
  62. //#endif
  63. const EXPIRETIME = 604800;
  64. export default {
  65. name: 'jhlive',
  66. components: { liveView },
  67. data() {
  68. return {
  69. userSig: '',
  70. imMsgInput: '',
  71. };
  72. },
  73. props: {
  74. sdkAppID: Number,
  75. secretKey: String,
  76. userid: String,
  77. roomid: String,
  78. isAuthor: Boolean,
  79. linkMic: Boolean,
  80. name: String,
  81. avtar: String,
  82. num: Number,
  83. likes: Number,
  84. imReady: Boolean,
  85. imMsgs: Array,
  86. },
  87. mounted: function() {
  88. this.init();
  89. },
  90. destroyed: function() {
  91. this.destroy();
  92. },
  93. methods: {
  94. init() {
  95. uni.setKeepScreenOn({
  96. keepScreenOn: true
  97. });
  98. },
  99. destroy() {
  100. uni.setKeepScreenOn({
  101. keepScreenOn: false
  102. });
  103. this.exitRoom()
  104. },
  105. enterRoom() {
  106. const generator = new LibGenerateTestUserSig(this.sdkAppID, this.secretKey, EXPIRETIME);
  107. this.userSig = generator.genTestUserSig(this.userid);
  108. setTimeout(()=>{
  109. this.$refs.liveView.enterRoom();
  110. }, 1000)
  111. },
  112. exitRoom() {
  113. this.$refs.liveView.exitRoom();
  114. },
  115. btnChangeCamera() {
  116. this.$refs.liveView.ChangeCamera();
  117. },
  118. btnImSend() {
  119. this.$emit('imSend', this.imMsgInput);
  120. this.imMsgInput = '';
  121. },
  122. btnLike() {
  123. this.$emit('like');
  124. },
  125. btnShop() {
  126. this.$emit('shop');
  127. }
  128. }
  129. };
  130. </script>
  131. <style scoped>
  132. .container-jhlive {
  133. position: relative;
  134. display: flex;
  135. flex-direction: column;
  136. align-items: stretch;
  137. background-color: black;
  138. width: 100%;
  139. height: 100%;
  140. }
  141. .liveView {
  142. flex: 1;
  143. }
  144. .top_left_box {
  145. left: 0;
  146. top: 0;
  147. margin-left: 10px;
  148. margin-top: 10px;
  149. position: absolute;
  150. z-index: 100;
  151. background-color:rgba(0, 0, 0, 0.4);
  152. border-radius: 1000px;
  153. display: flex;
  154. flex-direction: row;
  155. padding: 10px;
  156. }
  157. .top_left_box_img {
  158. width: 80rpx;
  159. height: 80rpx;
  160. border-radius: 1000px;
  161. background-color: white;
  162. }
  163. .top_left_box_text {
  164. margin-left: 10px;
  165. flex: 1;
  166. }
  167. .top_left_box_text1 {
  168. font-size: 28rpx;
  169. color: white;
  170. }
  171. .top_left_box_text2 {
  172. font-size: 20rpx;
  173. color: white;
  174. }
  175. .top-right-box {
  176. right: 0;
  177. top: 0;
  178. margin-top: 10px;
  179. margin-right: 10px;
  180. position: absolute;
  181. z-index: 100;
  182. }
  183. .top-right-box-btn {
  184. color: white;
  185. }
  186. .top-right-box-btn {
  187. color: white;
  188. }
  189. .bottom-left-box {
  190. left: 0;
  191. bottom: 0;
  192. margin-left: 10px;
  193. margin-bottom: 10px;
  194. position: absolute;
  195. z-index: 100;
  196. }
  197. .bottom-left-box-login {
  198. color: white;
  199. }
  200. .bottom-left-box-messages {
  201. }
  202. .bottom-left-box-message {
  203. }
  204. .bottom-left-box-input-box {
  205. }
  206. .bottom-left-box-input {
  207. color: #fff;
  208. font-size: 30rpx;
  209. }
  210. .bottom-right-box {
  211. right: 0;
  212. bottom: 0;
  213. margin-bottom: 10px;
  214. margin-right: 10px;
  215. position: absolute;
  216. z-index: 100;
  217. display: flex;
  218. flex-direction: row;
  219. }
  220. .bottom-right-box-btn {
  221. color: white;
  222. margin-left: 5px;
  223. }
  224. .bottom-right-box-btn-color {
  225. color: white;
  226. }
  227. </style>