Browse Source

feat 页面之间交互

anxiaoxia 1 year ago
parent
commit
9f214c7aff

+ 6 - 5
src/packagesEnv/api/officehome.js

@@ -3,16 +3,17 @@ import config from '@/config'
 import store from '@/store/index.js'
 
 function storeUser() {
+  let userInfo = store.state.user.userInfo
   return {
-    tag: '20247ac1b24e82760a733485969ef7ee',
-    userId: '9a1ecfbacb6b4f249bf2dd3ec7793ead',
-    phone: '17611228068',
-    userName: '安小霞'
+    userId: userInfo.userId,
+    phone: userInfo.phone,
+    userName: userInfo.name
   }
 }
 
 function getProjectId() {
-  return 'Pj1101080259'
+  let userInfo = store.state.user.userInfo
+  return userInfo.projectId
 }
 
 function commonParams() {

+ 42 - 35
src/packagesEnv/pages/officehome/FloorHeating/floorHeating.wpy

@@ -141,14 +141,14 @@
 <template>
     <div class="box">
         <image
-                :src="[totalStatus ?  (h5StaticPath+'floor_heat_open.png') : (h5StaticPath+'floor_heat_close.png')]"
-                class="img"
-            />
- 
+            :src="[totalStatus ?  (h5StaticPath+'floor_heat_open.png') : (h5StaticPath+'floor_heat_close.png')]"
+            class="img"
+        />
+
         <div class="card_total">
             <div class="titleSt">地暖</div>
             <div class="temSt">
-                <div class="num">{{ tempSet ? tempSet : '--'  }}</div>
+                <div class="num">{{ tempSet ? tempSet : '--' }}</div>
                 <div class="unit">℃</div>
             </div>
             <div class="btn_box">
@@ -160,7 +160,10 @@
                     <span v-show="onlyOne">{{""}}</span>
                 </div>
                 <div class="rt">
-                    <Switch :checked="totalStatus" @component-switch-change="changeSwitch($event,'total')"></Switch>
+                    <Switch
+                        :checked="totalStatus"
+                        @component-switch-change="changeSwitch($event,'total')"
+                    ></Switch>
                 </div>
             </div>
         </div>
@@ -189,9 +192,11 @@
             class="box_feat"
             v-show="!IsAll"
         >
-            <div class="eachFeat"  @click="openFloorFeatPop(item)"
-            v-for="item in equipList"
-            :key="item.id"
+            <div
+                class="eachFeat"
+                @click="openFloorFeatPop(item)"
+                v-for="item in equipList"
+                :key="item.id"
             >
                 <div class="temp">
                     <div style="display: flex;">{{item.tempSet ? item.tempSet :'--'}}<span class="unit">℃</span></div>
@@ -208,7 +213,7 @@
                 <div class="eqName">
                     {{ item.localName }}
                 </div>
-               
+
                 <img
                     :style="{'opacity':(item.runStatus ? '1' : '0.3;')}"
                     class="imgSt"
@@ -219,8 +224,8 @@
     </div>
 </template>
 <script>
-import wepy from '@wepy/core';
-import config from '@/config';
+import wepy from '@wepy/core'
+import config from '@/config'
 import { querySapceFloorHeating, setSocketHttp } from '@/packagesEnv/api/officehome.js'
 wepy.component({
   props: {
@@ -245,43 +250,45 @@ wepy.component({
   },
   computed: {
     arrowImg() {
-      let imgString = '';
+      let imgString = ''
       if (!this.arrowType) {
         imgString = 'down_Arrow.svg'
       } else {
         imgString = 'up_Arrow.svg'
       }
-      return imgString;
+      return imgString
     }
   },
   watch: {
-    spaceId() {
-      this.getData();
-      this.intervalCall();
+    spaceId(val) {
+      if (val) {
+        this.getData()
+        this.intervalCall()
+      }
     }
   },
   detached() {
-    clearInterval(this.timer);
-    this.timer = null;
+    clearInterval(this.timer)
+    this.timer = null
   },
   methods: {
-    // 定时调用
+        // 定时调用
     intervalCall() {
-      clearInterval(this.timer);
-      this.timer = null;
+      clearInterval(this.timer)
+      this.timer = null
       this.timer = setInterval(() => {
-        this.getData();
-      }, 1000 * 3);
+        this.getData()
+      }, 1000 * 3)
     },
     getData() {
       querySapceFloorHeating({ spaceId: this.spaceId }).then(res => {
-        const resData = res.data;
-        this.equipList = resData.equipList || [];
-        this.len = this.equipList.length;
-        this.tempSet = resData.tempSet;
-        this.maxValue = resData.maxTempSet > 35 ? 35 : resData.maxTempSet;
-        this.minValue = resData.minTempSet < 16 ? 16 : resData.minTempSet;
-        this.totalStatus = resData.runStatus;
+        const resData = res.data
+        this.equipList = resData.equipList || []
+        this.len = this.equipList.length
+        this.tempSet = resData.tempSet
+        this.maxValue = resData.maxTempSet > 35 ? 35 : resData.maxTempSet
+        this.minValue = resData.minTempSet < 16 ? 16 : resData.minTempSet
+        this.totalStatus = resData.runStatus
         let obj = {
           maxValue: this.maxValue,
           minValue: this.minValue,
@@ -296,11 +303,11 @@ wepy.component({
       })
     },
     changeSwitchLR(val) {
-      this.IsAll = val;
+      this.IsAll = val
     },
-    // 下发指令
+        // 下发指令
     changeSwitch(val, type, id, code) {
-      let paramArr = [];
+      let paramArr = []
       if (type === 'total') {
         this.equipList.map(item => {
           paramArr.push({
@@ -326,7 +333,7 @@ wepy.component({
           })
         })
       }
-    //   console.log(paramArr, '----paramArr');
+            //   console.log(paramArr, '----paramArr');
       this.setEquip(paramArr)
     },
     openFloorFeatPop(item) {

+ 7 - 5
src/packagesEnv/pages/officehome/components/socket-card.wpy

@@ -105,11 +105,13 @@ wepy.component({
     }
   },
   watch: {
-    spaceId() {
-      this.showsockets = false // 恢复初始化值
-      this.allowSvg = 'down_Arrow.svg'
-      this.onlyOne = true // 切换空间重新触发
-      this.handlerTimer()
+    spaceId(val) {
+      if (val) {
+        this.showsockets = false // 恢复初始化值
+        this.allowSvg = 'down_Arrow.svg'
+        this.onlyOne = true // 切换空间重新触发
+        this.handlerTimer()
+      }
     },
     openEquipList(newVal) {
       if (newVal.length) {

+ 26 - 26
src/packagesEnv/pages/officehome/index.wpy

@@ -522,7 +522,9 @@ page {
                 v-show="transY"
             >
                 <!--      <map-home    v-if="userInfo&& userInfo.userId" -->
-                <map-home @mapChangeSpaceInfo="mapChangeSpaceInfo"></map-home>
+                <map-home @mapChangeSpaceInfo="mapChangeSpaceInfo"
+                :space="userControlSpace"
+                ></map-home>
             </div>
             <div
                 class="move-wrap"
@@ -614,7 +616,7 @@ page {
                                 :key="idx"
                                 @click="handleScene(item,idx)"
                             >
-                                <image :src="h5StaticPath+item.img" />
+                                <image :src="h5StaticPath+item.headImg" />
                                 <span>{{item.name}}</span>
                             </div>
                         </div>
@@ -994,7 +996,7 @@ page {
 import wepy from '@wepy/core'
 import store from '@/store'
 import { mapState, mapActions } from '@wepy/x'
-
+import { checkUserControl } from '@/service/user.js'
 import moment from 'moment'
 import {
     getSpaceAdjustList,
@@ -1029,6 +1031,7 @@ let initListSen = [
     id: 0,
     code: 'DISCUSSING',
     name: '讨论',
+    headImg: 'discuss.svg',
     img: 'discuss.png',
     checked: true,
     textObj: [
@@ -1042,6 +1045,7 @@ let initListSen = [
     id: 1,
     code: 'PROJECTING',
     name: '投影',
+    headImg: 'shadow2.svg',
     img: 'shadow2.png',
     checked: false,
     textObj: [
@@ -1055,6 +1059,7 @@ let initListSen = [
     id: 2,
     code: 'ADJOURNMENT',
     name: '散会',
+    headImg: 'beover.svg',
     img: 'beover.png',
     checked: false,
     textObj: [
@@ -1127,7 +1132,7 @@ wepy.page({
     officeData: null,
     headScene: '', // 头部文案
     headImg: '', // 头部背景图片
-    options: { roomType: null, spaceId: 'Sp1101080259c4434730d12144ba890fe11f796d3143' }, // 本地数据
+    options: { roomType: null, spaceId: '' }, // 本地数据
     popList: [],
         // 上班=ATWORK 讨论=DISCUSSING 投影=PROJECTING 散会=ADJOURNMENT 下班=OFFWORK
     meetingRoomSence: [
@@ -1251,15 +1256,9 @@ wepy.page({
   },
     // 加载字体
   onLoad(routeParams) {
-    routeParams = {
-      'from': 'homeSetSpace',
-      'isControlSpace': 3,
-      'buildingId': 'string',
-      'spaceId': 'Sp1101080259c4434730d12144ba890fe11f796d3143',
-      'spaceName': 'string',
-      'floorId': 'string'
-    }
+    console.log(routeParams, '----routeParams')
     this.getCardWidth()
+    this.getWeatherInfo()// 天气预报
     var nowTimeStr = moment().format('YYYY-MM-DD')
     var eightTime = moment(nowTimeStr + ' 20:00:00').valueOf()
     var sixTime = moment(nowTimeStr + ' 05:00:00').valueOf()
@@ -1297,28 +1296,32 @@ wepy.page({
     spaceInfoStatusTimer = clearInterval(spaceInfoStatusTimer)
   },
   methods: {
+    // 关闭设置常驻的弹框
     closePermanentPanel(val) {
       this.isShowPermanent = val
     },
+    // 从找一找和首页 进入本页面
     async fromOtherPages() {
             // homeSetSpace 设置常驻,  homeShowEnv 环境调节,  FindIt 找一找
             // openLamp 开灯,  airAddOne 空调调高一度,  airReduceOne 空调下降一度 , closeLampAir 关闭灯和空调
 
       if (this.routeParams.from === 'FindIt') {
+        this.userControlSpace = this.routeParams
         this.options.spaceId = this.routeParams.spaceId
         this.moveToBottom = true  // 来自找一找, 页面在底部
         this.getData() // 获取数据
       } else {
+        // 从首页进入
         await this.getCurrentSpace()
         if (this.options.spaceId) {
           await this.getData()
         }
-                // 从首页过来
         let setAirtemp = this.$refs.airHandCard.airTemp
         switch (this.routeParams.from) {
           case 'homeShowEnv':
             if (this.userControlSpace.isControlSpace === 1 || this.userControlSpace.isControlSpace === 2) {
               this.moveToBottom = true
+              this.toRoom()
             }
             break
           case 'homeSetSpace':
@@ -1352,15 +1355,12 @@ wepy.page({
       }
     },
     getCurrentSpace() {
-      const resData = {
-        'isControlSpace': 3, // 1-租户下无可控;2-租户有可控;3-用户有可控 4-当前空间为常驻空间
-        'buildingId': 'string',
-        'spaceId': 'Sp1101080259c4434730d12144ba890fe11f796d3143',
-        'spaceName': 'string',
-        'floorId': 'string'
-      }
-      this.userControlSpace = resData
-      this.options.spaceId = resData.spaceId
+      return checkUserControl().then(res => {
+        console.log(res, '-----1')
+        // 1-租户下无可控;2-租户有可控;3-用户有可控 4-当前空间为常驻空间
+        this.userControlSpace = res
+        this.options.spaceId = res.spaceId || ''
+      })
     },
 
     setCanScroll(val) {
@@ -1530,7 +1530,6 @@ wepy.page({
       await this.getWorkDayTime() // 工作组时间
       this.getEquipments() // 空间下的设备
       this.checkEquipmentConfigStatus()
-      this.getWeatherInfo()// 天气预报
     },
     getEquipments() {
             // 获取空间下设备
@@ -1595,9 +1594,10 @@ wepy.page({
         this.getSpaceInfo() // 空间信息
       }, 20 * 1000) // 2秒描刷接口
     },
-
-    mapChangeSpaceInfo(spaceId) {
-      this.options.spaceId = spaceId
+    // 地图数据切换空间
+    mapChangeSpaceInfo(obj) {
+      this.userControlSpace = obj
+      this.options.spaceId = obj.spaceId
       this.getData()
     },
     getSpaceInfo() {