pickVideo.nvue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="container" :style="'height: '+windowHeight+'px;'">
  3. <jhlive
  4. ref="jhlive" class="jhlive"
  5. :sdkAppID="sdkAppID" :secretKey="secretKey" :userId="userId" :roomId="roomId"
  6. :isAuthor="isAuthor" :linkMic="linkMic"
  7. :avatar="avatar" :subtitle="num?'已连接':'等待用户进入'" :title="title"
  8. :btns="btns" @onBtnClick="onBtnClick"
  9. @onRemoteUser="handleRemoteUser" />
  10. <uni-popup ref="popup" animation type="bottom">
  11. <view class="popup-box">
  12. <view class="popup-close">
  13. <text class="popup-close-text" @click="$refs.popup.close()">收起</text>
  14. </view>
  15. <scroll-view scroll-y="true" class="good-box">
  16. </scroll-view>
  17. </view>
  18. </uni-popup>
  19. </view>
  20. </template>
  21. <script>
  22. import jhlive from "@/jhlive/jhlive";
  23. const NET = require('@/utils/request')
  24. const API = require('@/config/api')
  25. export default {
  26. components: { jhlive },
  27. data() {
  28. return {
  29. windowWidth: 0,
  30. windowHeight: 0,
  31. userData: {},
  32. orderId: '',
  33. tenantCode: '',
  34. goodsList: [],
  35. liveId: '',
  36. isAuthor: true,
  37. linkMic: false,
  38. sdkAppID:API.sdkAppID,
  39. secretKey:API.secretKey,
  40. btns: [{picture:"../static/images/live-good.png",title:''}],
  41. userId: '',
  42. roomId: '',
  43. title: "暂无",
  44. num: 0,
  45. avatar: "../static/images/loginLogo.png",
  46. }
  47. },
  48. onLoad(options) {
  49. this.orderId = options.orderId
  50. this.userData = uni.getStorageSync("userData");
  51. let info = uni.getSystemInfoSync();
  52. this.windowWidth = info.windowWidth;
  53. this.windowHeight = info.windowHeight;
  54. },
  55. onReady() {
  56. this.init();
  57. },
  58. methods: {
  59. init() {
  60. NET.request(API.creatPickVideo, {orderId: this.orderId}, 'GET').then(res => {
  61. this.liveId = res.data.liveId
  62. this.roomId = res.data.roomId;
  63. this.goodsList = res.data.liveProducResVO
  64. this.$nextTick(() => this.enterRoom());
  65. }).catch(error => {
  66. uni.showToast({
  67. title: error.data.msg,
  68. duration: 2000
  69. });
  70. })
  71. },
  72. enterRoom() {
  73. this.$refs.jhlive&&this.$refs.jhlive.enterRoom();
  74. },
  75. exitRoom() {
  76. this.$refs.jhlive&&this.$refs.jhlive.exitRoom();
  77. },
  78. handleRemoteUser(users) {
  79. this.subtitle = users.length;
  80. users.length&&this.request(API.getMainInfo +"?userId="+ users[0], {}, 'GET').then(res => {
  81. this.avatar = res.data.headimg;
  82. this.title = res.data.nickname;
  83. }).catch(error => {
  84. uni.showToast({
  85. title: error.data.msg,
  86. duration: 2000
  87. });
  88. })
  89. },
  90. onBtnClick(index, item) {
  91. if(index === 0) {
  92. this.$refs.popup.open()
  93. }
  94. },
  95. }
  96. }
  97. </script>
  98. <style lang="less" scoped>
  99. .container {
  100. position: relative;
  101. display: flex;
  102. flex-direction: column;
  103. align-items: stretch;
  104. width: 750rpx;
  105. }
  106. .jhlive {
  107. width: 750rpx;
  108. flex: 1;
  109. }
  110. .popup-open {
  111. width: 50px;
  112. height: 50px;
  113. position: fixed;
  114. bottom: 15px;
  115. right: 15px;
  116. background-color: #52A63A;
  117. border-radius: 50%;
  118. text-align: center;
  119. line-height: 50px;
  120. }
  121. .iconzhibo-shangpin {
  122. color: #FFFFFF;
  123. font-size: 34px;
  124. text-align: center;
  125. line-height: 50px;
  126. }
  127. .popup-box {
  128. background-color: #FFFFFF;
  129. width: 750rpx;
  130. height: 750rpx;
  131. border-top-left-radius: 10px;
  132. border-top-right-radius: 10px;
  133. }
  134. .popup-close {
  135. padding: 10px;
  136. line-height: 16px;
  137. }
  138. .popup-close-text {
  139. color: #52A63A;
  140. font-size: 15px;
  141. font-family: PingFang SC;
  142. text-align: left;
  143. }
  144. </style>