submit-map.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <script setup lang="ts">
  2. import { ref } from 'vue';
  3. import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
  4. import { useGetCurrentLocation } from '../composeabe/GetCurrentLocation';
  5. import { backAndCallOnPageBack, callPrevOnPageBack, navTo } from '@/components/utils/PageAction';
  6. import AppCofig from '@/common/config/AppCofig';
  7. import LightMap from '../components/LightMap.vue';
  8. import FlexCol from '@/components/layout/FlexCol.vue';
  9. import StatusBarSpace from '@/components/layout/space/StatusBarSpace.vue';
  10. import NavBar from '@/components/nav/NavBar.vue';
  11. import FlexRow from '@/components/layout/FlexRow.vue';
  12. import Text from '@/components/basic/Text.vue';
  13. import Image from '@/components/basic/Image.vue';
  14. import BoxMid from '@/common/components/box/BoxMid.vue';
  15. import JoinDialog from '../village/dialogs/JoinDialog.vue';
  16. import CitySelect from '../components/CitySelect.vue';
  17. import Popup from '@/components/dialog/Popup.vue';
  18. import FrameButton from '@/common/components/FrameButton.vue';
  19. import type { RegionItem } from '@/api/map/RegionApi';
  20. const { querys } = useLoadQuerys({
  21. latitude: AppCofig.defaultLonLat[1],
  22. longitude: AppCofig.defaultLonLat[0],
  23. city: '',
  24. cityCode: 0,
  25. district: '',
  26. }, async (querys) => {
  27. currentLocation.setCurrentLocationWithCity(querys.city, querys.district);
  28. currentCity.value = querys.city;
  29. currentCityCode.value = querys.cityCode;
  30. currentDistrict.value = querys.district;
  31. });
  32. const currentLocation = useGetCurrentLocation({
  33. onCityChanged: () => {},
  34. });
  35. const joinDialog = ref<InstanceType<typeof JoinDialog>>();
  36. const joinCurrentVillageId = ref(0);
  37. function handleLightVillage(villageId: number) {
  38. joinCurrentVillageId.value = villageId;
  39. joinDialog.value?.show();
  40. }
  41. function handleJoinFinish() {
  42. backAndCallOnPageBack('goVillage', { id: joinCurrentVillageId.value });
  43. joinCurrentVillageId.value = 0;
  44. }
  45. const showCityPopup = ref(false);
  46. const currentCity = ref('');
  47. const currentCityCode = ref(0);
  48. const currentDistrict = ref('');
  49. const lightMap = ref<InstanceType<typeof LightMap>>();
  50. function handleSelectCity(city: RegionItem) {
  51. currentLocation.setCurrentLocationWithCity(city.name, '');
  52. currentCity.value = city.name;
  53. currentCityCode.value = city.areaCode;
  54. showCityPopup.value = false;
  55. setTimeout(() => {
  56. callPrevOnPageBack('changeCurrentCity', {
  57. city,
  58. code: city.areaCode,
  59. longitude: Number(city.longitude),
  60. latitude: Number(city.latitude),
  61. })
  62. }, 2000);
  63. }
  64. defineExpose({
  65. onPageBack(name: string, params: any) {
  66. if (name === 'joinVillage') {
  67. if (params.createdNew) {
  68. }
  69. if (params.reselectAddress) {
  70. currentLocation.setCurrentLocationWithCity(params.reselectAddress.city, params.reselectAddress.district);
  71. currentCity.value = params.reselectAddress.city;
  72. currentCityCode.value = params.reselectAddress.cityCode;
  73. currentDistrict.value = params.reselectAddress.district;
  74. setTimeout(() => {
  75. callPrevOnPageBack('changeCurrentCity', {
  76. city: params.reselectAddress.city,
  77. code: params.reselectAddress.cityCode,
  78. longitude: Number(params.reselectAddress.cityLongitude),
  79. latitude: Number(params.reselectAddress.cityLatitude),
  80. })
  81. }, 2000);
  82. }
  83. joinCurrentVillageId.value = params.id;
  84. joinDialog.value?.show();
  85. }
  86. }
  87. })
  88. </script>
  89. <template>
  90. <FlexCol position="absolute" :top="0" :left="0" :right="0" :zIndex="1000">
  91. <StatusBarSpace />
  92. <NavBar leftButton="back" />
  93. <FlexRow center>
  94. <BoxMid
  95. :innerStyle="{
  96. width: '670rpx',
  97. }"
  98. direction="column"
  99. align="center"
  100. gap="gap.md"
  101. >
  102. <FlexCol center>
  103. <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="220" mode="widthFix" />
  104. <Text text="请选择您要点亮的村社" fontConfig="primaryTitle" />
  105. </FlexCol>
  106. <FlexRow gap="gap.md">
  107. <FrameButton size="small" icon="search" text="点击搜索" @click="lightMap?.showSearch()" />
  108. <FrameButton size="small" icon="home-filling" text="没有我的家乡?点这里建村" @click="navTo('/pages/home/light/create-village')" />
  109. </FlexRow>
  110. </BoxMid>
  111. </FlexRow>
  112. </FlexCol>
  113. <JoinDialog
  114. ref="joinDialog"
  115. :villageId="joinCurrentVillageId"
  116. @finish="handleJoinFinish"
  117. />
  118. <LightMap
  119. ref="lightMap"
  120. full
  121. :city="currentCity"
  122. :cityCode="currentCityCode"
  123. :district="currentDistrict"
  124. :lonlat="currentLocation.currentLonlat.value"
  125. :isLightMode="true"
  126. @lightVillage="handleLightVillage"
  127. @getCurrentLonlat="currentLocation.getCurrentExactLocation"
  128. @changeCity="showCityPopup=true"
  129. />
  130. <Popup
  131. v-model:show="showCityPopup"
  132. closeable
  133. position="bottom"
  134. size="60vh"
  135. >
  136. <CitySelect @selectCity="handleSelectCity" />
  137. </Popup>
  138. </template>