gemercheung 2 лет назад
Родитель
Сommit
f227d421de

+ 17 - 4
src/App.vue

@@ -25,7 +25,8 @@
   import { useI18n } from '/@/hooks/useI18n';
   import BaseDialog from '/@/components/chatRoom/dialog/base.vue';
   import PasswordDialog from '/@/components/chatRoom/dialog/password.vue';
-  import { useRoom } from './hooks/useRoom';
+  import { useRoom, roomId, currentSceneIndex } from './hooks/useRoom';
+
   const { createTourPlayer } = useTourPlayer();
   const showDebug = ref(Number(import.meta.env.VITE_SHOW_DEBUGPANEL) === 1);
   const { t } = useI18n();
@@ -282,10 +283,21 @@
   };
   watchEffect(() => {
     if (unref(isTourMode)) {
-      const { room } = useRoom();
+      const { room, currentSceneIndex, firstNum } = useRoom();
       console.log('room', room);
       if (unref(room)?.takeLookLock === 1) {
-        showPasswordDialog.value = true;
+        if (unref(currentSceneIndex) > 0) {
+          const hasInput = localStorage.getItem(`${roomId}-${unref(firstNum)}`);
+          console.log('密码::', hasInput);
+          if (Number(hasInput) === 1) {
+            showPasswordDialog.value = false;
+          } else {
+            showPasswordDialog.value = true;
+          }
+        } else {
+          showPasswordDialog.value = true;
+        }
+
         return;
       }
     }
@@ -299,9 +311,10 @@
       {{ maxNumber }}
     </span> -->
     <span>
-      {{ t('base.debuginfo') }}:公告,测试1.1.0-0330-01,角色:{{ rtcStore.role }} rId:{{
+      {{ t('base.debuginfo') }}:公告,测试1.1.0-0412-05,角色:{{ rtcStore.role }} rId:{{
         rtcStore.roomId || browser.getURLParam('roomId')
       }}
+      sceneIndex:{{ currentSceneIndex }}
     </span>
     <span class="close" @click.stop="showDebug = false">X</span>
   </div>

+ 2 - 2
src/components/chatRoom/dialog/password.vue

@@ -74,7 +74,7 @@
     emit('closeDialog');
   };
   const createdConfirm = async () => {
-    const { validPassRoom } = useRoom();
+    const { validPassRoom, firstNum } = useRoom();
     if (unref(password).length > 0 && unref(password).length === 4) {
       const encyrptPassword = md5(unref(password)).toString();
       let rid = unref(roomId);
@@ -84,6 +84,7 @@
       const res = await validPassRoom(rid, encyrptPassword);
       if (res) {
         emit('confirmDialog');
+        localStorage.setItem(`${rid}-${unref(firstNum)}`, '1');
       } else {
         Dialog.toast({ content: '请正确输入房间密码', type: 'error' });
       }
@@ -319,7 +320,6 @@
       margin: 0;
     }
 
-
     .pass-input {
       font-size: 0.39rem;
       width: 100%;

+ 18 - 5
src/components/chatRoom/index.vue

@@ -279,10 +279,25 @@
     rtcStore.setSocketParams(initParams);
     await nextTick();
     await initialRoom();
-    const { room } = useRoom();
+    const { room, currentSceneIndex, firstNum } = useRoom();
     console.log('room', room);
+    // if (unref(room)?.takeLookLock === 1) {
+    //   showPasswordDialog.value = true;
+    //   return;
+    // }
     if (unref(room)?.takeLookLock === 1) {
-      showPasswordDialog.value = true;
+      if (unref(currentSceneIndex) > 0) {
+        const hasInput = localStorage.getItem(`${rtcStore.roomId}-${unref(firstNum)}`);
+        console.log('密码::', hasInput);
+        if (Number(hasInput) === 1) {
+          showPasswordDialog.value = false;
+        } else {
+          showPasswordDialog.value = true;
+        }
+      } else {
+        showPasswordDialog.value = true;
+      }
+
       return;
     }
 
@@ -551,9 +566,7 @@
     Number(import.meta.env.VITE_SHOW_CONSOLE) === 1 && search.set('vlog', '1');
     const url = new URL(location.href);
     url.search = `?` + search.toString();
-    const { shareRoom } = useRoom();
-    // takelook/shareRoom
-    await shareRoom(rtcStore.roomId, rtcStore.userId);
+
     if (!unref(isUsingMiniApp)) {
       shareLink.value = url.toString();
     } else {

+ 8 - 0
src/components/chatRoom/share.vue

@@ -41,6 +41,9 @@
   import ClipboardJS from 'clipboard';
   import Dialog from '/@/components/basic/dialog';
   import { useI18n } from '/@/hooks/useI18n';
+  import { useRoom } from '/@/hooks/useRoom';
+  import { useRtcStore } from '/@/store/modules/rtc';
+
   const { t } = useI18n();
 
   const emit = defineEmits(['close']);
@@ -79,6 +82,11 @@
 
   const createdConfirm = async () => {
     if (unref(copylink$)) {
+      //xxx
+      const { shareRoom } = useRoom();
+      const rtcStore = useRtcStore();
+      // takelook/shareRoom
+      await shareRoom(rtcStore.roomId, rtcStore.userId);
       await nextTick(() => {
         console.log('copySuccess');
         Dialog.toast({ content: t('base.copyShareSuccess'), type: 'success' });

+ 12 - 4
src/hooks/useRoom.ts

@@ -36,6 +36,11 @@ export const room = ref<Nullable<roomDataType>>(null);
 export const roomId = roomParam;
 export const sceneList = computed<SceneItemType[]>(() => unref(room)?.sceneData || []);
 export const isLeader = browser.getURLParam('role') === 'leader';
+export const currentNum = browser.getURLParam('m');
+export const firstNum = computed(() => unref(sceneList)[0].num);
+export const currentSceneIndex = computed(() =>
+  unref(sceneList).findIndex((i) => i.num === browser.getURLParam('m')),
+);
 
 interface roomParamsType {
   name: string;
@@ -80,6 +85,9 @@ export function useRoom() {
     getSign,
     validPassRoom,
     shareRoom,
+    currentSceneIndex,
+    currentNum,
+    firstNum,
   };
 }
 
@@ -145,7 +153,7 @@ export const leaveRoom = async () => {
 };
 
 export const shareRoom = async (roomId: string, userId: string) => {
-  if (!isLeader) return;
+  // if (!isLeader) return;
   return shopAxios.get('/takelook/shareRoom', {
     params: {
       userId,
@@ -154,9 +162,9 @@ export const shareRoom = async (roomId: string, userId: string) => {
   });
 };
 
-if (roomId) {
-  shopAxios.get('/takelook/roomAddView', { params: { roomId } });
-}
+// if (roomId) {
+//   shopAxios.get('/takelook/roomAddView', { params: { roomId } });
+// }
 
 export const getSign = async (userId: string): Promise<getSignType> => {
   const res = await shopAxios.get<AxiosResponse>('/takelook/tencentYun/getSign', {