Преглед на файлове

🎨 优化村社首页和增加附近村社功能

快乐的梦鱼 преди 1 месец
родител
ревизия
3f25eb80f9
променени са 5 файла, в които са добавени 36 реда и са изтрити 20 реда
  1. 1 1
      src/pages/home/components/LightMap.vue
  2. 3 0
      src/pages/home/index.vue
  3. 13 15
      src/pages/home/village/index.vue
  4. 4 2
      src/pages/home/village/introd/card.vue
  5. 15 2
      src/pages/index.vue

+ 1 - 1
src/pages/home/components/LightMap.vue

@@ -446,7 +446,7 @@ onMounted(async () => {
   mapCtx.initMarkerCluster({
     enableDefaultStyle: false,
     zoomOnClick: true,
-    gridSize: props.small ? 10 : 35,
+    gridSize: props.small ? 25 : 50,
   });
   mapCtx.on('markerClusterCreate', (e: { clusters: any[] }) => {
     const customClusters = e.clusters.map((cluster) => {

+ 3 - 0
src/pages/home/index.vue

@@ -464,6 +464,9 @@ onMounted(async () => {
   }
 });
 defineExpose({
+  goMap() {
+    handleGoMap();
+  },
   onPageBack: (name: string, data: Record<string, unknown>) => {
     if (name === 'changeCurrentCity') {
       currentCity.value = data.city as string;

+ 13 - 15
src/pages/home/village/index.vue

@@ -15,22 +15,23 @@
           <Button
             icon="https://xy.wenlvti.net/app_static/images/home/IconSwitch.png"
             :text="villageStore.currentVillage?.name || '未选择村社'"
-            :textColor="topTab === 'village' ? 'text.titleLight' : 'text.content'"
+            textColor="text.titleLight"
             size="medium"
             @click="showMyFollowPopup = true"
           />
         </BubbleTip>
         <Button
-          :textColor="topTab === 'around' ? 'text.titleLight' : 'text.content'"
-          text="优秀村社" 
+          icon="map"
+          textColor="text.content"
+          text="周边村社" 
           size="medium"
-          @click="topTab = 'around'" 
+          @click="handleGoAround" 
         />
       </FlexRow>
     </FlexCol>
     <Height :height="40" />
     <template v-if="delayShow">
-      <FlexCol v-if="topTab === 'village' && villageStore.currentVillage" gap="gap.md">
+      <FlexCol v-if="villageStore.currentVillage" gap="gap.md">
         <FlexRow center :padding="[0,30]">
           <HomeLargeTitle title="村社名片" :active="tab === 'card'" @click="tab = 'card'" />
           <Width :width="30" />
@@ -53,7 +54,7 @@
         />
         <Height :height="150" />
       </FlexCol>
-      <FlexCol v-else-if="topTab === 'village'" gap="gap.md">
+      <FlexCol v-else gap="gap.md">
         <FlexCol center :padding="[60,0]" gap="gap.md">
           <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="320" mode="widthFix" />
           <Text text="还未选择一个村社" fontConfig="primaryTitle" />
@@ -62,6 +63,7 @@
           <Height :height="20" />
           <FlexRow gap="gap.lg">
             <FrameButton text="去认领村社" @click="handleGoSuscribe" primary />
+            <FrameButton text="查看附近村社" @click="handleGoAround" />
           </FlexRow>
         </FlexCol>
         <Around
@@ -69,10 +71,6 @@
           @selectVillage="onSelectVillage" 
         />
       </FlexCol>
-      <Around 
-        v-else 
-        @selectVillage="onSelectVillage" 
-      />
     </template>
     <LoadingPage v-else />
     <Height :height="200" />
@@ -124,8 +122,8 @@ import MemoryTimeOut from '@/components/composeabe/MemoryTimeOut';
 import LoadingPage from '@/components/display/loading/LoadingPage.vue';
 import { navTo } from '@/components/utils/PageAction';
 import { useRequireLogin } from '@/common/composeabe/RequireLogin';
+import { useStorageVar } from '@/components/composeabe/StorageVar';
 
-const topTab = ref<'village' | 'around'>('village');
 const tab = ref('card');
 const delayShow = ref(false);
 const delayShowAround = ref(false);
@@ -144,7 +142,7 @@ const props = withDefaults(defineProps<{
 }>(), {
   showSwitch: false,
 });
-const emit = defineEmits(['goHome']);
+const emit = defineEmits(['goHome', 'goMap']);
 
 const showFollowTipTimeout = new MemoryTimeOut('FollowTip', 1000 * 3600 * 30);//30h
 const showFollowTip = ref(false);
@@ -163,17 +161,17 @@ function handleCloseFollowTip(open: boolean) {
 function handleGoSuscribe() {
   requireLogin(() => navTo('/pages/home/light/create-village'), '登录后才能加入村社哦');
 }
+function handleGoAround() {
+  emit('goMap')
+}
 
 function onSelectVillage(village: VillageListItem) {
-  topTab.value = 'village';
   villageStore.setCurrentVillage(village);
   uni.pageScrollTo({ scrollTop: 0 });
   showMyFollowPopup.value = false;
 }
 
 watch(() => villageStore.currentVillage?.id, (newVal) => {
-  if (newVal && topTab.value === 'around')
-    topTab.value = 'village';
   tab.value = 'card';
   handleTestGoTree();
   handleShowFollowTip();

+ 4 - 2
src/pages/home/village/introd/card.vue

@@ -104,7 +104,8 @@
         <FlexRow align="center">
           <FlexCol gap="gap.md"> 
             <Text :text="`${villageInfoLoader.content.value?.levelText || '默认级别'}`" fontConfig="secondText" />  
-            <Text :text="`存储空间:${villageInfoLoader.content.value?.sizeText || ''}`" :fontSize="22" fontConfig="secondText" />
+            <Text v-if="villageInfoLoader.content.value?.sizeLimit" :text="`存储空间:${villageInfoLoader.content.value?.sizeText || ''}`" :fontSize="22" fontConfig="secondText" />
+            <Text v-else text="无限存储空间" :fontSize="22" fontConfig="secondText" />
           </FlexCol>
         </FlexRow>
         <FlexRow align="center" gap="gap.md">
@@ -452,7 +453,8 @@ const villageInfoLoader = useSimpleDataLoader(async () => {
     title: village?.name || '',
     desc: village?.desc || '',
     address: village?.address,
-    sizeText: `${FormatUtils.formatSize(village?.storageUsed || 0)}已用/${FormatUtils.formatSize(village?.storageLimit || 0)}`,
+    sizeText: `${FormatUtils.formatSize(village?.storageUsed || 0)}/${FormatUtils.formatSize(village?.storageLimit || 0)}`,
+    sizeLimit: (village?.storageLimit || 0) >= 0,
     level: village?.level.toString() || '',
     levelText: village?.levelText || '',
     rankText: village?.rank.toString() || '',

+ 15 - 2
src/pages/index.vue

@@ -17,8 +17,20 @@
         align="left"
         :zIndex="200"
       />
-      <HomeIndex v-show="tabIndex === 0" :currentScrollTop="currentScrollTop" @goVillage="tabIndex = 1" @goDig="tabIndex = 2" />
-      <VillageIndex v-if="tabIndex === 1" showSwitch ref="villageIndex" @goHome="tabIndex=0" />
+      <HomeIndex 
+        ref="homeIndex" 
+        v-show="tabIndex === 0"
+        :currentScrollTop="currentScrollTop"
+        @goVillage="tabIndex = 1" 
+        @goDig="tabIndex = 2" 
+      />
+      <VillageIndex 
+        v-if="tabIndex === 1"
+        ref="villageIndex" 
+        showSwitch
+        @goHome="tabIndex=0" 
+        @goMap="homeIndex?.goMap()"
+      />
       <DigIndex v-show="tabIndex === 2" />
       <DiscoverIndex v-show="tabIndex === 3" @goVillage="tabIndex = 1" />
       <UserIndex v-show="tabIndex === 4" @goSubmit="tabIndex = 2" />
@@ -85,6 +97,7 @@ const currentScrollTop = ref(0);
 
 const backToTop = ref<InstanceType<typeof BackToTop>>();
 const villageIndex = ref<InstanceType<typeof VillageIndex>>();
+const homeIndex = ref<InstanceType<typeof HomeIndex>>();
 
 const { querys } = useLoadQuerys({ 
   openLogin: false,