shuisheng před 1 rokem
rodič
revize
6fc093ac16
3 změnil soubory, kde provedl 42 přidání a 35 odebrání
  1. 4 0
      src/api/liveRoom.ts
  2. 1 1
      src/views/h5/index.vue
  3. 37 34
      src/views/pull/index.vue

+ 4 - 0
src/api/liveRoom.ts

@@ -2,6 +2,10 @@ import { IList, IPaging } from '@/interface';
 import { ILiveRoom } from '@/types/ILiveRoom';
 import request from '@/utils/request';
 
+export function fetchLiveRoomBilibili() {
+  return request.get<ILiveRoom>('/live_room/bilibili');
+}
+
 export function fetchLiveRoomList(params: IList<ILiveRoom>) {
   return request.get<IPaging<ILiveRoom>>('/live_room/list', {
     params,

+ 1 - 1
src/views/h5/index.vue

@@ -127,7 +127,7 @@ async function getLiveRoomList() {
       orderBy: 'desc',
       nowPage: 1,
       pageSize: 10,
-      childPageSize: 40,
+      childPageSize: 4,
       childNowPage: 1,
       childOrderName: 'priority',
       childOrderBy: 'desc',

+ 37 - 34
src/views/pull/index.vue

@@ -449,7 +449,7 @@ import {
 } from '@/api/giftRecord';
 import { fetchGoodsList } from '@/api/goods';
 import { fetchLiveRoomOnlineUser } from '@/api/live';
-import { fetchFindLiveRoom } from '@/api/liveRoom';
+import { fetchFindLiveRoom, fetchLiveRoomBilibili } from '@/api/liveRoom';
 import { fetchGetWsMessageList } from '@/api/wsMessage';
 import { liveRoomTypeEnumMap, QINIU_RESOURCE } from '@/constant';
 import { emojiArray } from '@/emoji';
@@ -572,6 +572,11 @@ const rtcBytesReceived = computed(() => {
 
 onMounted(async () => {
   roomId.value = route.params.roomId as string;
+  if (route.query.is_bilibili === '1') {
+    isBilibili.value = true;
+    const res = await fetchLiveRoomBilibili();
+    roomId.value = `${res.data.id!}`;
+  }
   initRoomId(roomId.value);
   initAdsbygoogle();
   await handleFindLiveRoomInfo();
@@ -600,8 +605,7 @@ onMounted(async () => {
         topRef.value.getBoundingClientRect().height);
     height.value = res;
   }
-  if (route.query.is_bilibili !== '1') {
-    isBilibili.value = false;
+  if (isBilibili.value) {
     initPull({});
   } else {
     initWs({
@@ -610,8 +614,6 @@ onMounted(async () => {
       isBilibili: true,
       isAnchor: false,
     });
-    isBilibili.value = true;
-    handleBilibil();
   }
   getGiftRecord();
   getGiftGroupList();
@@ -636,6 +638,9 @@ async function handleFindLiveRoomInfo() {
         } else {
           videoLoading.value = false;
         }
+        if (isBilibili.value) {
+          handleBilibil();
+        }
       }
     }
   } catch (error) {
@@ -644,35 +649,33 @@ async function handleFindLiveRoomInfo() {
 }
 
 async function handleBilibil() {
-  if (route.query.is_bilibili === '1') {
-    const flv = await fetchLiveBilibiliPlayUrl({
-      cid: route.params.roomId,
-      platform: 'web',
-    });
-    const hls = await fetchLiveBilibiliPlayUrl({
-      cid: route.params.roomId,
-      platform: 'h5',
-    });
-    const roomInfo = await fetchLiveBilibiliRoomGetInfo({
-      room_id: route.params.roomId,
-    });
-    console.log(flv?.data?.data?.durl?.[0].url, 'flv');
-    console.log(hls?.data?.data?.durl?.[0].url, 'hls');
-    roomLiving.value = true;
-    appStore.liveLine = LiveLineEnum.hls;
-    anchorInfo.value = {
-      avatar: roomInfo?.data?.data?.user_cover,
-      username: roomInfo?.data?.data?.title,
-    };
-    appStore.liveRoomInfo = {
-      type: LiveRoomTypeEnum.system,
-      flv_url: flv?.data?.data?.durl?.[0].url,
-      hls_url: hls?.data?.data?.durl?.[0].url,
-      areas: [{ name: roomInfo?.data?.data?.area_name }],
-      desc: roomInfo?.data?.data?.description,
-    };
-    handleRefresh();
-  }
+  const flv = await fetchLiveBilibiliPlayUrl({
+    cid: route.params.roomId,
+    platform: 'web',
+  });
+  const hls = await fetchLiveBilibiliPlayUrl({
+    cid: route.params.roomId,
+    platform: 'h5',
+  });
+  const roomInfo = await fetchLiveBilibiliRoomGetInfo({
+    room_id: route.params.roomId,
+  });
+  console.log(flv?.data?.data?.durl?.[0].url, 'flv');
+  console.log(hls?.data?.data?.durl?.[0].url, 'hls');
+  roomLiving.value = true;
+  appStore.liveLine = LiveLineEnum.hls;
+  anchorInfo.value = {
+    avatar: roomInfo?.data?.data?.user_cover,
+    username: roomInfo?.data?.data?.title,
+  };
+  appStore.liveRoomInfo = {
+    type: LiveRoomTypeEnum.system,
+    flv_url: flv?.data?.data?.durl?.[0].url,
+    hls_url: hls?.data?.data?.durl?.[0].url,
+    areas: [{ name: roomInfo?.data?.data?.area_name }],
+    desc: roomInfo?.data?.data?.description,
+  };
+  handleRefresh();
 }
 
 function handleSendGetLiveUser(liveRoomId: number) {