|
|
@@ -59,10 +59,12 @@
|
|
|
<LightMap
|
|
|
small
|
|
|
:city="currentCity"
|
|
|
+ :cityCode="currentCityCode"
|
|
|
+ :district="currentDistrict"
|
|
|
:lonlat="currentLocation.currentLonlat.value"
|
|
|
@getCurrentLonlat="currentLocation.getCurrentExactLocation"
|
|
|
@selectVillage="handleGoVillageDetails"
|
|
|
- @regionChanged="currentRegion=$event"
|
|
|
+ @changeCity="handleSelectCity"
|
|
|
>
|
|
|
<NoticeBar
|
|
|
v-if="currentNoticeContent"
|
|
|
@@ -134,14 +136,10 @@
|
|
|
</FlexCol>
|
|
|
</Construction> -->
|
|
|
|
|
|
- <HomeTitle title="乡村排名" showMore @moreClicked="navTo('/pages/home/village/rank/village', {
|
|
|
- regionId: currentRegion ?? undefined,
|
|
|
- })" />
|
|
|
+ <HomeTitle title="乡村排名" showMore @moreClicked="navTo('/pages/home/village/rank/village', {})" />
|
|
|
<VillageRankList :list="villageRankListLoader.content.value ?? []" :jumpToSingle="false" @goDetails="handleGoVillageDetails" />
|
|
|
|
|
|
- <HomeTitle title="志愿者排名" showMore :lightCount="3" @moreClicked="navTo('/pages/home/village/rank/volunteer', {
|
|
|
- regionId: currentRegion ?? undefined,
|
|
|
- })" />
|
|
|
+ <HomeTitle title="志愿者排名" showMore :lightCount="3" @moreClicked="navTo('/pages/home/village/rank/volunteer', {})" />
|
|
|
<VillageUserRankList
|
|
|
:list="villageUserRankListLoader.content.value ?? []"
|
|
|
scoreSuffix="积分"
|
|
|
@@ -192,7 +190,7 @@
|
|
|
v-model:show="showCityPopup"
|
|
|
closeable
|
|
|
position="top"
|
|
|
- size="90vh"
|
|
|
+ size="60vh"
|
|
|
>
|
|
|
<CitySelect @selectCity="handleSelectCity" />
|
|
|
</Popup>
|
|
|
@@ -246,7 +244,7 @@ import LightMap from './components/LightMap.vue';
|
|
|
import NoticeBar from '@/components/display/NoticeBar.vue';
|
|
|
import StatusBarSpace from '@/components/layout/space/StatusBarSpace.vue';
|
|
|
import LightVillageApi, { VillageListItem } from '@/api/light/LightVillageApi';
|
|
|
-import type { CityItem } from '@/api/map/MapApi';
|
|
|
+import type { RegionItem } from '@/api/map/RegionApi';
|
|
|
import Width from '@/components/layout/space/Width.vue';
|
|
|
import MasonryGrid from '@/components/layout/masonry/MasonryGrid.vue';
|
|
|
import MasonryGridItem from '@/components/layout/masonry/MasonryGridItem.vue';
|
|
|
@@ -276,17 +274,22 @@ const introClamTipTimeout = new MemoryTimeOut('IntroClamTip', 1000 * 3600 * 30);
|
|
|
const postIndexRef = ref<InstanceType<typeof PostIndex>>();
|
|
|
const appConfiguration = injectAppConfiguration();
|
|
|
|
|
|
-const currentRegion = ref<number | null>(null);
|
|
|
const { value: currentCity } = useStorageVar('currentCityName', '');
|
|
|
+const { value: currentCityCode } = useStorageVar('currentCityCode', 0);
|
|
|
+const { value: currentDistrict } = useStorageVar('currentDistrict', '');
|
|
|
const currentLocation = useGetCurrentLocation({
|
|
|
- onCityChanged: (city) => {
|
|
|
+ onCityChanged: (city, code, district) => {
|
|
|
currentCity.value = city;
|
|
|
+ currentCityCode.value = code;
|
|
|
+ if (!district)
|
|
|
+ console.error('!')
|
|
|
+ currentDistrict.value = district || '';
|
|
|
},
|
|
|
});
|
|
|
const currentNoticeContent = ref('目前厦门市已被点亮一个社区,刚刚小亮贡献了10个光源,让湖里区点亮了一个社区');
|
|
|
|
|
|
const villageRankListLoader = useSimpleDataLoader(async () => {
|
|
|
- const res = await LightVillageApi.getVillageRankList({ region_id: currentRegion.value ?? undefined, num: 3 });
|
|
|
+ const res = await LightVillageApi.getVillageRankList({ num: 3 });
|
|
|
return res.map((item, i) => ({
|
|
|
image: item.image ?? '',
|
|
|
title: item.name,
|
|
|
@@ -295,7 +298,7 @@ const villageRankListLoader = useSimpleDataLoader(async () => {
|
|
|
}));
|
|
|
});
|
|
|
const villageUserRankListLoader = useSimpleDataLoader(async () => {
|
|
|
- const res = (await LightVillageApi.getVolunteerRankList({ region_id: currentRegion.value ?? undefined, num: 3 }))
|
|
|
+ const res = (await LightVillageApi.getVolunteerRankList({ num: 3 }))
|
|
|
.map((item, i) => ({
|
|
|
id: item.id,
|
|
|
image: item.image ?? '',
|
|
|
@@ -341,11 +344,6 @@ const recommendLoader = useSimplePageListLoader(20, async (page, pageSize) => {
|
|
|
return await VillageInfoApi.getListForDiscover(page, pageSize);
|
|
|
}, true);
|
|
|
|
|
|
-watch(currentRegion, async (newVal) => {
|
|
|
- await villageRankListLoader.reload();
|
|
|
- await villageUserRankListLoader.reload();
|
|
|
-});
|
|
|
-
|
|
|
function handleGoRecommendDetails(item: CommonInfoModel) {
|
|
|
navTo(`/pages/home/discover/details`, { id: item.id });
|
|
|
}
|
|
|
@@ -356,24 +354,14 @@ async function handleGoVillageDetails(item: VillageListItem) {
|
|
|
await waitTimeOut(100);
|
|
|
emit('goVillage')
|
|
|
}
|
|
|
-async function handleChangedCity(city: string) {
|
|
|
- currentCity.value = city;
|
|
|
- try {
|
|
|
- const res = (await MapApi.simpleGetRegion(city)).requireData();
|
|
|
- currentLocation.currentLonlat.value = {
|
|
|
- longitude: Number(res.center.split(',')[0]),
|
|
|
- latitude: Number(res.center.split(',')[1]),
|
|
|
- };
|
|
|
- console.log('currentLocation.currentLonlat.value', currentLocation.currentLonlat.value);
|
|
|
- } catch (error) {
|
|
|
- console.error(error);
|
|
|
- return;
|
|
|
- }
|
|
|
-}
|
|
|
-function handleSelectCity(city: CityItem) {
|
|
|
+function handleSelectCity(city: RegionItem) {
|
|
|
currentCity.value = city.name;
|
|
|
+ currentCityCode.value = city.areaCode;
|
|
|
showCityPopup.value = false;
|
|
|
- handleChangedCity(city.name);
|
|
|
+ currentLocation.currentLonlat.value = {
|
|
|
+ longitude: Number(city.longitude),
|
|
|
+ latitude: Number(city.latitude),
|
|
|
+ };
|
|
|
}
|
|
|
function handleGoAI() {
|
|
|
requireLogin(async () => {
|
|
|
@@ -386,7 +374,11 @@ async function handleGoPublish() {
|
|
|
}, '欢迎您发布内容,登录后以便使用更多功能哦!');
|
|
|
}
|
|
|
async function handleLightVillage() {
|
|
|
- requireLogin(async () => navTo('/pages/home/light/submit-map', { city: currentCity.value }), '登录后才能点亮村社哦!');
|
|
|
+ requireLogin(async () => navTo('/pages/home/light/submit-map', {
|
|
|
+ city: currentCity.value,
|
|
|
+ cityCode: currentCityCode.value,
|
|
|
+ district: currentDistrict.value,
|
|
|
+ }), '登录后才能点亮村社哦!');
|
|
|
}
|
|
|
function handleSearch() {
|
|
|
if (!searchKeywords.value) {
|
|
|
@@ -394,7 +386,8 @@ function handleSearch() {
|
|
|
return;
|
|
|
}
|
|
|
navTo('/pages/home/search/index', {
|
|
|
- region: currentRegion.value ?? 0,
|
|
|
+ city: currentCity.value,
|
|
|
+ cityCode: currentCityCode.value,
|
|
|
searchValue: searchKeywords.value,
|
|
|
});
|
|
|
}
|
|
|
@@ -427,6 +420,7 @@ async function loadInfo() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
watch(() => authStore.isLogged, async (newVal) => {
|
|
|
if (newVal) {
|
|
|
await loadInfo();
|
|
|
@@ -436,7 +430,7 @@ watch(() => authStore.isLogged, async (newVal) => {
|
|
|
onMounted(async () => {
|
|
|
try {
|
|
|
if (currentCity.value) {
|
|
|
- await currentLocation.setCurrentLocationWithCity(currentCity.value);
|
|
|
+ await currentLocation.setCurrentLocationWithCity(currentCity.value, currentDistrict.value);
|
|
|
} else {
|
|
|
await currentLocation.getCurrentFuzzyLocation();
|
|
|
}
|
|
|
@@ -446,4 +440,17 @@ onMounted(async () => {
|
|
|
}
|
|
|
await loadInfo();
|
|
|
});
|
|
|
+defineExpose({
|
|
|
+ onPageBack: (name: string, data: Record<string, unknown>) => {
|
|
|
+ if (name === 'changeCurrentCity') {
|
|
|
+ currentCity.value = data.city as string;
|
|
|
+ currentCityCode.value = data.code as number;
|
|
|
+ currentDistrict.value = '';
|
|
|
+ currentLocation.currentLonlat.value = {
|
|
|
+ longitude: Number(data.longitude),
|
|
|
+ latitude: Number(data.latitude),
|
|
|
+ };
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|
|
|
</script>
|