123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- <template>
- <view class="container" :style="'height: '+windowHeight+'px;'">
- <jhlive
- ref="jhlive"
- class="jhlive"
- :sdkAppID="sdkAppID"
- :secretKey="secretKey"
- :userId="userId"
- :roomId="roomId"
- :isAuthor="isAuthor"
- :linkMic="linkMic"
- :avatar="avatar"
- :num="num"
- :likes="likes"
- :name="name"
- @onRemoteUser="handleRemoteUser" />
- </view>
- </template>
- <script>
- import jhlive from "@/jhlive/jhlive";
- const NET = require('@/utils/request')
- const API = require('@/config/api')
- export default {
- components: { jhlive },
- data() {
- return {
- userData: {},
- orderId: '',
- goodsList: [],
-
- isAuthor: true,
- linkMic: false,
- sdkAppID:API.sdkAppID,
- secretKey:API.secretKey,
- windowWidth: 0,
- windowHeight: 0,
- userId: '',
- roomId: '',
- liveId: '',
- num: 0,
- likes: 0,
- name:"等待用户连接",
- avatar:"../static/images/loginLogo.png",
- }
- },
- onLoad(options) {
- this.orderId = options.orderId
- this.userData = uni.getStorageSync("userData");
- let info = uni.getSystemInfoSync();
- this.windowWidth = info.windowWidth;
- this.windowHeight = info.windowHeight;
- },
- onReady() {
- this.init();
- },
- methods: {
- init() {
- NET.request(API.creatPickVideo, {orderId: this.orderId}, 'GET').then(res => {
- this.liveId = res.data.liveId
- this.roomId = res.data.roomId;
- this.goodsList = res.data.liveProducResVO
- this.$nextTick(() => this.enterRoom());
- }).catch(error => {
- uni.showToast({
- title: error.data.msg,
- duration: 2000
- });
- })
- },
- enterRoom() {
- this.$refs.jhlive&&this.$refs.jhlive.enterRoom();
- },
- exitRoom() {
- this.$refs.jhlive&&this.$refs.jhlive.exitRoom();
- },
- handleRemoteUser(users) {
- this.num = users.length;
- users.length&&this.request(API.getMainInfo +"?userId="+ users[0], {}, 'GET').then(res => {
- this.avatar = res.data.headimg;
- this.name = res.data.nickname;
- }).catch(error => {
- uni.showToast({
- title: error.data.msg,
- duration: 2000
- });
- })
- }
- }
- }
- </script>
- <style lang="less" scoped>
- .container {
- position: relative;
- display: flex;
- flex-direction: column;
- align-items: stretch;
- width: 750rpx;
- }
- .jhlive {
- width: 750rpx;
- flex: 1;
- }
- </style>
|