eventInteraction.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import { defineStore } from "pinia";
  2. import { ref, watch } from "vue";
  3. import { useCommonStore } from "./common";
  4. import {
  5. changeStreet,
  6. handleCaseRelPoints,
  7. handleDangerStatistic,
  8. handleJtlxPoints,
  9. initDistrict
  10. } from "@/utils/map/baseMethod.js";
  11. import {addMyGraphByData_TJ, changeMapType, createMap} from "@/utils/map/AddLayer.js";
  12. export const useEventInteractionStore = defineStore("eventInteractionStore", () => {
  13. const commonStore = useCommonStore();
  14. //地图区分上海、全国、全球
  15. const mapType = ref("shanghai");
  16. //区县选择
  17. const selectDistrict = ref("");
  18. //地图层级scale
  19. const currentMapScale = ref(0);
  20. //是否打开风险统计
  21. const isDangerStatistic = ref(false);
  22. //是否打开病例撒点
  23. const isCaseShow = ref(false);
  24. watch(
  25. () => commonStore.activeIndex,
  26. (val) => {
  27. // isDangerStatistic.value = val === 0
  28. }
  29. );
  30. watch(
  31. () => mapType.value,
  32. (val) => {
  33. if(val === "shanghai"){
  34. createMap()
  35. }else{
  36. changeMapType(val)
  37. }
  38. }
  39. )
  40. watch(
  41. () => isDangerStatistic.value,
  42. (val) => {
  43. handleDangerStatistic(currentMapScale.value < 90000, val)
  44. }
  45. )
  46. watch(
  47. () => currentMapScale.value,
  48. (newValue,oldValue) => {
  49. // console.log(newValue,oldValue);
  50. if(commonStore.activeIndex === 0){
  51. if(isDangerStatistic.value){
  52. if(oldValue > 90000 && newValue <= 90000){
  53. handleDangerStatistic(true, true)
  54. }
  55. if(oldValue < 90000 && newValue >= 90000){
  56. handleDangerStatistic(false, true)
  57. }
  58. }
  59. }
  60. if(isCaseShow.value){
  61. if(oldValue > 140000 && newValue <= 140000){
  62. handleCaseRelPoints(true)
  63. handleJtlxPoints(false)
  64. }
  65. if(oldValue < 140000 && newValue >= 140000){
  66. handleCaseRelPoints(false)
  67. handleJtlxPoints(true)
  68. }
  69. }
  70. }
  71. )
  72. watch(
  73. () => selectDistrict.value,
  74. (val) => {
  75. console.log(val);
  76. if(commonStore.activeIndex === 0){
  77. if(val){
  78. // isDangerStatistic.value = false
  79. changeStreet(val, true, true)
  80. }else {
  81. // isDangerStatistic.value = true
  82. initDistrict()
  83. }
  84. }
  85. }
  86. )
  87. return {
  88. mapType,
  89. selectDistrict,
  90. currentMapScale,
  91. isDangerStatistic,
  92. isCaseShow
  93. };
  94. });