pickVideo.nvue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  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="num=$event.length" />
  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: false,
  37. linkMic: true,
  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.tenantCode = options.tenantCode,
  50. this.orderId = options.orderId
  51. this.userData = uni.getStorageSync("userData");
  52. let info = uni.getSystemInfoSync();
  53. this.windowWidth = info.windowWidth;
  54. this.windowHeight = info.windowHeight;
  55. },
  56. onReady() {
  57. this.init();
  58. },
  59. methods: {
  60. init() {
  61. NET.request(API.linkPickVideo, {
  62. tenantCode : this.tenantCode,
  63. orderId: this.orderId
  64. }, 'GET').then(res => {
  65. this.title = res.data.tenantName;
  66. this.avatar = res.data.headImg;
  67. this.liveId = res.data.liveId;
  68. this.roomId = res.data.roomId;
  69. this.goodsList = res.data.liveProducResVO;
  70. this.$nextTick(() => {
  71. if(this.isAuthor) {
  72. permision.checkAndRequestPermission('scope.camera').then(()=>{
  73. permision.checkAndRequestPermission('scope.record').then(()=>{
  74. this.enterRoom();
  75. },()=>{
  76. uni.showToast({
  77. title: '获取权限失败',
  78. duration: 2000,
  79. })
  80. });
  81. },()=>{
  82. uni.showToast({
  83. title: '获取权限失败',
  84. duration: 2000,
  85. })
  86. })
  87. }else if(this.linkMic) {
  88. permision.checkAndRequestPermission('scope.record').then(()=>{
  89. this.enterRoom();
  90. },()=>{
  91. uni.showToast({
  92. title: '获取权限失败',
  93. duration: 2000,
  94. })
  95. });
  96. }else {
  97. this.enterRoom();
  98. }
  99. });
  100. }).catch(error => {
  101. uni.showToast({
  102. title: error.data.msg,
  103. duration: 2000
  104. });
  105. });
  106. },
  107. enterRoom() {
  108. this.$refs.jhlive&&this.$refs.jhlive.enterRoom();
  109. },
  110. exitRoom() {
  111. this.$refs.jhlive&&this.$refs.jhlive.exitRoom();
  112. },
  113. onBtnClick(index, item) {
  114. if(index === 0) {
  115. this.$refs.popup.open()
  116. }
  117. },
  118. }
  119. }
  120. </script>
  121. <style lang="less" scoped>
  122. .container {
  123. position: relative;
  124. display: flex;
  125. flex-direction: column;
  126. align-items: stretch;
  127. width: 750rpx;
  128. }
  129. .jhlive {
  130. width: 750rpx;
  131. flex: 1;
  132. }
  133. .popup-open {
  134. width: 50px;
  135. height: 50px;
  136. position: fixed;
  137. bottom: 15px;
  138. right: 15px;
  139. background-color: #52A63A;
  140. border-radius: 50%;
  141. text-align: center;
  142. line-height: 50px;
  143. }
  144. .iconzhibo-shangpin {
  145. color: #FFFFFF;
  146. font-size: 34px;
  147. text-align: center;
  148. line-height: 50px;
  149. }
  150. .popup-box {
  151. background-color: #FFFFFF;
  152. width: 750rpx;
  153. height: 750rpx;
  154. border-top-left-radius: 10px;
  155. border-top-right-radius: 10px;
  156. }
  157. .popup-close {
  158. padding: 10px;
  159. line-height: 16px;
  160. }
  161. .popup-close-text {
  162. color: #52A63A;
  163. font-size: 15px;
  164. font-family: PingFang SC;
  165. text-align: left;
  166. }
  167. </style>