App.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <div id="app">
  3. <div :id="`fengMap${id}`" class="fengMap"></div>
  4. <router-view />
  5. </div>
  6. </template>
  7. <script>
  8. import { mapGetters, mapActions, mapMutations } from "vuex";
  9. import { SFengParser } from "@saga-web/feng-map";
  10. window.fengmap = null;
  11. export default {
  12. data() {
  13. return {
  14. view: "",
  15. scene: "",
  16. id: "2",
  17. canvasID: "",
  18. key: "23f30a832a862c58637a4aadbf50a566",
  19. appName: "万达可视化系统",
  20. mapServerURL: `/wdfn`
  21. };
  22. },
  23. mounted() {
  24. // 监听页面刷新事件
  25. window.addEventListener("unload", this.unload);
  26. // 页面加载完成后,移除session里的存储的信息
  27. window.addEventListener("load", this.load);
  28. // 请求该项目下的楼层数据
  29. this.getFengMap();
  30. },
  31. computed: {
  32. ...mapGetters(["plazaId", "fmapID", "haveFengMap"])
  33. },
  34. methods: {
  35. ...mapActions(["getfmapID"]),
  36. ...mapMutations(["SETHAVEFENGMAP"]),
  37. unload() {
  38. // const { userInfo, projectId, menuStatus,manualAutoMode } = this.$store.state;
  39. const state = this.$store.state;
  40. sessionStorage.setItem("state", JSON.stringify(state));
  41. },
  42. load() {
  43. sessionStorage.clear();
  44. },
  45. getFengMap() {
  46. if (!this.fmapID) {
  47. this.getfmapID().then(() => {
  48. this.getMap();
  49. });
  50. return;
  51. }
  52. this.getMap();
  53. },
  54. getMap() {
  55. if (!window.fengmap) {
  56. window.fengmap = new SFengParser(
  57. `fengMap${this.id}`,
  58. `${this.mapServerURL}/fmap/${this.fmapID}`,
  59. this.key,
  60. this.appName,
  61. null
  62. );
  63. window.fengmap.loadMap(this.fmapID, () => {
  64. // 获取主题数据
  65. window.fengmap
  66. .loadTheme(
  67. `${this.mapServerURL}/webtheme/${this.fmapID}/${this.fmapID}.theme`
  68. )
  69. .then(res => {
  70. console.log("获取rf成功", res);
  71. this.SETHAVEFENGMAP()
  72. });
  73. });
  74. }
  75. }
  76. },
  77. watch: {
  78. haveFengMap(val) {
  79. alert(val);
  80. }
  81. }
  82. };
  83. </script>
  84. <style lang="less">
  85. body,
  86. h1,
  87. h2,
  88. h3,
  89. h4,
  90. h5,
  91. h6,
  92. hr,
  93. p,
  94. blockquote,
  95. dl,
  96. dt,
  97. dd,
  98. ul,
  99. ol,
  100. li,
  101. pre,
  102. form,
  103. fieldset,
  104. legend,
  105. button,
  106. input,
  107. textarea,
  108. th,
  109. td {
  110. margin: 0;
  111. padding: 0;
  112. }
  113. body,
  114. button,
  115. input,
  116. select,
  117. textarea {
  118. font: 12px/1.5 Arial, "Microsoft YaHei", "\65b0\5b8b\4f53";
  119. }
  120. h1,
  121. h2,
  122. h3,
  123. h4,
  124. h5,
  125. h6 {
  126. font-size: 100%;
  127. }
  128. address,
  129. cite,
  130. dfn,
  131. var,
  132. em,
  133. i,
  134. u {
  135. font-style: normal;
  136. }
  137. ol,
  138. ul {
  139. list-style: none;
  140. }
  141. a {
  142. text-decoration: none;
  143. }
  144. a:hover {
  145. text-decoration: underline;
  146. }
  147. img {
  148. border: none;
  149. vertical-align: middle;
  150. }
  151. :focus {
  152. outline: 0;
  153. }
  154. button,
  155. input,
  156. select,
  157. textarea {
  158. font-size: 100%;
  159. }
  160. table {
  161. border-collapse: collapse;
  162. border-spacing: 0;
  163. }
  164. /* 滚动条样式 */
  165. body ::-webkit-scrollbar {
  166. width: 5px;
  167. height: 5px;
  168. }
  169. body ::-webkit-scrollbar-track {
  170. background-color: rgba(0, 0, 0, 0);
  171. border-radius: 3px;
  172. }
  173. body ::-webkit-scrollbar-thumb {
  174. border-radius: 3px;
  175. background: #e6e6e6;
  176. border: 1px solid #e6e6e6;
  177. }
  178. body ::-webkit-scrollbar-thumb:vertical:hover {
  179. background: #e6e6e6;
  180. border: 1px solid #e6e6e6;
  181. }
  182. .clearfix::after {
  183. content: ".";
  184. display: block;
  185. height: 0;
  186. clear: both;
  187. visibility: hidden;
  188. }
  189. .clearfix {
  190. zoom: 1;
  191. }
  192. .left {
  193. float: left;
  194. }
  195. .right {
  196. float: right;
  197. }
  198. html,
  199. body {
  200. width: 100%;
  201. height: 100%;
  202. // min-width: 1920px;
  203. // background: url('./assets/images/back.jpg') no-repeat;
  204. }
  205. #app {
  206. height: 100%;
  207. width: 100%;
  208. position: relative;
  209. .fengMap {
  210. position: fixed;
  211. width: 100px;
  212. height: 100px;
  213. z-index: -1;
  214. opacity: 0
  215. }
  216. }
  217. </style>