pickVideo.nvue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. @onRemoteUser="handleRemoteUser" />
  17. </view>
  18. </template>
  19. <script>
  20. import jhlive from "@/jhlive/jhlive";
  21. const NET = require('@/utils/request')
  22. const API = require('@/config/api')
  23. export default {
  24. components: { jhlive },
  25. data() {
  26. return {
  27. userData: {},
  28. orderId: '',
  29. goodsList: [],
  30. isAuthor: true,
  31. linkMic: false,
  32. sdkAppID:API.sdkAppID,
  33. secretKey:API.secretKey,
  34. windowWidth: 0,
  35. windowHeight: 0,
  36. userId: '',
  37. roomId: '',
  38. liveId: '',
  39. num: 0,
  40. likes: 0,
  41. name:"等待用户连接",
  42. avatar:"../static/images/loginLogo.png",
  43. }
  44. },
  45. onLoad(options) {
  46. this.orderId = options.orderId
  47. this.userData = uni.getStorageSync("userData");
  48. let info = uni.getSystemInfoSync();
  49. this.windowWidth = info.windowWidth;
  50. this.windowHeight = info.windowHeight;
  51. },
  52. onReady() {
  53. this.init();
  54. },
  55. methods: {
  56. init() {
  57. NET.request(API.creatPickVideo, {orderId: this.orderId}, 'GET').then(res => {
  58. this.liveId = res.data.liveId
  59. this.roomId = res.data.roomId;
  60. this.goodsList = res.data.liveProducResVO
  61. this.$nextTick(() => this.enterRoom());
  62. }).catch(error => {
  63. uni.showToast({
  64. title: error.data.msg,
  65. duration: 2000
  66. });
  67. })
  68. },
  69. enterRoom() {
  70. this.$refs.jhlive&&this.$refs.jhlive.enterRoom();
  71. },
  72. exitRoom() {
  73. this.$refs.jhlive&&this.$refs.jhlive.exitRoom();
  74. },
  75. handleRemoteUser(users) {
  76. this.num = users.length;
  77. users.length&&this.request(API.getMainInfo +"?userId="+ users[0], {}, 'GET').then(res => {
  78. this.avatar = res.data.headimg;
  79. this.name = res.data.nickname;
  80. }).catch(error => {
  81. uni.showToast({
  82. title: error.data.msg,
  83. duration: 2000
  84. });
  85. })
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="less" scoped>
  91. .container {
  92. position: relative;
  93. display: flex;
  94. flex-direction: column;
  95. align-items: stretch;
  96. width: 750rpx;
  97. }
  98. .jhlive {
  99. width: 750rpx;
  100. flex: 1;
  101. }
  102. </style>