瀏覽代碼

fix: 需求更改

anxiaoxia 2 天之前
父節點
當前提交
ac581ce892

+ 1 - 0
src/components/slider/Slider.vue

@@ -63,6 +63,7 @@ const props = defineProps({
     type: Boolean,
     default: false
   }
+
 })
 
 const model = defineModel()

+ 30 - 2
src/components/slider/Slider111.vue

@@ -10,10 +10,19 @@
         @touchend="endDrag">
         <span class="slider-progress-line"></span>
       </div>
+
+      <span
+        v-if="isFollow && showValue"
+        class="slider-internal-text"
+        :style="{ left: isFollow && progressWidth < 86 ? `calc(${progressWidth}% + 10px)` : 'auto', color: followColor }"
+        >{{ showValue ? internalValue : max }}<sup v-if="suffix" class="slider-internal-text-suffix">{{ suffix }}</sup>
+        </span
+      >
       <span
+        v-if="progressWidth < 80"
         class="slider-max-text"
-        :style="{ left: isFollow && progressWidth < 86 ? `calc(${progressWidth}% + 10px)` : 'auto', color: maxColor }"
-        >{{ showValue ? internalValue : max }}{{ suffix }}</span
+        :style="{color: maxColor }"
+        >{{ max }}</span
       >
     </div>
   </div>
@@ -36,6 +45,7 @@ const props = defineProps({
     type: Boolean,
     default: false
   },
+
   suffix: {
     type: String,
     default: ''
@@ -44,6 +54,7 @@ const props = defineProps({
     type: Boolean,
     default: false
   }
+
 })
 
 const model = defineModel()
@@ -69,6 +80,10 @@ const progressWidth = computed(() => {
 //   return `linear-gradient(to right, #ff4d4f ${percentage}%, #e0e0e0 ${percentage}%)`
 // })
 
+const followColor = computed(() => {
+  const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100
+  return percentage >= 95 ? 'rgba(255, 255, 255, 0.6)' : 'var(--Blue, #001428)'
+})
 const maxColor = computed(() => {
   const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100
   return percentage >= 95 ? 'rgba(255, 255, 255, 0.6)' : 'rgb(116, 128, 141)'
@@ -186,5 +201,18 @@ onMounted(() => {
     @include text-middle(auto, 10px);
     color: rgb(116, 128, 141);
   }
+  &-internal-text{
+    @include text-middle(auto, 10px);
+    color: #001428;
+    font-family: Jost;
+    font-size: 20px;
+    font-style: normal;
+    font-weight: 300;
+    &-suffix {
+      font-size: 11px;
+      font-weight: 400;
+      line-height: 15px;
+    }
+  }
 }
 </style>

+ 13 - 10
src/hooks/useDeviceControl.js

@@ -6,7 +6,8 @@ const COMMAND_MAPPINGS = {
     gear: item => ({ code: item.gearCode, value: val => val })
   },
   lamp: {
-    isOpen: () => ({ code: 'EquipSwitchSet', value: val => (val ? 1 : 0) }),
+    // isOpen: () => ({ code: 'EquipSwitchSet', value: val => (val ? 1 : 0) }),
+    isOpen: () => ({ code: 'brightSet', value: val => (val ? 80 : 0) }),
     brightValue: () => ({ code: 'brightSet', value: val => val }),
     colorTempValue: () => ({ code: 'colorTempSet', value: val => val })
   },
@@ -14,7 +15,8 @@ const COMMAND_MAPPINGS = {
     isOpen: () => ({ code: 'EquipOffSet', value: val => (val ? 1 : 0) })
   },
   audio: {
-    isOpen: item => ({ code: item.inCloudSetCode, value: val => (val ? 1 : 0) })
+    isOpen: item => ({ code: item.inCloudSetCode, value: val => (val ? 1 : 0) }),
+    volumnSet: item => ({ code: 'volumnSet', value: val => val })
   },
   screen: {
     runStatus: item => ({ code: item.inCloudSetCode, value: val => val })
@@ -49,22 +51,23 @@ const assemblyScreenCommand = assemblyCommand('screen')
 
 // 初始化下发指令
 const initDeviceCommand = data => {
+
   let { lamps = [], curtains = [] } = data || {}
   let commands = []
   // 灯具指令
   lamps.forEach(item => {
-    // 开关指令
-    commands.push({
-      id: item.id,
-      code: item.codeSwitch,
-      value: item.valueSwitch
-    })
+    // 开关指令---取到开关点位
+    // commands.push({
+    //   id: item.id,
+    //   code: item.codeSwitch,
+    //   value: item.valueSwitch
+    // })
 
-    // 亮度指令
+    // 亮度指令 默认80
     commands.push({
       id: item.id,
       code: item.codeBright,
-      value: item.valueBright
+      value: 80
     })
 
     // 色温指令

+ 4 - 4
src/store/modules/taiguv1/index.js

@@ -8,19 +8,19 @@ const state = {
 const mutations = {
   SET_AIES_TATUS: (state, air) => {
     let { id, status } = air;
-    state.airSwtichStatus[id] = status;
+    state.airSwtichStatus[id] = {...state.airSwtichStatus[id],...status};
   },
   SET_LAMP_STATUS: (state, lamp) => {
     let { id, status } = lamp;
-    state.lampSwitchStatus[id] = status;
+    state.lampSwitchStatus[id] = {...state.lampSwitchStatus[id],...status};
   },
   SET_AUDIO_STATUS: (state, audio) => {
     let { id, status } = audio;
-    state.audioSwitchStatus[id] = status;
+    state.audioSwitchStatus[id] = {...state.audioSwitchStatus[id],...status};
   },
   SET_SCREEN_STATUS: (state, audio) => {
     let { id, status } = audio;
-    state.screenSwitchStatus[id] = status;
+    state.screenSwitchStatus[id] = {...state.screenSwitchStatus[id],...status};
   },
 };
 

+ 19 - 0
src/utils/index.ts

@@ -710,3 +710,22 @@ export const fix: any = function (d: any) {
   d1 = d1 / len;
   return d1;
 }
+
+// 自定义四舍五入
+export const customRound = (number: number) => {
+  // 确保输入在0-100范围内
+  if (number < 0) return 0;
+  if (number > 100) return 100;
+
+  // 获取个位数
+  const remainder = number % 10;
+  // 获取十位数的基数
+  const base = number - remainder;
+
+  // 四舍五入规则
+  if (remainder <= 4) {
+    return base;
+  } else {
+    return base + 10;
+  }
+}

+ 1 - 1
src/views/envmonitor/components/Light/index.vue

@@ -292,7 +292,7 @@ export default defineComponent({
             if(isAddTimer==0){
               proxyData.startLightsStatusTimer();
             }
-           
+
           })
           .catch(() => {
             if(isAddTimer==0){

文件差異過大導致無法顯示
+ 508 - 562
src/views/envmonitor/taiguv1/components/Air/AirMore.vue


+ 33 - 18
src/views/envmonitor/taiguv1/components/Volumn/index.vue

@@ -2,22 +2,24 @@
   <div class="volumn-box" :class="audioData.isOpen ? 'active' : ''">
     <div class="top">
       <img :src="audioData.isOpen ? speakerIcon : speakerCloseIcon" alt="" />
-        <SwitchButton 
-         :loading="allAudioStatus.all?.loading"
-        @change="setAudioStatus('isOpen')" 
+      <SwitchButton
+        :loading="allAudioStatus.all?.loading"
+        @change="setAudioStatus('isOpen')"
         v-model="audioData.isOpen" />
     </div>
     <div class="bottom">
       <div class="volumn-info">
         <div class="left">
           <div class="text">音响</div>
-          <div class="status">{{ audioData.isOpen ? `${audioData.onlineStatus? audioData.onlineStatus : '电脑音频'} 播放中` : '已静音' }}</div>
+          <div class="status">
+            {{ audioData.isOpen ? `${audioData.onlineStatus ? audioData.onlineStatus : '电脑音频'} 播放中` : '已静音' }}
+          </div>
         </div>
         <div class="temp" v-if="audioData.isOpen">{{ audioData.runStatus || 0 }}</div>
       </div>
 
       <div class="volumn-slider" v-if="audioData.isOpen">
-        <Slider v-model="audioData.runStatus" ></Slider>
+        <Slider :min="min" :max="max" v-model="audioData.volumnSet" @onEnd="setAudioStatus('volumnSet')"></Slider>
       </div>
     </div>
   </div>
@@ -31,10 +33,11 @@ import SwitchButton from '@/components/switch-button/SwitchButton.vue'
 import useDeviceControl from '@/hooks/useDeviceControl'
 import { useStore } from '@/store'
 import { computed, ref, watch } from 'vue'
-
+import { customRound } from '@/utils'
+const min = 0
+const max = 100
 const store = useStore()
 
-
 const emit = defineEmits(['getStatus'])
 const props = defineProps({
   audioStatus: {
@@ -52,8 +55,8 @@ const allAudioStatus = computed(() => store.state.taiguv1.audioSwitchStatus)
 
 const audioData = ref({
   isOpen: false,
-  onlineStatus:'电脑音频',
-  runStatus:0
+  onlineStatus: '电脑音频',
+  volumnSet: 0
 })
 
 watch(
@@ -68,7 +71,7 @@ watch(
 )
 const deviceControl = useDeviceControl()
 const setAudioStatus = type => {
-    if (type == 'isOpen') {
+  if (type == 'isOpen') {
     store.dispatch('taiguv1/setAudioStatus', {
       id: 'all',
       status: {
@@ -76,8 +79,17 @@ const setAudioStatus = type => {
         lastSwitchStatus: audioData.value.isOpen
       }
     })
+  } else {
+    store.dispatch('taiguv1/setAudioStatus', {
+      id: 'lastStatus',
+      status: {
+        lastValue: audioData.value.volumnSet,
+        paramsVaue: customRound(audioData.value.volumnSet)
+      }
+    })
   }
-  const params = deviceControl.assemblyAudioCommand(audioData.value[type], type, props.equipList)
+
+  const params = deviceControl.assemblyAudioCommand(customRound(audioData.value.volumnSet), type, props.equipList)
   deviceControl.sendCommands(params)
 }
 const compareStatus = data => {
@@ -90,20 +102,24 @@ const compareStatus = data => {
           lastSwitchStatus: data.isOpen
         }
       })
+
       audioData.value = {
         ...data,
-        isOpen: data.isOpen
+        isOpen: data.isOpen,
+        volumnSet: allAudioStatus.value?.lastStatus?.lastValue ?? data.volumnSet
       }
     } else {
-        audioData.value = {
+      audioData.value = {
         ...data,
-        isOpen: allAudioStatus.value.all.lastSwitchStatus
+        isOpen: allAudioStatus.value.all.lastSwitchStatus,
+        volumnSet: allAudioStatus.value?.lastStatus?.lastValue ?? data.volumnSet
       }
     }
   } else {
     audioData.value = {
       ...data,
-      isOpen: data.isOpen
+      isOpen: data.isOpen,
+      volumnSet: allAudioStatus.value?.lastStatus?.lastValue ?? data.volumnSet
     }
   }
 }
@@ -126,8 +142,8 @@ const compareStatus = data => {
     justify-content: space-between;
     align-items: center;
     img {
-        width: 30px;
-        height: 30px;
+      width: 30px;
+      height: 30px;
     }
   }
   .bottom {
@@ -206,4 +222,3 @@ const compareStatus = data => {
   }
 }
 </style>
-

+ 24 - 24
src/views/envmonitor/taiguv1/const.js

@@ -421,8 +421,8 @@ export const roomSourceData = [
   {
     id: "room2",
     spaceId: "Sp3301050005440cdf66ec914af4924a3b5e6daa52f8",
-    meetingId: "2fbaf1a040ad404f9570508b987f61f1",
-    name: "ROOM METIS",
+    meetingId: "32abde8cdb2c4bc4a5e6f3d178ea0f24",
+    name: "ROOM NAIAD",
     chineseName: "水",
     scene: {
       SceneDefaul: {
@@ -1547,23 +1547,18 @@ export const roomSourceData = [
         ],
       },
     },
+    icon: roomNaiadIcon,
     modeBg:
-      "linear-gradient(113.73deg, rgba(37, 21, 8, 0.4) 17.26%, rgba(37, 21, 8, 0.8) 55.71%)",
-    bg: "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room2.png",
-    icon: roomMetisIcon,
+      "linear-gradient(113.73deg, rgba(8, 14, 37, 0.4) 17.26%, rgba(10, 15, 33, 0.9) 55.71%)",
+    bg: "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room3.png",
     video:
-      "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room_video2.mp4",
-    envParams: {
-      CO2: 1800,
-      TVOC: 100,
-      PM25: 10,
-    },
+      "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room_video3.mov",
   },
   {
     id: "room3",
-    name: "ROOM NAIAD",
+    name: "ROOM HELIOS",
     spaceId: "Sp3301050005281ad906311240c7916e404f5eac5ad7",
-    meetingId: "32abde8cdb2c4bc4a5e6f3d178ea0f24",
+    meetingId: "9984a5ca99e5493caf959c3700e2f049",
     chineseName: "火",
     scene: {
       SceneDefaul: {
@@ -2232,18 +2227,18 @@ export const roomSourceData = [
         ],
       },
     },
-    icon: roomNaiadIcon,
+    icon: roomHeliosIcon,
     modeBg:
-      "linear-gradient(113.73deg, rgba(8, 14, 37, 0.4) 17.26%, rgba(10, 15, 33, 0.9) 55.71%)",
-    bg: "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room3.png",
+      "linear-gradient(113.73deg, rgba(32, 5, 5, 0.4) 17.26%, rgba(28, 7, 7, 0.8) 55.71%)",
+    bg: "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room4.png",
     video:
-      "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room_video3.mov",
+      "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room_video4.mp4",
   },
   {
     id: "room4",
-    name: "ROOM HELIOS",
+    name: "ROOM METIS",
     spaceId: "Sp33010500051768f3aa7b154c0f9850779d8460a682",
-    meetingId: "9984a5ca99e5493caf959c3700e2f049",
+    meetingId: "2fbaf1a040ad404f9570508b987f61f1",
     chineseName: "木",
     scene: {
       SceneDefaul: {
@@ -2696,12 +2691,17 @@ export const roomSourceData = [
         ],
       },
     },
-    icon: roomHeliosIcon,
     modeBg:
-      "linear-gradient(113.73deg, rgba(32, 5, 5, 0.4) 17.26%, rgba(28, 7, 7, 0.8) 55.71%)",
-    bg: "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room4.png",
+      "linear-gradient(113.73deg, rgba(37, 21, 8, 0.4) 17.26%, rgba(37, 21, 8, 0.8) 55.71%)",
+    bg: "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room2.png",
+    icon: roomMetisIcon,
     video:
-      "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room_video4.mp4",
+      "https://terra-h5.tenants.link/static/WeChat/page-taiguv1/page-pad/pad_room_video2.mp4",
+    envParams: {
+      CO2: 1800,
+      TVOC: 100,
+      PM25: 10,
+    },
   },
   {
     id: "room5",
@@ -3582,7 +3582,7 @@ export const roomSourceData = [
 
 export const lanageArr = [
   {
-    type: "zh",
+    type: "zh-CN",
     text: "中",
   },
   {

+ 33 - 13
src/views/envmonitor/taiguv1/index.vue

@@ -26,6 +26,7 @@
                 <div class="name">{{ roomInfo.name }}</div>
                 <div class="location">38/F</div>
             </div>
+
             <div class="language-box">
                 <div
                     class="language-item"
@@ -35,6 +36,7 @@
                 >
                     {{ item.text }}
                 </div>
+                {{$t('login.title')}}
             </div>
             <!-- 场景类型 -->
             <div class="mode-box">
@@ -157,6 +159,7 @@
             </div>
             <div
                 class="box"
+                v-if="spaceDevice.curtains?.length"
             >
                 <Curtain
                     @showMore="showMore"
@@ -197,6 +200,7 @@
 
 <script setup>
 import { onMounted, onUnmounted, ref } from 'vue'
+import { useI18n } from 'vue-i18n'
 import { useRoute, useRouter } from 'vue-router'
 import AirMore from './components/Air/AirMore.vue'
 import Air from './components/Air/index.vue'
@@ -207,17 +211,16 @@ import LightMore from './components/Lamp/LightMore.vue'
 import Screen from './components/Screen/index.vue'
 import Volumn from './components/Volumn/index.vue'
 import { ENV_CONFIG, lanageArr, roomSourceData } from './const'
+
 const boxLine = require('@/assets/taiguv1/svg/box_line.png')
 // import "vue3-video-play/dist/style.css";
 import { httpGetByMeetingId, HttpGetSpaceInfo, queryAirStatus, queryAudioStatus, queryLampStatus, queryScreenCastingStatus } from '@/apis/taiguv1'
 import useDeviceControl from '@/hooks/useDeviceControl'
-const type = ref('zh')
+const type = ref(localStorage.getItem('lang') || 'zh-CN')
 const route = useRoute()
 const router = useRouter()
 const deviceControl = useDeviceControl()
-const checkLanage = item => {
-    type.value = item.type
-}
+
 // 空间信息
 const roomInfo = ref({})
 // 场景
@@ -256,6 +259,14 @@ const popupType = ref(null)
 
 const envParams = ref({})
 
+
+const { locale } = useI18n()
+const checkLanage = item => {
+  type.value = item.type
+  locale.value  = item.type
+  localStorage.setItem('lang',  item.type)  // 持久化存储
+}
+
 const handleChildLampSwitch = (status, text) => {
     // lampSwitchStatus.value = status
     // lampStatusText.value = text
@@ -269,7 +280,9 @@ const hasExecutedModeScene = ref(false)
 // const store = useStore()
 
 onMounted(() => {
-    // try {
+  type.value = localStorage.getItem('lang') || 'zh-CN'
+  locale.value  = type.value
+    try {
         let roomId = route.query.id || 'room4'
 
         roomInfo.value = roomSourceData.find(item => item.id == roomId) || {}
@@ -285,9 +298,9 @@ onMounted(() => {
         getDeviceStatus()
         // 获取空间环境参数  轮询 5 分钟
         getSpaceInfo()
-    // } catch (error) {
-    //     handleError(error)
-    // }
+    } catch (error) {
+        handleError(error)
+    }
 })
 
 // 获取空间信息
@@ -359,7 +372,8 @@ const showDefaultScene = () => {
 // 获取空间场景
 const getSpaceScene = params => {
     const polling = createPollingTask(() => {
-        httpGetByMeetingId(params).then(res => {
+        httpGetByMeetingId(params)
+        .then(res => {
             if (res.code == 1) {
                 let { modeScene, startTime, endTime } = res.data || {}
 
@@ -385,8 +399,14 @@ const getSpaceScene = params => {
                     // 默认场景
                     showDefaultScene()
                 }
+            }else{
+                showDefaultScene()
             }
         })
+        .catch(error=>{
+            console.log('请求失败',error);
+            showDefaultScene();
+        })
     }, 1000 * 30)
     polling.start()
     onUnmounted(() => {
@@ -397,7 +417,7 @@ const getSpaceScene = params => {
 //初始化空间
 const initSpace = () => {
     sceneData.value = roomInfo.value.scene ?.[spaceScene.value] || {}
-  modeData.value = sceneData.value.mode || {}
+    modeData.value = sceneData.value.mode || {}
     modeType.value = modeData.value[0].id
     spaceDevice.value = modeData.value[0]
 }
@@ -487,12 +507,12 @@ const updateAirStatus = data => {
 }
 
 const updateLampStatus = data => {
-    let brightLamp = data.find(item => item.runStatus == 1)
-    let arr = data.filter(item => item.runStatus == 1)
+    let brightLamp = data?.find(item => item.brightValue !=0)
+    let arr = data?.filter(item => item.brightValue == 0)
     lampStatus.value = {
         brightValue: brightLamp ?.brightValue,
         colorTempValue: brightLamp ?.colorTempValue,
-        lampStatusText: arr.length == 0 ? '已关闭' : arr.length < data.length ? '已部分开启' : '已开启'
+        lampStatusText: arr?.length == 0 ? '已关闭' : arr?.length < data?.length ? '已部分开启' : '已开启'
     }
     // TODO:灯暂时都打开
     // lampStatus.value.isOpen = false