Browse Source

fix:框架配置相关的修改

chenzhen2 1 year ago
parent
commit
fb7d9ec771

+ 20 - 0
settings.json

@@ -0,0 +1,20 @@
+{
+    // 修改编辑器默认格式化方案,也就是右键format Document width里面的默认
+    "editor.defaultFormatter": "hu2ren.vetur-wepy",
+    "vetur.validation.script": false,
+    "vetur.validation.interpolation": false,
+    "vetur.validation.template": false,
+    "vetur.format.defaultFormatter.js": "none",
+    "vetur.format.defaultFormatter.html": "js-beautify-html",
+    "editor.formatOnSave": true,
+    "eslint.run": "onSave",
+    "eslint.validate": [
+      "vue"
+    ],
+    // #每次保存的时候将代码按eslint格式进行修复,要在保存时运行的代码操作类型。保存时按照哪个规则进行格式化
+    "editor.codeActionsOnSave": {
+      "source.fixAll": true,
+      "source.fixAll.stylelint": true
+    }
+  }
+  

+ 7 - 0
src/api/home.js

@@ -4,6 +4,13 @@ function getUserHasFollowed() {
     })
 }
 
+export function getCompanyMapData(companyId) {
+    return $http({
+      url: `/config/map/${companyId}`,
+      method: 'GET'
+    })
+  }
+
 export {
     getUserHasFollowed
 }

+ 28 - 103
src/packagesEnv/pages/intelligentControl/home2.wpy

@@ -126,7 +126,7 @@ movable-view {
   word-break: break-all;
 }
 
-.area-items-wrapper{
+.area-items-wrapper {
   position: relative;
   width: 100%;
   height: 100%;
@@ -137,7 +137,7 @@ movable-view {
   width: 144rpx;
   position: absolute;
   z-index: 9999;
-  transform-origin: 36px 54px;//偏移量决定的
+  transform-origin: 36px 54px; //偏移量决定的
 }
 
 .room-item.selected .text {
@@ -385,82 +385,6 @@ wepy.component({
   computed: {
     ...mapState({ userInfo: state => state.user.userInfo })
   },
-  //   ready() {
-  //     // let from = query.from;
-  //     // 页面加载
-  //    // this.canSearchPerson = query.from !== 'visit'; // 从访客进入的页面无法搜索人
-  //     // 如果从博瑞尚格智慧空间过来,面板是折叠起来,并且不能滑动
-  //     if (from == 'officehome') {
-  //       this.foldStatus = 'fold';
-  //       this.canSlideExpanel = false;
-  //     }
-  //     let qrcodeUrl = '';
-  //     // if (query.q) {
-  //     //   qrcodeUrl = decodeURIComponent(query.q);
-  //     //   let params = utils.getUrlParams(qrcodeUrl);
-  //     // }
-  //     // this.query = { ...query };
-  //     let queryId = '';
-  //     checkLogin()
-  //       .then(() => {
-  //         return this.getHistorySelectedArea();
-  //       })
-  //       .then(historyArea => {
-  //         let historyAreaInfo = data.find(e => e.id == historyArea.spaceId);
-  //         return getMapInfoHttp().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 = queryId || historyArea.spaceId;
-  //         console.log('httpDdata----', httpDdata);
-  //         console.log('historyArea----', historyArea);
-  //         const combinedData = httpDdata.reduce((acc, cur) => {
-  //           const target = acc.find(e => e.id == cur.id);
-  //           selectarea = acc.find(e => e.id == selectAraeId);
-  //           if (target) {
-  //             Object.assign(target, { title: cur.localName });
-  //             // console.log('找到了', cur, index);
-  //           } else {
-  //             // console.log('data有没找到', cur.id);
-  //           }
-
-  //           if (target && target.id == selectAraeId) {
-  //             selectarea = { ...target }; // 如果有新数据,则更新选中的数据
-  //           }
-  //           return acc;
-  //         }, data);
-  //         this.mapAreasInfo = data;
-  //         // 如果从博瑞尚格智慧空间过来,面板是折叠起来,并且不能滑动
-  //         // if (from == 'officehome' && queryId) {
-  //         if (from == 'officehome') {
-  //           // this.foldPanelFun();
-  //           this.doSelectArea(selectarea);
-  //           // this.getSpaceTem();
-  //         } else {
-  //           this.autoSelectArea(selectarea);
-  //         }
-  //       });
-  //     getScreenInfo().then(res => {
-  //       this.screenScale = res.screenScale;
-  //     });
-
-  //     this.getMapScale().then(res => {
-  //       this.mapScale = res.mapScale;
-  //       this.mapWidth = Math.ceil(res.mapScale * standerMapWidth); // 因为有小数点的误差,故增加一部分
-  //       this.mapHeight = res.mapHeight;
-  //       this.mapParentHeight = res.mapHeight;
-  //       this.mapParentWidth = res.screenWidth;
-  //     });
-  //   },
   ready() {
     // 页面加载
     // let from = query.from;
@@ -470,21 +394,16 @@ wepy.component({
       this.foldStatus = 'fold';
       this.canSlideExpanel = false;
     }
-    // let qrcodeUrl = '';
-    // if (query.q) {
-    //   qrcodeUrl = decodeURIComponent(query.q);
-    //   let params = utils.getUrlParams(qrcodeUrl);
-    // }
-    // this.query = { ...query };
+   
     checkHasUserInfo()
-    .then((userInfo) => {
+      .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) => {
+        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;
@@ -492,11 +411,11 @@ wepy.component({
         this.getMapSize();
         return this.getHistorySelectedArea();
       })
-      .then((historyArea) => {
+      .then(historyArea => {
         let historyAreaInfo = CompanyMapData.mapInfo.find(
-          (e) => e.id == historyArea.spaceId
+          e => e.id == historyArea.spaceId
         );
-        return getMapInfoHttp(this.companyId).then((res) => {
+        return getMapInfoHttp(this.companyId).then(res => {
           const result = JSON.parse(res.data);
           const httpDdata = (result && result.content) || [];
           return {
@@ -505,29 +424,33 @@ wepy.component({
           };
         });
       })
-      .then((res) => {
+      .then(res => {
         const { httpDdata, historyArea } = res;
         let historyAreaInfo;
         let selectarea;
         let selectAraeId = null;
         if (from == 'officehome') {
-          selectAraeId = this.spaceIdProp
+          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
+        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;
+                  .split(',')
+            : undefined;
         });
         combinedData = httpDdata.reduce((acc, cur) => {
-          let target = acc.find((e) => e.id == cur.id);
+          let target = acc.find(e => e.id == cur.id);
 
-          selectarea = acc.find((e) => e.id == selectAraeId);
+          selectarea = acc.find(e => e.id == selectAraeId);
           if (target) {
             Object.assign(target, { title: cur.localName });
           } else {
@@ -804,7 +727,9 @@ wepy.component({
       wx.uma.trackEvent('officeHome_map-find', { key: '环境调节-地图-找找' });
 
       wx.navigateTo({
-        url: `/packagesEnv/pages/intelligentControl/search/search?canSearchPerson=${this.canSearchPerson}&companyId=${this.companyId}&from=officehome`
+        url: `/packagesEnv/pages/intelligentControl/search/search?canSearchPerson=${
+          this.canSearchPerson
+        }&companyId=${this.companyId}&from=officehome`
       });
     },
     goBack() {

File diff suppressed because it is too large
+ 2122 - 1874
src/packagesEnv/pages/officehome/index.wpy


+ 47 - 0
src/service/user.js

@@ -1,3 +1,50 @@
+import apiLogin from '@/api/login.js';
+import { getUserInfo, setWxAuthUserInfo, getThirdInfo, createAccount, changePhone } from '@/api/user.js';
+import store from '@/store';
+import config from '@/config';
+
+// 获取用户数据
+function getUserData() {
+    return new Promise((resolve, reject) => {
+        Promise.all([getUserInfo(), getThirdInfo()]).then(([userInfoRes, thirdInfores]) => {
+            let userInfo = userInfoRes.data || {};
+            let thirdInfo = thirdInfores.data || {};
+            let cachedInfo = wx.getStorageSync('UserInfo');
+            userInfo = { ...cachedInfo, ...userInfo, ...thirdInfo };
+            userInfo.userName = userInfo.userName || '';
+            // test 用户身份
+            // userInfo.roles = ['tenant.admin', 'operator', 'owner'];
+            // userInfo.phone = '';wxLogin
+            // userInfo.nickName = '';
+            // userInfo.userName = ''
+            userInfo = addRolesInfoToUserInfo(userInfo);
+            if (!userInfo.userName) {
+                userInfo.defaultUserName = 'Hello';
+            }
+            // todo 模拟银泰配置 接口增加buildingLogo
+            if (config.projectName === 'yintai') {
+                userInfo.buildingLogo = `${config.h5StaticPath}/page-yintai/project-logo.png`;
+            }
+            //   userInfo.companyId = 'c68dcccd57984277ab7736f2d257cd0c'
+            store.commit('setUserInfo', userInfo);
+            resolve(userInfo);
+        }).catch((res) => {
+            reject(res);
+        })
+    })
+}
+
+// 检查登录
+function checkLogin(needGetetUserInfo = true) {
+    let token = store.state.user.token;
+    if (!token) {
+        return wxLogin(needGetetUserInfo);
+    } else {
+        return Promise.resolve();
+    }
+}
+
+//  检查用户信息
 function checkHasUserInfo() {
     let userInfo = store.state.user.userInfo;
     if (userInfo && JSON.stringify(userInfo) !== '{}') {

+ 6 - 1
src/store/user.js

@@ -13,7 +13,12 @@ export default {
     token: '',
     projectId: '',
     refreshToken: '',
-    userInfo: {},
+    userInfo: {
+      userId:'602ef709beb64a1f9a4b6af2196d0af7',
+      userPhone:15321277745,
+      userName:'陈珍',
+      projectId:'Pj1101080259'
+    },
     // 申请id
     applyId: '',
     hasClearToken: false,