home2.wpy 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  1. <style lang="less">
  2. .page-intelligent-control {
  3. position: relative;
  4. // height: 100%;
  5. width: 100%;
  6. box-sizing: border-box;
  7. overflow: hidden;
  8. .top-bar {
  9. height: 96px;
  10. background: #f7f8fa;
  11. }
  12. }
  13. .page-intelligent-control .map-contanier {
  14. // height: 100%;
  15. width: 100%;
  16. // padding-bottom: 176rpx;
  17. //background: #ebeef5;
  18. background: #f7f8fa;
  19. box-sizing: border-box;
  20. }
  21. .page-intelligent-control .location-wrapper {
  22. position: absolute;
  23. bottom: 36rpx;
  24. right: 32rpx;
  25. &.fold {
  26. }
  27. &.building {
  28. }
  29. }
  30. .search-btn-box {
  31. display: flex;
  32. justify-content: flex-end;
  33. }
  34. .page-intelligent-control .location-wrapper .search-btn {
  35. // position: absolute;
  36. // right: 0;
  37. margin-bottom: 16rpx;
  38. width: 96rpx;
  39. height: 96rpx;
  40. display: block;
  41. background: #ffffff;
  42. border-radius: 16rpx;
  43. }
  44. .page-intelligent-control .location-wrapper.expand {
  45. bottom: 658rpx;
  46. }
  47. movable-area {
  48. width: 100%;
  49. height: 0;
  50. position: relative;
  51. }
  52. movable-view {
  53. color: #fff;
  54. }
  55. .room-item {
  56. position: absolute;
  57. box-shadow: 0px 1px 4px rgba(1, 1, 51, 0.01),
  58. 0px 16px 40px rgba(1, 1, 51, 0.03);
  59. border-radius: 4px;
  60. box-sizing: border-box;
  61. padding: 0 12rpx;
  62. transform-origin: center;
  63. z-index: 1;
  64. &.isAbnormity {
  65. padding: 0;
  66. }
  67. }
  68. .room-item.selected {
  69. border: 2px solid rgba(77, 148, 255, 0.8);
  70. }
  71. .room-item.transparent {
  72. box-shadow: none;
  73. }
  74. .room-item.selected.transparent {
  75. border: 0;
  76. }
  77. .room-item.clickDisabled {
  78. border: 2px solid #dfe3ed;
  79. box-sizing: border-box;
  80. background-repeat: repeat;
  81. }
  82. .room-item .bg-disabled {
  83. width: 100%;
  84. height: 100%;
  85. border-radius: 4px;
  86. }
  87. .room-item .icon {
  88. width: 72rpx;
  89. height: 40rpx;
  90. position: absolute;
  91. top: 50%;
  92. left: 50%;
  93. transform: translateX(-50%) translateY(-50%);
  94. }
  95. .room-item .circle {
  96. width: 8rpx;
  97. height: 8rpx;
  98. border-radius: 50%;
  99. position: absolute;
  100. top: 50%;
  101. left: 50%;
  102. transform: translateX(-50%) translateY(-50%);
  103. }
  104. .room-item .door {
  105. position: absolute;
  106. width: 48rpx;
  107. height: 24rpx;
  108. }
  109. .room-item .text {
  110. font-weight: 600;
  111. font-size: 20rpx;
  112. line-height: 24rpx;
  113. text-align: center;
  114. color: #8995ba;
  115. position: absolute;
  116. top: 50%;
  117. left: 50%;
  118. width: 100%;
  119. transform: translateX(-50%) translateY(32rpx);
  120. padding: 0 16rpx;
  121. box-sizing: border-box;
  122. word-break: break-all;
  123. }
  124. .area-items-wrapper {
  125. position: relative;
  126. width: 100%;
  127. height: 100%;
  128. }
  129. .selected-icon {
  130. height: 88rpx;
  131. width: 144rpx;
  132. position: absolute;
  133. z-index: 9999;
  134. transform-origin: 36px 54px; //偏移量决定的
  135. }
  136. .room-item.selected .text {
  137. font-weight: 600;
  138. font-size: 24rpx;
  139. line-height: 24rpx;
  140. text-align: center;
  141. white-space: nowrap;
  142. color: #515a76;
  143. top: 50%;
  144. left: 50%;
  145. z-index: 2;
  146. width: auto;
  147. padding: 0;
  148. text-shadow: #fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0;
  149. transform: translateX(-50%) translateY(-50%);
  150. }
  151. .room-item.selected.ConferenceRoom {
  152. box-shadow: 0px 0px 4px rgba(1, 1, 51, 0.01),
  153. 0px 0px 40px rgba(1, 1, 51, 0.03);
  154. border-radius: 2px;
  155. border: 2px solid rgba(77, 148, 255, 0.42);
  156. }
  157. .office-content-abstract {
  158. position: absolute;
  159. bottom: 0;
  160. left: 0;
  161. right: 0;
  162. height: 238rpx;
  163. box-shadow: 0px 0px 2rpx rgba(0, 0, 0, 0.05),
  164. 0px 8rpx 30rpx rgba(0, 0, 0, 0.15);
  165. border-radius: 50rpx 50rpx 0px 0px;
  166. box-sizing: border-box;
  167. padding: 48rpx 48rpx 0;
  168. background: #ffffff;
  169. .title {
  170. font-weight: 600;
  171. font-size: 36rpx;
  172. line-height: 50rpx;
  173. color: #000000;
  174. }
  175. .btn-switch {
  176. position: absolute;
  177. top: 40rpx;
  178. right: 48rpx;
  179. width: 148rpx;
  180. height: 64rpx;
  181. font-weight: 500;
  182. font-size: 28rpx;
  183. line-height: 64rpx;
  184. color: #000000;
  185. background: #ffe823;
  186. text-align: center;
  187. box-shadow: 0px 0px 2rpx rgba(0, 0, 0, 0.15),
  188. 0px 8rpx 12rpx rgba(0, 0, 0, 0.07);
  189. border-radius: 60rpx;
  190. }
  191. }
  192. </style>
  193. <template>
  194. <div class="page-intelligent-control" v-on:click="flodFloorFun">
  195. <div class="top-bar"></div>
  196. <div class="map-contanier">
  197. <movable-area
  198. :style="{'height':mapParentHeight+'px','width':mapParentWidth+'px'}"
  199. scale-area="true"
  200. >
  201. <movable-view
  202. x="{{x}}"
  203. y="{{y}}"
  204. style="height:{{mapHeight}}px;width:{{mapWidth}}px"
  205. direction="all"
  206. out-of-bounds="false"
  207. bindscale="onScale"
  208. scale="true"
  209. scale-min="0.5"
  210. scale-max="1"
  211. scale-value="1"
  212. >
  213. <div class="area-items-wrapper">
  214. <block
  215. v-for="(area, index) in mapAreasInfo"
  216. :key="index"
  217. wx:if="{{area.floorId == selectedFloor}}"
  218. >
  219. <div
  220. @tap="selectAreaFun(area)"
  221. class="room-item {{area.isAbnormity? 'isAbnormity': ''}}"
  222. style="{{'width:'+ (area.isAbnormity? '0px;':area.width*mapScale +'px;') + 'height:'+(area.isAbnormity? '0px;':area.height*mapScale +'px;')+'left:'+area.left*mapScale+'px;'+'top:'+area.top*mapScale+'px;'+(area.isAbnormity?'': 'background-color:'+ area.backgroundColor+';'+(!area.canClick?('background-image:url(' +h5StaticPath+ 'map-icon/bg_disable.png);'): '')) + (area.isAbnormity?('border-top:' + area['borderWidth'][0]*mapScale +'px solid ' +area['borderColor'][0]+ ';' + 'border-right:' + area['borderWidth'][1]*mapScale+'px solid ' + area['borderColor'][1] +';' +'border-bottom:' + area['borderWidth'][2]*mapScale +'px solid ' +area['borderColor'][2] + ';' + 'border-left:' + area['borderWidth'][3]*mapScale +'px solid ' +area['borderColor'][3] + ';'):'')+ (area['borderRadius'] && area['borderRadius'].length? 'border-radius:' + area['borderRadius'][0]*mapScale + 'px ' + area['borderRadius'][1]*mapScale + 'px ' + area['borderRadius'][2]*mapScale + 'px ' + area['borderRadius'][3]*mapScale + 'px;': '')+(area.rotate?'transform:rotate('+area.rotate+'deg)': '')}}"
  223. :class="{'selected': selectArea.id === area.id, 'clickDisabled': area.canClick !==true,'transparent': !area.backgroundColor}"
  224. >
  225. <block wx:if="{{selectArea.id === area.id}}"></block>
  226. <block
  227. wx:elif="{{area.width*mapScale*touchScale>24&&area.height*mapScale*touchScale>24}}"
  228. >
  229. <image
  230. wx:if="{{area.icon}}"
  231. class="icon"
  232. src="{{h5StaticPath+ 'map-icon/' + area.icon}}"
  233. />
  234. </block>
  235. <block
  236. wx:elif="{{area.width*mapScale*touchScale>=24 || area.height*mapScale*touchScale>=24}}"
  237. >
  238. <div class="circle" style="{{'background-color:'+ area.circleColor+';'}}"></div>
  239. </block>
  240. <div
  241. class="text"
  242. wx:if="{{selectArea.id === area.id || (area.roomFuncType>=300 &&area.height*mapScale>80 && (area.title.length*screenScale*10 +16*screenScale)<area.width*mapScale)}}"
  243. >{{area.title}}</div>
  244. <image
  245. wx:if="{{area.has_door===true && selectArea.id !== area.id}}"
  246. style="width:{{area.door_width*mapScale}}px;height:{{area.door_height*mapScale}}px;left:{{(area.door_left === '') ? '': area.door_left*mapScale}}px;top: {{(area.door_top === '') ? '': area.door_top*mapScale}}px;right: {{(area.door_right === '') ? '': area.door_right*mapScale}}px;bottom: {{(area.door_bottom === '') ? '': area.door_bottom*mapScale}}px;"
  247. class="door"
  248. mode="scaleToFill"
  249. src="{{h5StaticPath+ 'map-icon/' +area.door_icon}}"
  250. />
  251. </div>
  252. </block>
  253. <image
  254. class="selected-icon"
  255. wx:if="{{selectArea}}"
  256. mode="scaleToFill"
  257. :style="{top: selectArea.isAbnormity? ((selectArea['borderWidth'][0]+selectArea['borderWidth'][2])/2 - selectArea['borderWidth'][0])*mapScale +'px' : (selectArea.top*mapScale-54 + (selectArea.height*mapScale/2))+'px', left: selectArea.isAbnormity? ((selectArea['borderWidth'][1]+selectArea['borderWidth'][3])/2 - selectArea['borderWidth'][3])*mapScale +'px': (selectArea.left*mapScale+(selectArea.width*mapScale/2)-36)+'px', transform: 'rotate('+(selectArea.rotate)+'deg)' }"
  258. src="{{h5StaticPath + 'map-icon/' + selectArea.selectIcon}}"
  259. />
  260. </div>
  261. </movable-view>
  262. <div class="{{'location-wrapper ' + foldStatus}}">
  263. <div class="search-btn-box">
  264. <image
  265. v-on:click="toSearchPage"
  266. class="search-btn"
  267. src="{{h5StaticPath}}icon-search-big.svg"
  268. />
  269. </div>
  270. <floor
  271. status="{{floorStatus}}"
  272. :floors="floors"
  273. :buildings="buildingData"
  274. selectedBuilding="{{ selectedBuilding }}"
  275. selectedFloor="{{selectedFloor}}"
  276. @component-floor-fold="flodFloorFun"
  277. @component-floor-change="changeFloorFun($event)"
  278. @component-floor-click="toggleFloorStatus"
  279. ></floor>
  280. </div>
  281. </movable-area>
  282. </div>
  283. </div>
  284. </template>
  285. <script>
  286. import wepy from '@wepy/core';
  287. import store from '@/store';
  288. import {
  289. getSpaceBytoothHttp,
  290. getMapDetailHttp
  291. } from '@/packagesEnv/api/intelligentControl';
  292. import { checkHasUserInfo } from '@/service/user';
  293. import utils from '@/common/utils';
  294. import config from '@/config';
  295. import { mapState } from '@wepy/x';
  296. import { saveCompanyConfig } from '@/service/companyConfig';
  297. import { getCompanyMapData } from '@/api/home';
  298. import {
  299. getBuildingList,
  300. getFloorList,
  301. getMapInfo
  302. } from '@/packagesEnv/api/mapApi.js';
  303. let h5StaticPath = config.h5StaticPath + '/page-intelligent-control/';
  304. const tarBarHeight = 96;
  305. const panelExpandHeight = 407; // 单位为px
  306. const panelFoldHeight = 96; // 单位为px
  307. const switchPanelHeight = 145; // 单位为px
  308. const standerScreenWidth = 375;
  309. const standerMapHeight = 812 - tarBarHeight - panelFoldHeight; // 在375*812屏幕下地图所能展示区域的大小px
  310. let screenInfo = {};
  311. let standerMapWidth = 2336;
  312. let mapScale;
  313. let screenScale;
  314. let foldPanelPXHeight; // 在不同的手机屏幕的实际高度
  315. let expandPXHeight;
  316. let pageSelectedAreaRecord = {
  317. // key为楼层ID,value 为spceId
  318. };
  319. let touchMapStartRecord = {
  320. timeStamp: 0,
  321. pageX: 0,
  322. pageY: 0
  323. };
  324. let touchMapEndRecord = {
  325. timeStamp: 0,
  326. pageX: 0,
  327. pageY: 0
  328. };
  329. let from = 'officehome';
  330. let CompanyMapData = {};
  331. let combinedData = [];
  332. wepy.component({
  333. props: {
  334. spaceIdProp: '',
  335. companyIdProp: ''
  336. },
  337. store,
  338. data: {
  339. currentSp: '', // 空间id 用于路由跳转
  340. h5StaticPath,
  341. mapAreasInfo: [],
  342. selectArea: {},
  343. x: 0,
  344. y: 0,
  345. selectedBuilding: '',
  346. selectedFloor: '',
  347. foldStatus: 'fold', // fold-最小化 expand-展开状态
  348. floorStatus: 'fold', // flod-收起楼层 expand-展开楼层选则
  349. mapHeight: 507,
  350. mapParentHeight: 607,
  351. mapParentWidth: 375,
  352. mapWidth: 2336,
  353. mapScale: 1,
  354. screenScale: 1,
  355. mapMoveByTouch: false,
  356. touchScale: 1,
  357. isShowLocationEntrance: false,
  358. canSearchPerson: true,
  359. canSlideExpanel: true,
  360. pageHide: false,
  361. query: {},
  362. floors: [],
  363. companyId: '',
  364. buildingData: [],
  365. buildingItem: {},
  366. floorItem: {}
  367. },
  368. computed: {
  369. ...mapState({
  370. userInfo: state => state.user.userInfo,
  371. projectId: state =>
  372. state.company &&
  373. state.company.companyConfig &&
  374. state.company.companyConfig.sagacareProjectId
  375. })
  376. },
  377. ready() {
  378. // 获取地图数据
  379. console.log('地图模块触发了--');
  380. this.init();
  381. },
  382. // 页面激活
  383. attached() {},
  384. watch: {
  385. // 父亲传过来的空间id 搜索返回才会有这个传递
  386. spaceIdProp: function(newSpaceId, oldSpaceId) {
  387. if (oldSpaceId !== newSpaceId && newSpaceId) {
  388. let area = this.mapAreasInfo.find(item => {
  389. return item.id == newSpaceId;
  390. });
  391. area && this.doSelectArea(area, true);
  392. }
  393. }
  394. },
  395. methods: {
  396. init() {
  397. this.projectId = 'Pj1101080259';
  398. this.getPageBuildingList();
  399. },
  400. //获取建筑数据
  401. getPageBuildingList() {
  402. let params = {
  403. criteria: {
  404. projectId: 'Pj1101080259'
  405. }
  406. };
  407. getBuildingList(params).then(res => {
  408. this.buildingData = res.content || [];
  409. this.buildingItem = this.buildingData[0];
  410. this.selectedBuilding = this.buildingItem.id;
  411. this.getFloorList();
  412. });
  413. },
  414. /**
  415. * 查询楼层信息
  416. */
  417. getFloorList() {
  418. let params = {
  419. criteria: {
  420. projectId: 'Pj1101080259',
  421. buildingId: this.buildingItem.id
  422. }
  423. };
  424. getFloorList(params).then(res => {
  425. this.floors = res.content || [];
  426. console.log('===', this.floors);
  427. CompanyMapData.mapWidth = 2314;
  428. this.floorItem = this.floors[0];
  429. this.selectedFloor = this.floorItem.id;
  430. this.getMapSize();
  431. this.getPageMapInfo();
  432. });
  433. },
  434. /**
  435. * 获取地图信息
  436. */
  437. getPageMapInfo() {
  438. let params = {
  439. projectId: 'Pj1101080259',
  440. floorId: this.floorItem.id
  441. };
  442. getMapInfo(params)
  443. .then(res => {
  444. let data = res.data || {};
  445. this.mapAreasInfo = data.spaceList || [];
  446. console.log('地图数据--');
  447. })
  448. .catch(() => {});
  449. },
  450. getMapSize() {
  451. getScreenInfo().then(res => {
  452. this.screenScale = res.screenScale;
  453. });
  454. this.getMapScale().then(res => {
  455. this.mapScale = res.mapScale;
  456. this.mapWidth = Math.ceil(res.mapScale * CompanyMapData.mapWidth); // 因为有小数点的误差,故增加一部分
  457. this.mapHeight = res.mapHeight;
  458. this.mapParentHeight = res.mapHeight;
  459. this.mapParentWidth = res.screenWidth;
  460. });
  461. },
  462. setCacheSelectedArea(area) {
  463. const { selectedFloor } = this;
  464. wx.setStorage({
  465. key: 'SelectedASpace',
  466. data: {
  467. spaceId: area.id,
  468. floorId: selectedFloor
  469. },
  470. success: function() {}
  471. });
  472. // 选中一个并记录
  473. pageSelectedAreaRecord = {
  474. ...pageSelectedAreaRecord,
  475. [selectedFloor]: area.id
  476. };
  477. },
  478. setCacheSelectedFloor(floorId) {
  479. const { selectArea } = this;
  480. wx.setStorage({
  481. key: 'SelectedASpace',
  482. data: {
  483. floorId: floorId,
  484. spaceId: selectArea.floorId == floorId ? selectArea.id : ''
  485. },
  486. success: function() {}
  487. });
  488. },
  489. getHistorySelectedArea() {
  490. return new Promise((resolve, reject) => {
  491. wx.getStorage({
  492. key: 'SelectedASpace',
  493. success: res => {
  494. if (res.data && res.data.spaceId) {
  495. pageSelectedAreaRecord = {
  496. ...CompanyMapData.defalutSelectedId,
  497. [res.data.floorId]: res.data.spaceId // 如果有历史记录选中,覆盖值
  498. };
  499. resolve(res.data);
  500. } else {
  501. pageSelectedAreaRecord = CompanyMapData.defalutSelectedId;
  502. resolve({
  503. spaceId: CompanyMapData.defalutSelectedId[this.selectedFloor],
  504. floorId: this.selectedFloor
  505. });
  506. }
  507. },
  508. fail: () => {
  509. pageSelectedAreaRecord = CompanyMapData.defalutSelectedId;
  510. resolve({
  511. spaceId: CompanyMapData.defalutSelectedId[this.selectedFloor],
  512. floorId: this.selectedFloor
  513. });
  514. }
  515. });
  516. });
  517. },
  518. doSelectArea(area, sign) {
  519. if (!area) {
  520. return;
  521. }
  522. this.selectArea = area;
  523. this.selectedFloor = area.floorId;
  524. // this.getSpaceTem();
  525. this.setCacheSelectedArea(area);
  526. this.setAreaCenter(area);
  527. if (!sign) {
  528. // 如果是父亲传进来的areaId 不执行下面的触发
  529. this.$emit('mapChangeSpaceInfo', area.id); // 传给父组件,以请求数据
  530. }
  531. },
  532. selectAreaFun(currentSelect) {
  533. if (!currentSelect.canClick) {
  534. wx.showToast({
  535. title: '不可选区域',
  536. duration: 1000,
  537. icon: 'none'
  538. });
  539. return;
  540. }
  541. this.doSelectArea(currentSelect);
  542. },
  543. setAreaCenter(area) {
  544. if (!area.id) {
  545. return;
  546. }
  547. if (this.touchScale !== 1) {
  548. return;
  549. }
  550. getExpandPXHeight()
  551. .then(res => {
  552. const { expandPXHeight, screenHeight, screenWidth } = res;
  553. return this.getMapScale().then(res => {
  554. return {
  555. ...res,
  556. expandPXHeight,
  557. screenHeight,
  558. screenWidth
  559. };
  560. });
  561. })
  562. .then(res => {
  563. const { foldStatus } = this;
  564. const {
  565. screenHeight,
  566. screenWidth,
  567. expandPXHeight,
  568. mapScale,
  569. mapHeight
  570. } = res;
  571. let viewHeight = screenHeight - tarBarHeight - expandPXHeight;
  572. let viewCenterX = screenWidth / 2,
  573. viewCenterY = viewHeight / 2,
  574. areaCenterX =
  575. (parseInt(area.left) + parseInt(area.width) / 2) * mapScale,
  576. areaCenterY =
  577. (parseInt(area.top) + parseInt(area.height) / 2) * mapScale;
  578. let x = parseInt(viewCenterX - areaCenterX);
  579. let y = parseInt(viewCenterY - areaCenterY);
  580. let max = expandPXHeight - foldPanelPXHeight + 20;
  581. this.mapMoveByTouch = false;
  582. this.x = x > 0 ? 0 : x; // 超过边线设置边线值
  583. this.y =
  584. foldStatus === 'expand' ? (Math.abs(y) > max ? -max : y) : this.y; // 当面板展开时候,才需垂直居中
  585. // wx.showModal({
  586. // title: '提示', //提示的标题,
  587. // content: `x值:${this.x} y值:${y}`, //提示的内容,
  588. // showCancel: true, //是否显示取消按钮,
  589. // cancelText: '取消', //取消按钮的文字,默认为取消,最多 4 个字符,
  590. // cancelColor: '#000000', //取消按钮的文字颜色,
  591. // confirmText: '确定', //确定按钮的文字,默认为取消,最多 4 个字符,
  592. // confirmColor: '#3CC51F', //确定按钮的文字颜色,
  593. // success: res => {}
  594. // });
  595. this.mapHeight = screenHeight - tarBarHeight - foldPanelPXHeight; // 相当于加入底部空白,让面板被顶起来
  596. });
  597. },
  598. onScale(e) {
  599. this.touchScale = e.$wx.detail.scale;
  600. },
  601. foldPanelFun() {
  602. this.getMapHeight().then(res => {
  603. this.mapHeight = res.mapHeight;
  604. this.y = 0;
  605. });
  606. if (this.foldStatus === 'expand') {
  607. this.foldStatus = 'fold';
  608. }
  609. },
  610. flodFloorFun() {
  611. if (this.floorStatus !== 'fold') {
  612. this.floorStatus = 'fold';
  613. }
  614. },
  615. changeFloorFun(floor) {
  616. wx.uma.trackEvent('officeHome_map-floorchange', {
  617. key: '环境调节-地图-楼层切换'
  618. });
  619. this.selectedFloor = floor;
  620. let spaceId = pageSelectedAreaRecord[floor];
  621. let area = this.mapAreasInfo.find(item => item.id == spaceId);
  622. // console.log("home",floor,this.mapAreasInfo,pageSelectedAreaRecord,area);
  623. if (from == 'officehome') {
  624. area && this.doSelectArea(area);
  625. }
  626. },
  627. toggleFloorStatus() {
  628. this.floorStatus = this.floorStatus === 'expand' ? 'fold' : 'expand';
  629. },
  630. positionFun(devices) {
  631. wx.uma.trackEvent('officeHome_map-location', {
  632. key: '环境调节-地图-定位'
  633. });
  634. getSpaceBytoothHttp(devices, this.companyId).then(res => {
  635. const result = JSON.parse(res.data || '{}');
  636. const data = (result && result.content && result.content[0]) || {};
  637. if (!data || (data && !data.id)) {
  638. wx.showToast({
  639. title: '未定位到空间', // 提示的内容,
  640. icon: 'none', // 图标,
  641. duration: 2000 // 延迟时间
  642. });
  643. return;
  644. }
  645. let mapInfo = this.mapAreasInfo.find(item => {
  646. return item.id === data.id;
  647. });
  648. this.doSelectArea({
  649. ...mapInfo,
  650. title: data.localName
  651. });
  652. });
  653. },
  654. toSearchPage() {
  655. wx.uma.trackEvent('officeHome_map-find', { key: '环境调节-地图-找找' });
  656. wx.navigateTo({
  657. url: `/packagesEnv/pages/intelligentControl/search/search?canSearchPerson=${
  658. this.canSearchPerson
  659. }&companyId=${this.companyId}&from=officehome`
  660. });
  661. },
  662. goBack() {
  663. wx.navigateBack({
  664. delta: 1 // 返回的页面数,如果 delta 大于现有页面数,则返回到首页,
  665. });
  666. },
  667. getfoldPanelPXHeight() {
  668. if (
  669. foldPanelPXHeight &&
  670. screenInfo &&
  671. screenInfo.screenWidth &&
  672. screenInfo.screenHeight
  673. ) {
  674. return Promise.resolve({
  675. foldPanelPXHeight,
  676. screenWidth: screenInfo.screenWidth,
  677. screenHeight: screenInfo.screenHeight
  678. });
  679. }
  680. return getScreenInfo().then(res => {
  681. let foldHeight =
  682. from == 'officehome' ? switchPanelHeight : panelFoldHeight;
  683. // foldPanelPXHeight = parseInt(res.screenScale * foldHeight);
  684. foldPanelPXHeight = parseInt(foldHeight);
  685. return {
  686. screenWidth: res.screenWidth,
  687. screenHeight: res.screenHeight,
  688. foldPanelPXHeight
  689. };
  690. });
  691. },
  692. getMapHeight() {
  693. return this.getfoldPanelPXHeight().then(res => {
  694. let mapHeight = res.screenHeight - tarBarHeight - res.foldPanelPXHeight;
  695. return {
  696. ...res,
  697. mapHeight
  698. };
  699. });
  700. },
  701. getMapScale() {
  702. return this.getMapHeight().then(res => {
  703. mapScale = Math.floor((res.mapHeight / standerMapHeight) * 10) / 10;
  704. return {
  705. ...res,
  706. mapScale
  707. };
  708. });
  709. }
  710. }
  711. });
  712. function getScreenInfo() {
  713. if (
  714. screenScale &&
  715. screenInfo &&
  716. screenInfo.screenWidth &&
  717. screenInfo.screenHeight
  718. ) {
  719. return Promise.resolve({
  720. ...screenInfo,
  721. screenScale
  722. });
  723. }
  724. return new Promise((resolve, reject) => {
  725. wx.getSystemInfo({
  726. success: res => {
  727. screenInfo.screenHeight = res.screenHeight;
  728. screenInfo.screenWidth = res.screenWidth;
  729. screenScale = res.screenWidth / standerScreenWidth;
  730. resolve({
  731. screenWidth: res.screenWidth,
  732. screenHeight: res.screenHeight,
  733. screenScale
  734. });
  735. }
  736. });
  737. });
  738. }
  739. function getExpandPXHeight() {
  740. if (
  741. expandPXHeight &&
  742. screenInfo &&
  743. screenInfo.screenWidth &&
  744. screenInfo.screenHeight
  745. ) {
  746. return Promise.resolve({
  747. expandPXHeight,
  748. screenWidth: screenInfo.screenWidth,
  749. screenHeight: screenInfo.screenHeight
  750. });
  751. }
  752. return getScreenInfo().then(res => {
  753. expandPXHeight = parseInt(res.screenScale * panelExpandHeight);
  754. return {
  755. screenWidth: res.screenWidth,
  756. screenHeight: res.screenHeight,
  757. expandPXHeight
  758. };
  759. });
  760. }
  761. </script>
  762. <config>
  763. {
  764. "navigationBarBackgroundColor": "#EBEEF5",
  765. "backgroundColor": "#EBEEF5",
  766. "disableScroll": true,
  767. "usingComponents": {
  768. "control-panel": "./components/controlpanel/controlpanel",
  769. "temperture-control-panel": "./components/temperturecontrolpanel/temperturecontrolpanel",
  770. "floor": "./components/floor/floor",
  771. "location": "./components/location/location"
  772. }
  773. }
  774. </config>