mapFacilitiesView.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <web-view
  3. id="amapView"
  4. ref="amapView"
  5. src="/static/amap/mapFacilitiesView.html"
  6. bindmessage="receiveMessage"
  7. :webview-styles="{
  8. height: proxy.$settingStore.webViewHeight,
  9. }"
  10. @message="onMessage"
  11. ></web-view>
  12. </template>
  13. <script setup>
  14. import { onReady, onLoad, onShow, onNavigationBarButtonTap } from "@dcloudio/uni-app";
  15. import { ref, onMounted, inject, shallowRef, reactive, getCurrentInstance, toRefs, nextTick } from "vue";
  16. import { useStores, commonStores } from "@/store/modules/index";
  17. import { baseFacilityType, baseGgpFacilityList } from "@/api/business/fireIot/facilitiesManage.js";
  18. const commonStore = commonStores(); //全局公共Store
  19. const { proxy } = getCurrentInstance();
  20. const dataArray = ref();
  21. const typeCode = ref("");
  22. /**
  23. * @初始化
  24. */
  25. function init() {
  26. handleSelectApi();
  27. }
  28. /**
  29. * @设施地图列表查询
  30. * @api接口查询
  31. */
  32. function handleSelectApi() {
  33. baseFacilityType({
  34. pageNum: 1,
  35. pageSize: 20000,
  36. }).then((requset) => {
  37. if (requset.status === "SUCCESS") {
  38. if (requset.data.length > 0) {
  39. setTimeout(() => {
  40. var message = {
  41. funcName: "初始化",
  42. param: JSON.stringify(requset.data[0]),
  43. };
  44. handleChildren(message);
  45. }, 1000);
  46. }
  47. }
  48. });
  49. }
  50. /**
  51. * @撒点查询
  52. * @api接口查询
  53. */
  54. function handleMarkerApi(param) {
  55. baseGgpFacilityList({
  56. facilityType: param,
  57. }).then((requset) => {
  58. if (requset.status === "SUCCESS") {
  59. var message = {
  60. funcName: "撒点",
  61. param: JSON.stringify(requset.data),
  62. };
  63. handleChildren(message);
  64. }
  65. });
  66. }
  67. /**
  68. * @解析父页面传回的数据
  69. */
  70. function analysisData(data) {
  71. if ("funcName" in data) {
  72. if (data.funcName == "撒点") {
  73. var param = data.param.split(",");
  74. handleMarkerApi(param);
  75. }
  76. }
  77. }
  78. /**
  79. * @向子页面发送数据
  80. */
  81. function handleChildren(data) {
  82. // #ifdef APP-PLUS
  83. var pages = getCurrentPages();
  84. var currentWebview = pages[pages.length - 1].$getAppWebview();
  85. var wv = currentWebview.children()[0];
  86. wv.evalJS(`receiveData(${JSON.stringify(data)})`);
  87. // #endif
  88. // #ifdef H5
  89. var iframe = document.getElementById("amapView");
  90. iframe.contentWindow.postMessage(data, "*");
  91. // #endif
  92. }
  93. /**
  94. * @接收子页面传过来的值
  95. */
  96. function onMessage(e) {
  97. analysisData(e.detail.data[0]);
  98. }
  99. // #ifdef H5
  100. window.onmessage = function (event) {
  101. analysisData(event.data);
  102. };
  103. // #endif
  104. onLoad((options) => {
  105. if ("typeCode" in options) {
  106. typeCode.value = options.typeCode;
  107. init();
  108. }
  109. });
  110. onShow(() => {
  111. //调用系统主题颜色
  112. proxy.$settingStore.systemThemeColor([1]);
  113. });
  114. onReady(() => {});
  115. </script>