home2.wpy 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981
  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. .tool-box {
  14. position: fixed;
  15. bottom: 272rpx;
  16. right: 40rpx;
  17. z-index: 333;
  18. .search-btn-box {
  19. overflow: hidden;
  20. text-align: right;
  21. image {
  22. float: right;
  23. width: 88rpx;
  24. height: 88rpx;
  25. }
  26. }
  27. .search-btn {
  28. margin-bottom: 16rpx;
  29. width: 88rpx;
  30. height: 88rpx;
  31. display: block;
  32. border-radius: 16rpx;
  33. }
  34. .now-floor {
  35. box-sizing: border-box;
  36. padding: 20rpx 0;
  37. background: #ffffff;
  38. border-radius: 16rpx;
  39. box-shadow: 0px 4px 12px 0px #00000008;
  40. .select-building {
  41. display: inline-block;
  42. vertical-align: middle;
  43. padding-left: 28rpx;
  44. padding-right: 24rpx;
  45. font-family: PingFang SC;
  46. font-size: 32rpx;
  47. font-weight: 500;
  48. line-height: 44rpx;
  49. text-align: center;
  50. }
  51. .line {
  52. display: inline-block;
  53. vertical-align: middle;
  54. height: 36rpx;
  55. width: 1px;
  56. background: #e1e5eb;
  57. }
  58. .select-floor {
  59. display: inline-block;
  60. vertical-align: middle;
  61. padding: 0 24rpx;
  62. font-family: PingFang SC;
  63. font-size: 32rpx;
  64. font-weight: 500;
  65. line-height: 44rpx;
  66. text-align: center;
  67. background: #fff;
  68. }
  69. }
  70. }
  71. .page-intelligent-control .map-contanier {
  72. // height: 100%;
  73. width: 100%;
  74. // padding-bottom: 176rpx;
  75. //background: #ebeef5;
  76. background: #f7f8fa;
  77. box-sizing: border-box;
  78. }
  79. .page-intelligent-control .location-wrapper {
  80. position: fixed;
  81. bottom: 272rpx;
  82. right: 40rpx;
  83. z-index: 444;
  84. &.fold {
  85. }
  86. &.building {
  87. }
  88. }
  89. .page-intelligent-control .location-wrapper.expand {
  90. bottom: 658rpx;
  91. }
  92. movable-area {
  93. width: 100%;
  94. height: 0;
  95. position: relative;
  96. }
  97. movable-view {
  98. color: #fff;
  99. }
  100. .room-item {
  101. position: absolute;
  102. box-shadow: 0px 1px 4px rgba(1, 1, 51, 0.01),
  103. 0px 16px 40px rgba(1, 1, 51, 0.03);
  104. border-radius: 4px;
  105. box-sizing: border-box;
  106. padding: 0 12rpx;
  107. transform-origin: center;
  108. z-index: 1;
  109. &.isAbnormity {
  110. padding: 0;
  111. }
  112. }
  113. // 租户可控
  114. .tent-space {
  115. background: #ffffff;
  116. }
  117. // 用户可控
  118. .user-space {
  119. background: #d5e4ed;
  120. }
  121. // 不能控制
  122. .no-control {
  123. }
  124. .room-item.selected {
  125. border: 2px solid rgba(77, 148, 255, 0.8);
  126. }
  127. .room-item.transparent {
  128. box-shadow: none;
  129. }
  130. .room-item.selected.transparent {
  131. border: 0;
  132. }
  133. .room-item.clickDisabled {
  134. border: 2px solid #dfe3ed;
  135. box-sizing: border-box;
  136. background-repeat: repeat;
  137. }
  138. .room-item .bg-disabled {
  139. width: 100%;
  140. height: 100%;
  141. border-radius: 4px;
  142. }
  143. .room-item .icon {
  144. width: 40rpx;
  145. height: 40rpx;
  146. position: absolute;
  147. top: 50%;
  148. left: 50%;
  149. transform: translateX(-50%) translateY(-50%);
  150. }
  151. .room-item .circle {
  152. width: 8rpx;
  153. height: 8rpx;
  154. border-radius: 50%;
  155. position: absolute;
  156. top: 50%;
  157. left: 50%;
  158. transform: translateX(-50%) translateY(-50%);
  159. }
  160. .room-item .door {
  161. position: absolute;
  162. width: 48rpx;
  163. height: 24rpx;
  164. }
  165. .room-item .text {
  166. font-weight: 600;
  167. font-size: 20rpx;
  168. line-height: 24rpx;
  169. text-align: center;
  170. color: #8995ba;
  171. position: absolute;
  172. top: 50%;
  173. left: 50%;
  174. width: 100%;
  175. transform: translateX(-50%) translateY(32rpx);
  176. padding: 0 16rpx;
  177. box-sizing: border-box;
  178. word-break: break-all;
  179. }
  180. .area-items-wrapper {
  181. position: relative;
  182. width: 100%;
  183. height: 100%;
  184. }
  185. .selected-icon {
  186. height: 38px;
  187. box-sizing: border-box;
  188. position: absolute;
  189. // background: #ac8be8;
  190. border-radius: 30px;
  191. background-size: 100% 100%;
  192. z-index: 9999;
  193. text-align: center;
  194. padding: 8px;
  195. max-width: 140px;
  196. .sanjiao {
  197. position: absolute;
  198. content: '';
  199. width: 0;
  200. height: 0;
  201. top: 30px;
  202. left: 50%;
  203. transform: translateX(-50%) rotate(90deg);
  204. border-top: solid 10px transparent;
  205. border-left: solid 10px;
  206. border-bottom: solid 10px transparent;
  207. border-top-width: 10px;
  208. border-top-style: solid;
  209. border-top-color: transparent;
  210. border-left-width: 10px;
  211. border-left-style: solid;
  212. // border-left-color: #ac8be8;
  213. border-bottom-width: 10px;
  214. border-bottom-style: solid;
  215. border-bottom-color: transparent;
  216. }
  217. label {
  218. position: relative;
  219. display: inline-block;
  220. // width: 100%;
  221. max-width: 132px;
  222. font-family: PingFang SC;
  223. font-size: 14px;
  224. font-weight: 600;
  225. line-height: 22px;
  226. letter-spacing: 0px;
  227. text-align: center;
  228. overflow: hidden;
  229. white-space: nowrap;
  230. text-overflow: ellipsis;
  231. margin: 0 auto;
  232. }
  233. }
  234. .room-item.selected .text {
  235. font-weight: 600;
  236. font-size: 24rpx;
  237. line-height: 24rpx;
  238. text-align: center;
  239. white-space: nowrap;
  240. color: #515a76;
  241. top: 50%;
  242. left: 50%;
  243. z-index: 2;
  244. width: auto;
  245. padding: 0;
  246. text-shadow: #fff 1px 0 0, #fff 0 1px 0, #fff -1px 0 0, #fff 0 -1px 0;
  247. transform: translateX(-50%) translateY(-50%);
  248. }
  249. .room-item.selected.ConferenceRoom {
  250. box-shadow: 0px 0px 4px rgba(1, 1, 51, 0.01),
  251. 0px 0px 40px rgba(1, 1, 51, 0.03);
  252. border-radius: 2px;
  253. border: 2px solid rgba(77, 148, 255, 0.42);
  254. }
  255. .office-content-abstract {
  256. position: absolute;
  257. bottom: 0;
  258. left: 0;
  259. right: 0;
  260. height: 238rpx;
  261. box-shadow: 0px 0px 2rpx rgba(0, 0, 0, 0.05),
  262. 0px 8rpx 30rpx rgba(0, 0, 0, 0.15);
  263. border-radius: 50rpx 50rpx 0px 0px;
  264. box-sizing: border-box;
  265. padding: 48rpx 48rpx 0;
  266. background: #ffffff;
  267. .title {
  268. font-weight: 600;
  269. font-size: 36rpx;
  270. line-height: 50rpx;
  271. color: #000000;
  272. }
  273. .btn-switch {
  274. position: absolute;
  275. top: 40rpx;
  276. right: 48rpx;
  277. width: 148rpx;
  278. height: 64rpx;
  279. font-weight: 500;
  280. font-size: 28rpx;
  281. line-height: 64rpx;
  282. color: #000000;
  283. background: #ffe823;
  284. text-align: center;
  285. box-shadow: 0px 0px 2rpx rgba(0, 0, 0, 0.15),
  286. 0px 8rpx 12rpx rgba(0, 0, 0, 0.07);
  287. border-radius: 60rpx;
  288. }
  289. }
  290. .icon-arrow {
  291. text-align: right;
  292. .icon-arrow-box {
  293. margin-top: 8rpx;
  294. box-sizing: border-box;
  295. border-radius: 16rpx;
  296. display: inline-block;
  297. height: 88rpx;
  298. line-height: 88rpx;
  299. text-align: center;
  300. width: 152rpx;
  301. background: #fff;
  302. box-shadow: 0px 4px 12px 0px #00000008;
  303. label {
  304. display: inline-block;
  305. vertical-align: middle;
  306. font-family: PingFang SC;
  307. font-size: 32rpx;
  308. font-weight: 500;
  309. letter-spacing: 0px;
  310. }
  311. image {
  312. display: inline-block;
  313. vertical-align: middle;
  314. margin-left: 16rpx;
  315. width: 24rpx;
  316. height: 24rpx;
  317. }
  318. }
  319. }
  320. </style>
  321. <template>
  322. <div class="page-intelligent-control">
  323. <div class="top-bar"></div>
  324. <div class="map-contanier">
  325. <movable-area
  326. :style="{'height':mapParentHeight+'px','width':mapParentWidth+'px'}"
  327. scale-area="true"
  328. >
  329. <movable-view
  330. x="{{x}}"
  331. y="{{y}}"
  332. style="height:{{mapHeight}}px;width:{{mapWidth}}px"
  333. direction="all"
  334. out-of-bounds="false"
  335. bindscale="onScale"
  336. scale="true"
  337. scale-min="0.5"
  338. scale-max="1"
  339. scale-value="1"
  340. >
  341. <div class="area-items-wrapper">
  342. <block
  343. v-for="(area, index) in mapAreasInfo"
  344. :key="index">
  345. <div
  346. @tap="selectAreaFun(area)"
  347. class="room-item {{area.isAbnormity? 'isAbnormity': ''}}"
  348. 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.isCompanyControl?('background-image:url(' +h5StaticPath+ '/page-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)': '')}}"
  349. :class="{'selected': selectArea.spaceId === area.spaceId,
  350. 'clickDisabled': area.isCompanyControl !==true,'transparent': !area.isCompanyControl}"
  351. >
  352. <block
  353. wx:if="{{area.width*mapScale*touchScale>24&&area.height*mapScale*touchScale>24}}"
  354. >
  355. <image
  356. wx:if="{{area.icon}}"
  357. class="icon"
  358. src="{{h5StaticPath+ '/page-map-icon/' + area.icon}}"
  359. />
  360. </block>
  361. <block
  362. wx:elif="{{area.width*mapScale*touchScale>=24 || area.height*mapScale*touchScale>=24}}"
  363. >
  364. <div class="circle" style="{{'background-color:'+ area.circleColor+';'}}"></div>
  365. </block>
  366. <div
  367. class="text"
  368. wx:if="{{selectArea.spaceId === area.spaceId || (area.height*mapScale>80 && (area.title.length*screenScale*10 +16*screenScale)<area.width*mapScale)}}"
  369. >{{area.title}}</div>
  370. </div>
  371. </block>
  372. <div
  373. class="selected-icon"
  374. v-if="selectArea"
  375. mode="scaleToFill"
  376. :style="{top:(selectArea.top*mapScale-38)+'px',width:(selectArea.selectIconWidth)+'px',left:(selectArea.left*mapScale+(selectArea.width*mapScale/2)-selectArea.selectIconWidth/2)+'px',background:(selectArea.circleColor), transform: 'rotate('+(selectArea.rotate)+'deg)'}"
  377. >
  378. <span :style="{'border-left-color':(selectArea.circleColor)}" class="sanjiao "></span>
  379. <label>{{ selectArea.localName }}</label>
  380. </div>
  381. </div>
  382. </movable-view>
  383. <div class="tool-box" v-if="foldStatus!=='expand'">
  384. <div class="search-btn-box">
  385. <image
  386. v-on:click="toSearchPage"
  387. class="search-btn"
  388. src="{{h5StaticPath}}/page-intelligent-control/icon-search-big.svg"
  389. />
  390. </div>
  391. <div class="now-floor"
  392. v-on:click="changeBuilding">
  393. <div class="select-building"
  394. v-if="buildingData && buildingData.length>1"
  395. >{{ buildingItem.localName }}</div>
  396. <div class="line" v-if="buildingData && buildingData.length>1"></div>
  397. <div class="select-floor">{{ floorItem.localName }}</div>
  398. </div>
  399. </div>
  400. <div v-if="foldStatus=='expand'" class="location-wrapper">
  401. <!--楼层和建筑数据-->
  402. <floor
  403. status="{{floorStatus}}"
  404. :floors="floors"
  405. :buildings="buildingData"
  406. selectedBuilding="{{ selectedBuilding }}"
  407. selectedFloor="{{selectedFloor}}"
  408. @component-building-change="changeBuildingFun($event)"
  409. @component-floor-change="changeFloorFun($event)"
  410. ></floor>
  411. <!--查看更多 -->
  412. <div class="icon-arrow">
  413. <div class="icon-arrow-box"
  414. @click="closeExpend">
  415. <label>收起</label>
  416. <image
  417. mode="scaleToFill"
  418. class="icon"
  419. src="{{h5StaticPath+ 'page-intelligent-control/icon-floor-arrow.svg'}}"/>
  420. </div>
  421. </div>
  422. </div>
  423. </movable-area>
  424. </div>
  425. </div>
  426. </template>
  427. <script>
  428. import wepy from '@wepy/core';
  429. import store from '@/store';
  430. import {
  431. getSpaceBytoothHttp,
  432. getMapDetailHttp
  433. } from '@/packagesEnv/api/intelligentControl';
  434. import { checkHasUserInfo } from '@/service/user';
  435. import utils from '@/common/utils';
  436. // import { getMapSpaceIcon } from '@/common/utils.js';
  437. import config from '@/config';
  438. import { mapState } from '@wepy/x';
  439. import { saveCompanyConfig } from '@/service/companyConfig';
  440. import { getCompanyMapData } from '@/api/home';
  441. import {
  442. getBuildingList,
  443. getFloorList,
  444. getMapInfo
  445. } from '@/packagesEnv/api/mapApi.js';
  446. let h5StaticPath = config.h5StaticPath;
  447. const tarBarHeight = 96;
  448. const panelExpandHeight = 407; // 单位为px
  449. const panelFoldHeight = 96; // 单位为px
  450. const switchPanelHeight = 145; // 单位为px
  451. const standerScreenWidth = 375;
  452. const standerMapHeight = 812 - tarBarHeight - panelFoldHeight; // 在375*812屏幕下地图所能展示区域的大小px
  453. let screenInfo = {};
  454. let standerMapWidth = 2336;
  455. let mapScale;
  456. let screenScale;
  457. let foldPanelPXHeight; // 在不同的手机屏幕的实际高度
  458. let expandPXHeight;
  459. let pageSelectedAreaRecord = {
  460. // key为楼层ID,value 为spceId
  461. };
  462. let touchMapStartRecord = {
  463. timeStamp: 0,
  464. pageX: 0,
  465. pageY: 0
  466. };
  467. let touchMapEndRecord = {
  468. timeStamp: 0,
  469. pageX: 0,
  470. pageY: 0
  471. };
  472. let from = 'officehome';
  473. let CompanyMapData = {};
  474. let combinedData = [];
  475. wepy.component({
  476. props: {
  477. space: {
  478. type: Object,
  479. default: {
  480. isControlSpace: 0,
  481. buildingId: 'Bd1101080259317347f00d0811ebb06b1d2749356f83',
  482. spaceId: 'Sp1101080259308f5ed92e964bc1b029038dea962de4',
  483. spaceName: '上格云二区',
  484. floorId: 'Fl1101080259282bba688d32419caa57685ff17447b2'
  485. }
  486. }
  487. },
  488. store,
  489. data: {
  490. currentSp: '', // 空间id 用于路由跳转
  491. h5StaticPath,
  492. mapAreasInfo: [],
  493. selectArea: null,
  494. x: 0,
  495. y: 0,
  496. selectedBuilding: '',
  497. selectedFloor: '',
  498. foldStatus: 'fold', // fold-最小化 expand-展开状态
  499. floorStatus: 'fold', // flod-收起楼层 expand-展开楼层选则
  500. mapHeight: 507,
  501. mapParentHeight: 607,
  502. mapParentWidth: 375,
  503. mapWidth: 2336,
  504. mapScale: 1,
  505. screenScale: 1,
  506. mapMoveByTouch: false,
  507. touchScale: 1,
  508. isShowLocationEntrance: false,
  509. canSearchPerson: true,
  510. canSlideExpanel: true,
  511. pageHide: false,
  512. query: {},
  513. floors: [],
  514. companyId: '',
  515. buildingData: [],
  516. buildingItem: {},
  517. floorItem: {}
  518. },
  519. computed: {
  520. ...mapState({
  521. userInfo: state => state.user.userInfo
  522. })
  523. },
  524. ready() {
  525. // 获取地图数据
  526. console.log('地图模块触发了--');
  527. if (this.space) {
  528. this.init();
  529. }
  530. },
  531. // 页面激活
  532. attached() {},
  533. watch: {
  534. // 父亲传过来的空间id 搜索返回才会有这个传递
  535. space: function(newSpace, oldSpace) {
  536. console.log('获取到空间数据--');
  537. console.log(newSpace);
  538. // console.log(oldSpace)
  539. }
  540. },
  541. methods: {
  542. // 收起
  543. closeExpend() {
  544. console.log('点击了收起--');
  545. this.foldStatus = 'fold';
  546. console.log(this.foldStatus);
  547. },
  548. init() {
  549. // this.projectId = 'Pj3301100002';
  550. console.log(this.userInfo);
  551. this.projectId = this.userInfo.projectId;
  552. this.getPageBuildingList();
  553. },
  554. // 展开建筑
  555. changeBuilding() {
  556. if (this.floors && this.floors.length > 1) {
  557. this.foldStatus = 'expand';
  558. } else {
  559. return;
  560. }
  561. },
  562. //设置建筑名称
  563. setBuidingItem() {
  564. console.log('this.space.buildingId==', this.space.buildingId);
  565. this.buildingData.map(item => {
  566. if (item.id == this.space.buildingId) {
  567. this.selectedBuilding = item.id;
  568. this.buildingItem = item;
  569. }
  570. });
  571. },
  572. //获取建筑数据
  573. getPageBuildingList() {
  574. let params = {
  575. criteria: {
  576. projectId: this.projectId
  577. }
  578. };
  579. getBuildingList(params).then(res => {
  580. this.buildingData = res.content || [];
  581. console.log('this.selectedBuilding==', this.selectedBuilding);
  582. this.setBuidingItem();
  583. console.log('this.selectedBuilding==', this.selectedBuilding);
  584. if (this.selectedBuilding) {
  585. this.getFloorList();
  586. }
  587. });
  588. },
  589. // 设置楼层
  590. setFlorrItem() {
  591. this.floors.map(item => {
  592. if (item.id == this.space.floorId) {
  593. this.selectedFloor = item.id;
  594. this.floorItem = item;
  595. }
  596. });
  597. },
  598. /**
  599. * 查询楼层信息
  600. */
  601. getFloorList() {
  602. let params = {
  603. criteria: {
  604. projectId: this.projectId,
  605. buildingId: this.selectedBuilding
  606. }
  607. };
  608. getFloorList(params).then(res => {
  609. this.floors = res.content || [];
  610. this.setFlorrItem();
  611. // console.log('this.selectedFloor==', this.selectedFloor);
  612. if (this.selectedFloor) {
  613. this.getPageMapInfo();
  614. }
  615. });
  616. },
  617. /**
  618. * 获取地图信息
  619. */
  620. getPageMapInfo() {
  621. let params = {
  622. projectId: this.projectId,
  623. floorId: this.selectedFloor,
  624. userCode: this.userInfo.userId,
  625. companyId: this.userInfo.companyId
  626. };
  627. getMapInfo(params)
  628. .then(res => {
  629. let data = res.data || {};
  630. this.mapAreasInfo = data.spaceList || [];
  631. CompanyMapData.mapWidth = data.width;
  632. this.setMapIcon();
  633. this.getMapSize();
  634. console.log('this.selectArea===', this.selectArea);
  635. })
  636. .catch(() => {});
  637. },
  638. // 设置地图的图标
  639. setMapIcon() {
  640. this.mapAreasInfo.map(item => {
  641. if (item.spaceId == this.space.spaceId) {
  642. this.selectArea = item;
  643. }
  644. if (item.localName) {
  645. item.selectIconWidth = item.localName.length * 14 + 16;
  646. if (item.selectIconWidth < 74) {
  647. item.selectIconWidth = 74;
  648. }
  649. if (item.selectIconWidth > 140) {
  650. item.selectIconWidth = 132;
  651. }
  652. } else {
  653. item.selectIconWidth = 0;
  654. }
  655. item.icon = utils.getMapSpaceIcon(item.roomFuncType).icon;
  656. item.typeName = utils.getMapSpaceIcon(item.roomFuncType).typeName;
  657. item.selectIcon = item.icon;
  658. if (item.typeName == '开放办公区') {
  659. item.circleColor = '#6B96D9';
  660. } else if (item.typeName == '个人办公区') {
  661. item.circleColor = '#AC8BE8';
  662. } else if (item.typeName == '会议室') {
  663. item.circleColor = '#69CACB';
  664. } else {
  665. item.circleColor = '#9DAACB';
  666. }
  667. if (item.isCompanyControl) {
  668. item.backgroundColor = '#D5E4ED';
  669. }
  670. if (item.isCompanyControl && item.isUserControl) {
  671. item.backgroundColor = '#FFFFFF';
  672. }
  673. if (!item.isCompanyControl) {
  674. item.backgroundColor = '';
  675. }
  676. });
  677. },
  678. // 切换建筑
  679. changeBuildingFun(building) {
  680. // this.buildingItem = building;
  681. this.selectedBuilding = building;
  682. this.getFloorList();
  683. },
  684. // 切换楼层
  685. changeFloorFun(floor) {
  686. console.log('切换楼层');
  687. this.selectedFloor = floor;
  688. // this.floorItem = floor;
  689. this.getPageMapInfo();
  690. },
  691. // 获取地图的缩放比例
  692. getMapSize() {
  693. getScreenInfo().then(res => {
  694. this.screenScale = res.screenScale;
  695. });
  696. this.getMapScale().then(res => {
  697. this.mapScale = res.mapScale;
  698. this.mapWidth = Math.ceil(res.mapScale * CompanyMapData.mapWidth); // 因为有小数点的误差,故增加一部分
  699. this.mapHeight = res.mapHeight;
  700. this.mapParentHeight = res.mapHeight;
  701. this.mapParentWidth = res.screenWidth;
  702. });
  703. },
  704. getHistorySelectedArea() {
  705. return new Promise((resolve, reject) => {
  706. wx.getStorage({
  707. key: 'SelectedASpace',
  708. success: res => {
  709. if (res.data && res.data.spaceId) {
  710. pageSelectedAreaRecord = {
  711. ...CompanyMapData.defalutSelectedId,
  712. [res.data.floorId]: res.data.spaceId // 如果有历史记录选中,覆盖值
  713. };
  714. resolve(res.data);
  715. } else {
  716. pageSelectedAreaRecord = CompanyMapData.defalutSelectedId;
  717. resolve({
  718. spaceId: CompanyMapData.defalutSelectedId[this.selectedFloor],
  719. floorId: this.selectedFloor
  720. });
  721. }
  722. },
  723. fail: () => {
  724. pageSelectedAreaRecord = CompanyMapData.defalutSelectedId;
  725. resolve({
  726. spaceId: CompanyMapData.defalutSelectedId[this.selectedFloor],
  727. floorId: this.selectedFloor
  728. });
  729. }
  730. });
  731. });
  732. },
  733. // 设置选中的路径
  734. doSelectArea(area, sign) {
  735. if (!area) {
  736. return;
  737. }
  738. this.selectArea = area;
  739. this.selectedFloor = area.floorId;
  740. this.setAreaCenter(area);
  741. if (!sign) {
  742. // 如果是父亲传进来的areaId 不执行下面的触发
  743. console.log('this.selectArea==', this.selectArea);
  744. this.$emit('mapChangeSpaceInfo', area); // 传给父组件,以请求数据
  745. }
  746. },
  747. // 获取选中的空间
  748. selectAreaFun(currentSelect) {
  749. if (!currentSelect.isCompanyControl) {
  750. wx.showToast({
  751. title: '不可选区域',
  752. duration: 1000,
  753. icon: 'none'
  754. });
  755. return;
  756. }
  757. this.selectArea = null;
  758. this.doSelectArea(currentSelect);
  759. },
  760. setAreaCenter(area) {
  761. if (!area.id) {
  762. return;
  763. }
  764. if (this.touchScale !== 1) {
  765. return;
  766. }
  767. getExpandPXHeight()
  768. .then(res => {
  769. const { expandPXHeight, screenHeight, screenWidth } = res;
  770. return this.getMapScale().then(res => {
  771. return {
  772. ...res,
  773. expandPXHeight,
  774. screenHeight,
  775. screenWidth
  776. };
  777. });
  778. })
  779. .then(res => {
  780. const { foldStatus } = this;
  781. const {
  782. screenHeight,
  783. screenWidth,
  784. expandPXHeight,
  785. mapScale,
  786. mapHeight
  787. } = res;
  788. let viewHeight = screenHeight - tarBarHeight - expandPXHeight;
  789. let viewCenterX = screenWidth / 2,
  790. viewCenterY = viewHeight / 2,
  791. areaCenterX =
  792. (parseInt(area.left) + parseInt(area.width) / 2) * mapScale,
  793. areaCenterY =
  794. (parseInt(area.top) + parseInt(area.height) / 2) * mapScale;
  795. let x = parseInt(viewCenterX - areaCenterX);
  796. let y = parseInt(viewCenterY - areaCenterY);
  797. let max = expandPXHeight - foldPanelPXHeight + 20;
  798. this.mapMoveByTouch = false;
  799. this.x = x > 0 ? 0 : x; // 超过边线设置边线值
  800. this.y =
  801. foldStatus === 'expand' ? (Math.abs(y) > max ? -max : y) : this.y; // 当面板展开时候,才需垂直居中
  802. // wx.showModal({
  803. // title: '提示', //提示的标题,
  804. // content: `x值:${this.x} y值:${y}`, //提示的内容,
  805. // showCancel: true, //是否显示取消按钮,
  806. // cancelText: '取消', //取消按钮的文字,默认为取消,最多 4 个字符,
  807. // cancelColor: '#000000', //取消按钮的文字颜色,
  808. // confirmText: '确定', //确定按钮的文字,默认为取消,最多 4 个字符,
  809. // confirmColor: '#3CC51F', //确定按钮的文字颜色,
  810. // success: res => {}
  811. // });
  812. this.mapHeight = screenHeight - tarBarHeight - foldPanelPXHeight; // 相当于加入底部空白,让面板被顶起来
  813. });
  814. },
  815. onScale(e) {
  816. this.touchScale = e.$wx.detail.scale;
  817. },
  818. // 下面面板折叠起来的逻辑
  819. foldPanelFun() {
  820. this.getMapHeight().then(res => {
  821. this.mapHeight = res.mapHeight;
  822. this.y = 0;
  823. });
  824. if (this.foldStatus === 'expand') {
  825. this.foldStatus = 'fold';
  826. }
  827. },
  828. toSearchPage() {
  829. console.log('被点击了');
  830. wx.navigateTo({
  831. url: `/packagesEnv/pages/search/index`
  832. });
  833. },
  834. goBack() {
  835. wx.navigateBack({
  836. delta: 1 // 返回的页面数,如果 delta 大于现有页面数,则返回到首页,
  837. });
  838. },
  839. getfoldPanelPXHeight() {
  840. if (
  841. foldPanelPXHeight &&
  842. screenInfo &&
  843. screenInfo.screenWidth &&
  844. screenInfo.screenHeight
  845. ) {
  846. return Promise.resolve({
  847. foldPanelPXHeight,
  848. screenWidth: screenInfo.screenWidth,
  849. screenHeight: screenInfo.screenHeight
  850. });
  851. }
  852. return getScreenInfo().then(res => {
  853. let foldHeight =
  854. from == 'officehome' ? switchPanelHeight : panelFoldHeight;
  855. // foldPanelPXHeight = parseInt(res.screenScale * foldHeight);
  856. foldPanelPXHeight = parseInt(foldHeight);
  857. return {
  858. screenWidth: res.screenWidth,
  859. screenHeight: res.screenHeight,
  860. foldPanelPXHeight
  861. };
  862. });
  863. },
  864. getMapHeight() {
  865. return this.getfoldPanelPXHeight().then(res => {
  866. let mapHeight = res.screenHeight - tarBarHeight - res.foldPanelPXHeight;
  867. return {
  868. ...res,
  869. mapHeight
  870. };
  871. });
  872. },
  873. getMapScale() {
  874. return this.getMapHeight().then(res => {
  875. mapScale = Math.floor((res.mapHeight / standerMapHeight) * 10) / 10;
  876. return {
  877. ...res,
  878. mapScale
  879. };
  880. });
  881. }
  882. }
  883. });
  884. function getScreenInfo() {
  885. if (
  886. screenScale &&
  887. screenInfo &&
  888. screenInfo.screenWidth &&
  889. screenInfo.screenHeight
  890. ) {
  891. return Promise.resolve({
  892. ...screenInfo,
  893. screenScale
  894. });
  895. }
  896. return new Promise((resolve, reject) => {
  897. wx.getSystemInfo({
  898. success: res => {
  899. screenInfo.screenHeight = res.screenHeight;
  900. screenInfo.screenWidth = res.screenWidth;
  901. screenScale = res.screenWidth / standerScreenWidth;
  902. resolve({
  903. screenWidth: res.screenWidth,
  904. screenHeight: res.screenHeight,
  905. screenScale
  906. });
  907. }
  908. });
  909. });
  910. }
  911. function getExpandPXHeight() {
  912. if (
  913. expandPXHeight &&
  914. screenInfo &&
  915. screenInfo.screenWidth &&
  916. screenInfo.screenHeight
  917. ) {
  918. return Promise.resolve({
  919. expandPXHeight,
  920. screenWidth: screenInfo.screenWidth,
  921. screenHeight: screenInfo.screenHeight
  922. });
  923. }
  924. return getScreenInfo().then(res => {
  925. expandPXHeight = parseInt(res.screenScale * panelExpandHeight);
  926. return {
  927. screenWidth: res.screenWidth,
  928. screenHeight: res.screenHeight,
  929. expandPXHeight
  930. };
  931. });
  932. }
  933. </script>
  934. <config>
  935. {
  936. "navigationBarBackgroundColor": "#EBEEF5",
  937. "backgroundColor": "#EBEEF5",
  938. "disableScroll": true,
  939. "usingComponents": {
  940. "control-panel": "./components/controlpanel/controlpanel",
  941. "temperture-control-panel": "./components/temperturecontrolpanel/temperturecontrolpanel",
  942. "floor": "./components/floor/floor",
  943. "location": "./components/location/location"
  944. }
  945. }
  946. </config>