|
|
@@ -65,22 +65,29 @@
|
|
|
<Icon name="https://xy.wenlvti.net/app_static/images/village/IconMap.png" size="fontSize.md" />
|
|
|
<Text :text="villageInfoLoader.content.value?.address" fontConfig="contentText" />
|
|
|
</FlexRow>
|
|
|
- <VillageMiniMap />
|
|
|
+ <VillageMiniMap
|
|
|
+ v-if="villageInfoLoader.content.value"
|
|
|
+ :lonlat="{
|
|
|
+ longitude: villageInfoLoader.content.value.longitude,
|
|
|
+ latitude: villageInfoLoader.content.value.latitude
|
|
|
+ }"
|
|
|
+ />
|
|
|
|
|
|
<FlexRow center gap="gap.lg">
|
|
|
<Button
|
|
|
icon="https://xy.wenlvti.net/app_static/images/village/IconJoin.png"
|
|
|
radius="radius.lgr"
|
|
|
size="large"
|
|
|
- :innerStyle="{ flexBasis: '20%' }"
|
|
|
+ :innerStyle="{ flexBasis: '25%' }"
|
|
|
+ @click="isFollowed ? onUnFollow() : onFollow()"
|
|
|
>
|
|
|
- 关注
|
|
|
+ {{ isFollowed ? '已关注' : '关注' }}
|
|
|
</Button>
|
|
|
<Button
|
|
|
icon="https://xy.wenlvti.net/app_static/images/village/IconFollow.png"
|
|
|
size="large"
|
|
|
radius="radius.lgr"
|
|
|
- :innerStyle="{ flexBasis: '20%' }"
|
|
|
+ :innerStyle="{ flexBasis: '25%' }"
|
|
|
>
|
|
|
加入
|
|
|
</Button>
|
|
|
@@ -197,7 +204,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
-import { ref } from 'vue';
|
|
|
+import { computed, ref, watch } from 'vue';
|
|
|
import HomeTitle from '@/common/components/parts/HomeTitle.vue';
|
|
|
import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
|
|
|
import Button from '@/components/basic/Button.vue';
|
|
|
@@ -219,31 +226,75 @@ import GridItem from '@/components/layout/grid/GridItem.vue';
|
|
|
import MasonryGrid from '@/components/layout/masonry/MasonryGrid.vue';
|
|
|
import MasonryGridItem from '@/components/layout/masonry/MasonryGridItem.vue';
|
|
|
import IndexCommonImageItem from '@/common/components/parts/IndexCommonImageItem.vue';
|
|
|
+import { useVillageStore } from '@/store/village';
|
|
|
+import FollowVillageApi from '@/api/light/FollowVillageApi';
|
|
|
+import { confirm, toast } from '@/components/utils/DialogAction';
|
|
|
|
|
|
+const villageStore = useVillageStore();
|
|
|
const villageInfoLoader = useSimpleDataLoader(async () => {
|
|
|
+ const village = villageStore.currentVillage;
|
|
|
return {
|
|
|
- title: '高点社区',
|
|
|
- desc: '',
|
|
|
- address: '福建省厦门市同安区高浦社区',
|
|
|
- applyCount: 100,
|
|
|
- levelText: '一级',
|
|
|
- rankText: '1',
|
|
|
- light: 0,
|
|
|
- memberCount: 0,
|
|
|
- followerCount: 0,
|
|
|
- images: [
|
|
|
- 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest1.jpg',
|
|
|
- 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest2.jpg',
|
|
|
- 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest3.jpg',
|
|
|
- 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest4.jpg',
|
|
|
- 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest5.jpg',
|
|
|
- ],
|
|
|
+ title: village?.villageName || '',
|
|
|
+ desc: village?.desc || '',
|
|
|
+ address: village?.address,
|
|
|
+ applyCount: village?.applyCount || 0,
|
|
|
+ levelText: village?.levelText as string || '',
|
|
|
+ rankText: village?.rankText as string || '',
|
|
|
+ light: village?.light as number || 0,
|
|
|
+ memberCount: village?.memberCount as number || 0,
|
|
|
+ followerCount: village?.followerCount as number || 0,
|
|
|
+ images: village?.images || [],
|
|
|
+ longitude: village?.longitude as number || 0,
|
|
|
+ latitude: village?.latitude as number || 0,
|
|
|
};
|
|
|
});
|
|
|
|
|
|
+watch(() => villageStore.currentVillage, () => {
|
|
|
+ villageInfoLoader.reload();
|
|
|
+ recommendLoader.reload();
|
|
|
+
|
|
|
+});
|
|
|
+
|
|
|
const rankActiveTag = ref('乡源果');
|
|
|
const listActiveTag = ref('广场');
|
|
|
|
|
|
+const isFollowed = computed(() => {
|
|
|
+ return villageStore.myFollowVillages.some(p => p.id === villageStore.currentVillage?.id);
|
|
|
+});
|
|
|
+const isJoined = computed(() => {
|
|
|
+ return false;
|
|
|
+});
|
|
|
+
|
|
|
+async function onFollow() {
|
|
|
+ if (!villageStore.currentVillage) return;
|
|
|
+ try {
|
|
|
+ await FollowVillageApi.followVillage(villageStore.currentVillage.id);
|
|
|
+ villageStore.myFollowVillages.push(villageStore.currentVillage);
|
|
|
+ toast('关注成功');
|
|
|
+ } catch {
|
|
|
+ toast('关注失败');
|
|
|
+ }
|
|
|
+}
|
|
|
+function onUnFollow() {
|
|
|
+ if (!villageStore.currentVillage) return;
|
|
|
+ confirm({
|
|
|
+ title: '取消关注',
|
|
|
+ content: '确定取消关注该村庄吗?',
|
|
|
+ confirmText: '取消关注',
|
|
|
+ cancelText: '取消',
|
|
|
+ }).then(async (res) => {
|
|
|
+ if (res) {
|
|
|
+ try {
|
|
|
+ await FollowVillageApi.unfollowVillage(villageStore.currentVillage!.id);
|
|
|
+ villageStore.myFollowVillages = villageStore.myFollowVillages.filter(p => p.id !== villageStore.currentVillage!.id);
|
|
|
+ toast('取消关注成功');
|
|
|
+ } catch {
|
|
|
+ toast('取消关注失败');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
const recommendLoader = useSimpleDataLoader(async () => {
|
|
|
return [
|
|
|
{
|