transportationSafetyCenter.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292
  1. <template>
  2. <div style="position: relative">
  3. <div id="bmap"></div>
  4. <ShipSearch
  5. class="ship-search z20"
  6. :api="'searchShipSelect'"
  7. v-model="shipStr"
  8. @selectItem="selectShip"
  9. style="position: absolute; top: 40px; right: 524px"
  10. ></ShipSearch>
  11. <NumberVue
  12. class="z20"
  13. v-if="this.$store.state.currentTabText != '环境中心'"
  14. :data="this.$store.state.numbers"
  15. style="position: absolute; top: 0; left: 0"
  16. ></NumberVue>
  17. <SafetyModule
  18. class="z20"
  19. v-if="this.$store.state.currentTabText == '运输安全管理中心'"
  20. style="position: absolute; top: 24px; right: 34px"
  21. ></SafetyModule>
  22. <IntelligentModule
  23. class="z20"
  24. v-if="this.$store.state.currentTabText == '智能交易中心'"
  25. style="position: absolute; top: 24px; right: 34px"
  26. ></IntelligentModule>
  27. <EnvironmentalModule
  28. class="z20"
  29. v-if="this.$store.state.currentTabText == '环境中心'"
  30. style="position: absolute; top: 24px; right: 34px"
  31. ></EnvironmentalModule>
  32. <Warning
  33. class="z20"
  34. v-if="this.$store.state.currentTabText == '环境中心'"
  35. style="position: absolute; top: 40px; left: 20px; right: 744px"
  36. ></Warning>
  37. <div class="mask"></div>
  38. </div>
  39. </template>
  40. <script>
  41. import ShipSearch from "comps/ShipSearch.vue";
  42. import router from "router/index";
  43. import store from "store/index";
  44. import api from "apis/fetch";
  45. import { ref, onMounted, watch } from "vue";
  46. export default {
  47. components: {
  48. ShipSearch,
  49. },
  50. setup() {
  51. const bmap = ref({});
  52. function initMap() {
  53. bmap.value = new BMapGL.Map("bmap");
  54. bmap.value.setMapStyleV2({
  55. styleId: "fa3f2f79d64ac87e2683cfa762891cb5",
  56. });
  57. bmap.value.centerAndZoom(new BMapGL.Point(120.688612, 31.975529), 11);
  58. bmap.value.enableScrollWheelZoom(true);
  59. cpxOverlay();
  60. }
  61. watch(
  62. () => store.state.currentTabText,
  63. (a, b) => {
  64. store.dispatch("GetNumbers");
  65. }
  66. );
  67. let shipStr = ref("");
  68. function selectShip(item) {
  69. if (store.state.currentTabText == "运输安全管理中心") {
  70. store.dispatch("GetManageShipDetail", item.key);
  71. }
  72. if (store.state.currentTabText == "智能交易中心") {
  73. store.dispatch("GetTradeShipDetail", item.key);
  74. }
  75. }
  76. // 定义复杂覆盖物
  77. function cpxOverlay(
  78. lng = 120.688612,
  79. lat = 31.995529,
  80. shipName = "颖航5156",
  81. mmsi = "413835188",
  82. cargo = "豆粕",
  83. tons = "1565.69",
  84. shipId = "51710"
  85. ) {
  86. console.log("创建自定义覆盖物");
  87. // 复杂的自定义覆盖物
  88. function ComplexCustomOverlay(point) {
  89. this._point = point;
  90. }
  91. ComplexCustomOverlay.prototype = new BMapGL.Overlay();
  92. ComplexCustomOverlay.prototype.addEventListener = function (event, fun) {
  93. this._div["on" + event] = fun;
  94. };
  95. ComplexCustomOverlay.prototype.initialize = function (map) {
  96. this._map = map;
  97. let div = (this._div = document.createElement("div"));
  98. div.style.position = "absolute";
  99. div.style.margin = 0;
  100. div.style.padding = 0;
  101. div.style.zIndex = BMapGL.Overlay.getZIndex(this._point.lat);
  102. div.style.height = "118px";
  103. div.style.width = "270px";
  104. div.style.lineHeight = "18px";
  105. div.style.whiteSpace = "nowrap";
  106. div.style.MozUserSelect = "none";
  107. div.style.fontSize = "12px";
  108. div.style.cursor = "pointer";
  109. function parseDom(arg) {
  110. let objE = document.createElement("div");
  111. objE.innerHTML = arg;
  112. return objE;
  113. }
  114. let content = `
  115. <div
  116. style="
  117. display: flex;
  118. align-items:center;
  119. text-shadow: 0px 0px 5px rgba(100, 185, 255, 0.6);
  120. "
  121. >
  122. <img
  123. style="
  124. margin: 0px;
  125. padding: 0px;
  126. height: 55px;
  127. width: 55px;
  128. margin-right: 20px;
  129. "
  130. src="https://6875-huihenduo-2gx127w7f837b584-1255802371.tcb.qcloud.la/data-platform/map-ship-icon.png"
  131. alt=""
  132. />
  133. <div
  134. style="
  135. height: 118px;
  136. width: 3px;
  137. box-sizing: border-box;
  138. background: rgb(16, 255, 185);
  139. border: 1px solid rgb(16, 255, 185);
  140. margin-right: 4px;
  141. "
  142. ></div>
  143. <div
  144. style="
  145. padding: 8px 12px;
  146. height: 118px;
  147. width: 191px;
  148. background: rgba(0, 0, 0, 0.6);
  149. text-align: left;
  150. box-sizing: border-box;
  151. "
  152. >
  153. <div
  154. style="
  155. font-size: 18px;
  156. font-family: SourceHanSansSC-Bold, SourceHanSansSC;
  157. font-weight: bold;
  158. color: #10ffb9;
  159. margin-bottom: 2px;
  160. "
  161. >
  162. ${shipName}
  163. </div>
  164. <div
  165. style="
  166. font-size: 10px;
  167. font-family: SourceHanSansSC-Medium, SourceHanSansSC;
  168. font-weight: 500;
  169. color: #fafeff;
  170. margin-bottom: 14px;
  171. "
  172. >
  173. MMSI: ${mmsi}
  174. </div>
  175. <div
  176. style="
  177. display: flex;
  178. font-size: 20px;
  179. font-family: DINAlternate-Bold, DINAlternate;
  180. font-weight: bold;
  181. color: #ffffff;
  182. "
  183. >
  184. <div style="margin-right: 35px">
  185. <div style="margin-bottom: 3px; height: 28px">${cargo}</div>
  186. <div
  187. style="
  188. font-size: 14px;
  189. font-family: SourceHanSansSC-Normal, SourceHanSansSC;
  190. font-weight: 400;
  191. color: #92afc7;
  192. "
  193. >
  194. 货种
  195. </div>
  196. </div>
  197. <div>
  198. <div
  199. style="
  200. margin-bottom: 3px;
  201. height: 28px;
  202. line-height:22px
  203. "
  204. >
  205. ${tons}
  206. <span style="display: inline-block; font-size: 16px"
  207. >吨</span
  208. >
  209. </div>
  210. <div
  211. style="
  212. font-size: 14px;
  213. font-family: SourceHanSansSC-Normal, SourceHanSansSC;
  214. font-weight: 400;
  215. color: #92afc7;
  216. "
  217. >
  218. 吨位
  219. </div>
  220. </div>
  221. </div>
  222. </div>
  223. </div>
  224. `;
  225. let contain = parseDom(content);
  226. div.addEventListener("click", function () {
  227. console.log("shipId", shipId);
  228. selectShip({ key: shipId });
  229. });
  230. div.appendChild(contain);
  231. bmap.value.getPanes().labelPane.appendChild(div);
  232. return div;
  233. };
  234. ComplexCustomOverlay.prototype.draw = function () {
  235. let map = this._map;
  236. let pixel = map.pointToOverlayPixel(this._point);
  237. this._div.style.left = pixel.x - 30 + "px";
  238. this._div.style.top = pixel.y - 65 + "px";
  239. };
  240. let myCompOverlay = new ComplexCustomOverlay(new BMapGL.Point(lng, lat));
  241. bmap.value.addOverlay(myCompOverlay);
  242. }
  243. onMounted(() => {
  244. initMap();
  245. // store.dispatch("GetManageShipDetail", 51710);
  246. // store.dispatch("GetTradeShipDetail", 51710);
  247. store.dispatch("GetNumbers");
  248. });
  249. return {
  250. initMap,
  251. shipStr,
  252. selectShip,
  253. };
  254. },
  255. };
  256. </script>
  257. <style lang="scss" scoped>
  258. #bmap {
  259. width: 100%;
  260. height: calc(100vh - 60px);
  261. box-sizing: border-box;
  262. background: #1d2c43;
  263. border-top: 1px solid grey;
  264. }
  265. :deep(.ship-search) {
  266. .el-input__inner {
  267. background: none;
  268. color: #fff;
  269. }
  270. }
  271. .mask {
  272. position: fixed;
  273. top: 60px;
  274. left: 0;
  275. right: 0;
  276. bottom: 0;
  277. z-index: 8;
  278. pointer-events: none;
  279. background-image: radial-gradient(ellipse, #213e5f, #0f1d2e);
  280. opacity: 0.35;
  281. }
  282. </style>