Переглянути джерело

fix:用户信息默认填充

chenzhen2 1 рік тому
батько
коміт
5f39dc3e4f

+ 91 - 80
src/packagesEnv/pages/intelligentControl/home2.wpy

@@ -316,6 +316,7 @@ import config from '@/config';
 import { mapState } from '@wepy/x';
 import { saveCompanyConfig } from '@/service/companyConfig';
 import { getCompanyMapData } from '@/api/home';
+import {getFloorList} from '@/packagesEnv/api/mapApi.js'
 
 let h5StaticPath = config.h5StaticPath + '/page-intelligent-control/';
 const tarBarHeight = 96;
@@ -383,7 +384,13 @@ wepy.component({
     companyId: ''
   },
   computed: {
-    ...mapState({ userInfo: state => state.user.userInfo })
+    ...mapState({
+      userInfo: state => state.user.userInfo,
+      projectId: state =>
+        state.company &&
+        state.company.companyConfig &&
+        state.company.companyConfig.sagacareProjectId
+    })
   },
   ready() {
     // 页面加载
@@ -395,82 +402,86 @@ wepy.component({
       this.canSlideExpanel = false;
     }
 
-    checkHasUserInfo()
-      .then(userInfo => {
-        // let companyId =
-        //   query.from !== 'visit' ? userInfo.companyId : query.companyId;
-        let companyId = this.companyIdProp || userInfo.companyId;
-        this.companyId = companyId;
-        return getCompanyMapData(companyId);
-      })
-      .then(res => {
-        CompanyMapData = JSON.parse(res.data);
-        this.selectedFloor = CompanyMapData.floorInfo[0].floorId;
-        this.floors = CompanyMapData.floorInfo;
-        this.isShowLocationEntrance = CompanyMapData.sagaCareBluetooth || false;
-        this.getMapSize();
-        return this.getHistorySelectedArea();
-      })
-      .then(historyArea => {
-        // let historyAreaInfo = CompanyMapData.mapInfo.find(
-        //   e => e.id == historyArea.spaceId
-        // );
-        return getMapInfoHttp(this.companyId).then(res => {
-          const result = JSON.parse(res.data);
-          const httpDdata = (result && result.content) || [];
-          return {
-            historyArea,
-            httpDdata
-          };
-        });
-      })
-      .then(res => {
-        const { httpDdata, historyArea } = res;
-        let historyAreaInfo;
-        let selectarea;
-        let selectAraeId = null;
-        if (from == 'officehome') {
-          selectAraeId = this.spaceIdProp;
-        } else {
-          selectAraeId = historyArea.spaceId;
-        }
-        CompanyMapData.mapInfo.forEach(item => {
-          item.canClick =
-            typeof item.canClick === 'boolean'
-              ? item.canClick
-              : JSON.parse(item.canClick);
-          item.borderRadius = item.borderRadius
-            ? item.borderRadius instanceof Array
-              ? item.borderRadius
-              : item.borderRadius
-                  .slice(2, item.borderRadius.length - 2)
-                  .split(',')
-            : undefined;
-        });
-        combinedData = httpDdata.reduce((acc, cur) => {
-          let target = acc.find(e => e.id == cur.id);
-
-          selectarea = acc.find(e => e.id == selectAraeId);
-          if (target) {
-            Object.assign(target, { title: cur.localName });
-          } else {
-          }
-
-          if (target && target.id == selectAraeId) {
-            selectarea = { ...target }; // 如果有新数据,则更新选中的数据
-          }
-          return acc;
-        }, CompanyMapData.mapInfo);
-        this.mapAreasInfo = combinedData;
-        // 如果从博瑞尚格智慧空间过来,面板是折叠起来,并且不能滑动
-        if (from == 'officehome') {
-          this.foldPanelFun();
-          this.doSelectArea(selectarea);
-          // this.getSpaceTem();
-        } else {
-          this.autoSelectArea(selectarea);
-        }
-      });
+    // 获取地图数据
+    this.getFloorList();
+
+    // checkHasUserInfo()
+    //   .then(userInfo => {
+    //     // let companyId =
+    //     //   query.from !== 'visit' ? userInfo.companyId : query.companyId;
+    //     let companyId = this.companyIdProp || userInfo.companyId;
+    //     this.companyId = companyId;
+    //     return getCompanyMapData(companyId);
+    //   })
+    //   .then(res => {
+    //     CompanyMapData = JSON.parse(res.data);
+    //     this.selectedFloor = CompanyMapData.floorInfo[0].floorId;
+    //     this.floors = CompanyMapData.floorInfo;
+    //     this.isShowLocationEntrance = CompanyMapData.sagaCareBluetooth || false;
+    //     this.getMapSize();
+    //     return this.getHistorySelectedArea();
+    //   })
+    //   .then(historyArea => {
+    //     // let historyAreaInfo = CompanyMapData.mapInfo.find(
+    //     //   e => e.id == historyArea.spaceId
+    //     // );
+    //     return getMapInfoHttp(this.companyId).then(res => {
+    //       const result = JSON.parse(res.data);
+    //       const httpDdata = (result && result.content) || [];
+    //       return {
+    //         historyArea,
+    //         httpDdata
+    //       };
+    //     });
+    //   })
+    //   .then(res => {
+    //     const { httpDdata, historyArea } = res;
+    //     let historyAreaInfo;
+    //     let selectarea;
+    //     let selectAraeId = null;
+    //     if (from == 'officehome') {
+    //       selectAraeId = this.spaceIdProp;
+    //     } else {
+    //       selectAraeId = historyArea.spaceId;
+    //     }
+    //     CompanyMapData.mapInfo.forEach(item => {
+    //       item.canClick =
+    //         typeof item.canClick === 'boolean'
+    //           ? item.canClick
+    //           : JSON.parse(item.canClick);
+    //       item.borderRadius = item.borderRadius
+    //         ? item.borderRadius instanceof Array
+    //           ? item.borderRadius
+    //           : item.borderRadius
+    //               .slice(2, item.borderRadius.length - 2)
+    //               .split(',')
+    //         : undefined;
+    //     });
+    //     combinedData = httpDdata.reduce((acc, cur) => {
+    //       let target = acc.find(e => e.id == cur.id);
+
+    //       selectarea = acc.find(e => e.id == selectAraeId);
+    //       if (target) {
+    //         Object.assign(target, { title: cur.localName });
+    //       } else {
+    //       }
+
+    //       if (target && target.id == selectAraeId) {
+    //         selectarea = { ...target }; // 如果有新数据,则更新选中的数据
+    //       }
+    //       return acc;
+    //     }, CompanyMapData.mapInfo);
+    //     this.mapAreasInfo = combinedData;
+    //     // 如果从博瑞尚格智慧空间过来,面板是折叠起来,并且不能滑动
+    //     if (from == 'officehome') {
+    //       this.foldPanelFun();
+    //       this.doSelectArea(selectarea);
+    //       // this.getSpaceTem();
+    //     } else {
+    //       this.autoSelectArea(selectarea);
+    //     }
+    //   });
+    
   },
   watch: {
     // 父亲传过来的空间id 搜索返回才会有这个传递
@@ -487,10 +498,10 @@ wepy.component({
     /**
      * 查询楼层信息
      */
-    getFloorList(flag) {
+    getFloorList() {
       let params = {
         criteria: {
-          projectId: projectId
+          projectId: this.projectId
         }
       };
       getFloorList(params).then(res => {});
@@ -500,7 +511,7 @@ wepy.component({
      */
     getMapInfo() {
       let params = {
-        projectId: 'props.projectId',
+        projectId: '',
         floorId: 'proxyData.floorItem.id'
       };
       getMapInfo(params)

+ 3 - 1
src/packagesEnv/pages/officehome/index.wpy

@@ -1147,7 +1147,9 @@ wepy.page({
 
     var _this = this;
     this.routeParams = routeParams;
-    // console.log('routeParams', routeParams)                                                                                                                                                                                                                                                              ;
+    // console.log('routeParams', routeParams) 
+    
+    console.log("this.userInfo==",this.userInfo);
 
     checkHasUserInfo().then(userInfo => {
       if (userInfo) {

+ 0 - 1
src/service/user.js

@@ -1,4 +1,3 @@
-// import apiLogin from '@/api/login.js';
 import { getUserInfo, setWxAuthUserInfo, getThirdInfo, createAccount, changePhone } from '@/api/user.js';
 import store from '@/store';
 import config from '@/config';

+ 2 - 2
src/store/company.js

@@ -1,7 +1,7 @@
 export default {
   state: {
     companyConfig: {
-      projectId: 'Pj1101080255'  // 测试阶段先给一个默认值
+      sagacareProjectId: 'Pj1101080255'  // 测试阶段先给一个默认值
     }
   },
   mutations: {
@@ -11,7 +11,7 @@ export default {
     clearCompanyConfig(state) {
       // state.companyConfig = null;
       state.companyConfig = {
-        projectId: 'Pj1101080255'  // 测试阶段先给一个默认值
+        sagacareProjectId: 'Pj1101080255'  // 测试阶段先给一个默认值
       }
     }
   },

+ 18 - 6
src/store/user.js

@@ -14,10 +14,10 @@ export default {
     projectId: '',
     refreshToken: '',
     userInfo: {
-      userId:'602ef709beb64a1f9a4b6af2196d0af7',
-      userPhone:15321277745,
-      userName:'陈珍',
-      projectId:'Pj1101080259'
+      userId: '602ef709beb64a1f9a4b6af2196d0af7',
+      userPhone: 15321277745,
+      userName: '陈珍',
+      projectId: 'Pj1101080259'
     },
     // 申请id
     applyId: '',
@@ -35,13 +35,25 @@ export default {
       state.status = status;
     },
     setUserInfo(state, userInfo) {
-      state.userInfo = { ...state.userInfo, ...userInfo };
+      // state.userInfo = { ...state.userInfo, ...userInfo };
+      state.userInfo = {
+        userId: '602ef709beb64a1f9a4b6af2196d0af7',
+        userPhone: 15321277745,
+        userName: '陈珍',
+        projectId: 'Pj1101080259'
+      }
     },
     setApplyId(state, applyId) {
       state.applyId = applyId
     },
     clearUserInfo(state) {
-      state.userInfo = {};
+      // state.userInfo = {};
+      state.userInfo = {
+        userId: '602ef709beb64a1f9a4b6af2196d0af7',
+        userPhone: 15321277745,
+        userName: '陈珍',
+        projectId: 'Pj1101080259'
+      }
     },
     hasClearToken(state, data) {
       state.hasClearToken = data