瀏覽代碼

🎨 优化村落默认空白推荐

快乐的梦鱼 1 月之前
父節點
當前提交
ef445e259b

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

@@ -121,28 +121,6 @@
         </BubbleTip>
       </FlexRow>
 
-      <!-- <HomeTitle title="最新动态" />
-      <Construction text="测试数据,没有接口!">
-        <FlexCol gap="gap.lg">
-          <FlexRow 
-            v-for="item in activityLoader.content.value" :key="item.id"
-            backgroundColor="background.tertiary"
-            radius="radius.md"
-            :padding="[20, 30]"
-            gap="gap.lg"
-            align="center"
-          > 
-            <Avatar 
-              :url="item.head"
-              :size="80"
-              :round="false"
-              :radius="10"
-            />
-            <Text :text="item.content" fontConfig="contentText" :innerStyle="{ flex: 1 }" />
-          </FlexRow>
-        </FlexCol>
-      </Construction> -->
-
       <HomeTitle title="乡村排名" showMore @moreClicked="navTo('/pages/home/village/rank/village', {})" />
       <VillageRankList :list="villageRankListLoader.content.value ?? []" :jumpToSingle="false" @goDetails="handleGoVillageDetails" />
 
@@ -315,29 +293,6 @@ const villageUserRankListLoader = useSimpleDataLoader(async () => {
   return res
 });
 
-const activityLoader = useSimpleDataLoader(async () => {
-  return [
-    {
-      id: 1,
-      head: 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest1.png',
-      content: '测试数据,没有接口!:福泽乡里 为全村加成+10%乡源果,可持续24小时',
-      levelText: '一级',
-    },
-    {
-      id: 2,
-      head: 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest2.png',
-      content: '福泽乡里 为全村加成+10%乡源果,可持续24小时',
-      levelText: '五级',
-    },
-    {
-      id: 3,
-      head: 'https://mn.wenlvti.net/app_static/minnan/images/test/ImageTest3.png',
-      content: '福泽乡里 为全村加成+10%乡源果,可持续24小时',
-      levelText: '十级',
-    },
-
-  ];
-});
 const recommendLoader = useSimplePageListLoader(20, async (page, pageSize) => {
   return await VillageInfoApi.getListForDiscover(page, pageSize);
 }, true);

+ 45 - 53
src/pages/home/light/create-village.vue

@@ -15,6 +15,29 @@
           @pickEnd="handlePickEnd"
         />
       </template>
+      <template v-else-if="step === 'selectVillage'">
+        <FlexCol gap="gap.md" padding="padding.md" width="600rpx">
+          <BoxMid>
+            <Touchable direction="row" gap="gap.md"center @click="handleSkipSearch()">
+              <Image src="https://xy.wenlvti.net/app_static/images/home/volunteer/IconFollows.png" :radius="20" width="70" height="70" mode="aspectFill" />
+              <Text text="以下没有我的家乡" fontConfig="lightGoldTitle" />
+            </Touchable>
+          </BoxMid>
+          <BoxMid
+            v-for="(item, k) in searchedList"
+            :key="k"
+            justify="flex-start"
+          >
+            <Touchable direction="row" gap="gap.md"center @click="handleChooseSearchedVillage(item as VillageListItem)">
+              <Image :src="item.image" :radius="20" width="70" height="70" mode="aspectFill" />
+              <FlexCol gap="gap.md">
+                <Text :text="item.name" fontConfig="lightGoldTitle" />
+                <Text :text="item.address" fontConfig="secondText" />
+              </FlexCol>
+            </Touchable>
+          </BoxMid>
+        </FlexCol>
+      </template>
       <template v-else-if="step === 'inputInfo'">
         <Field v-model="currentVillageName" placeholder="请输入家乡名称,例如:大庆村" />
         <Field 
@@ -74,31 +97,6 @@
       </template>
     </FlexCol>
 
-
-    <CommonDialog v-model:show="showSearchedList" title="您要找的是不是以下村社?" :showDivider="false">
-      <FlexCol gap="gap.md" padding="padding.md" width="600rpx">
-        <BoxMid>
-          <Touchable direction="row" gap="gap.md"center @click="handleConfirm(true)">
-            <Image src="https://xy.wenlvti.net/app_static/images/home/volunteer/IconFollows.png" :radius="20" width="70" height="70" mode="aspectFill" />
-            <Text text="以下没有我的家乡" fontConfig="lightGoldTitle" />
-          </Touchable>
-        </BoxMid>
-        <BoxMid
-          v-for="(item, k) in searchedList"
-          :key="k"
-          justify="flex-start"
-        >
-          <Touchable direction="row" gap="gap.md"center @click="handleChooseSearchedVillage(item as VillageListItem)">
-            <Image :src="item.image" :radius="20" width="70" height="70" mode="aspectFill" />
-            <FlexCol gap="gap.md">
-              <Text :text="item.name" fontConfig="lightGoldTitle" />
-              <Text :text="item.address" fontConfig="secondText" />
-            </FlexCol>
-          </Touchable>
-        </BoxMid>
-      </FlexCol>
-    </CommonDialog>
-
   </CommonTopBanner>
 </template>
 
@@ -121,7 +119,6 @@ import Field from '@/components/form/Field.vue';
 import LightVillageApi, { type VillageListItem } from '@/api/light/LightVillageApi';
 import RadioGroup from '@/components/form/RadioGroup.vue';
 import Radio from '@/components/form/Radio.vue';
-import CommonDialog from '@/common/components/CommonDialog.vue';
 import BoxMid from '@/common/components/box/BoxMid.vue';
 import Touchable from '@/components/feedback/Touchable.vue';
 import Image from '@/components/basic/Image.vue';
@@ -162,7 +159,7 @@ const { querys } = useLoadQuerys({
 
 const mapCtx = uni.createMapContext('prevMap');
 
-const step = ref<'selectArea'|'inputInfo'>('selectArea');
+const step = ref<'selectArea'|'selectVillage'|'inputInfo'>('selectArea');
 const currentFromPreData = ref(false);
 const currentLonLat = ref({ longitude: 0, latitude: 0 });
 const currentVillageName = ref('')
@@ -170,9 +167,7 @@ const currentVillageDesc = ref('')
 const currentVillageType = ref<number>(95);
 const currentAreaCode = ref(0);
 
-const showSearchedList = ref(false);
 const searchedList = ref<VillageListItem[]>([]);
-
 const enableSatellite = ref(false);
 const selectedValue = ref<(string | number)[]>([]);
 const provinceList = ref<CascaderItem[]>([]);
@@ -231,7 +226,17 @@ async function handlePickEnd(values: CascaderItem[]) {
       longitude: Number(currentLonLat.value.longitude),
       latitude: Number(currentLonLat.value.latitude),
     });
-    step.value = 'inputInfo';
+    uni.showLoading();
+    step.value = 'selectVillage';
+    const searchRes = (await LightVillageApi.getVillageList({
+      areaCode: currentAreaCode.value,
+      page: 1,
+      pageSize: 10
+    })).list;
+    if (searchRes.length > 0) {
+      uni.hideLoading();
+      searchedList.value = searchRes;
+    }
   }
 }
 function handleRegionchange(e: any) {
@@ -242,30 +247,17 @@ function handleRegionchange(e: any) {
     };
   }
 }
-async function handleConfirm(skipSearch?: boolean) {
+function handleSkipSearch() {
+  step.value = 'inputInfo';
+}
+async function handleConfirm() {
   if (!currentVillageName.value) {
     toast('请输入家乡名称');
     return;
   }
   uni.showLoading();
   try {
-    //先尝试搜索已有村社 
-    if (!skipSearch) {
-      const searchRes = (await LightVillageApi.getVillageList({
-        areaCode: currentAreaCode.value,
-        keyword: currentVillageName.value.trim() || undefined,
-        page: 1,
-        pageSize: 10
-      })).list;
-      if (searchRes.length > 0) {
-        uni.hideLoading();
-        showSearchedList.value = true;
-        searchedList.value = searchRes;
-        return;
-      }
-    }
-    showSearchedList.value = false;
-    //否则添加村社
+    //添加村社
     const res = (await LightVillageApi.createVillage({ 
       name: currentVillageName.value,
       desc: currentVillageDesc.value,
@@ -273,19 +265,19 @@ async function handleConfirm(skipSearch?: boolean) {
       latitude: String(currentLonLat.value.latitude),
       area_code: currentAreaCode.value,
       village_type: currentVillageType.value,
-    })).data;
+    }));
 
     uni.hideLoading();
 
     await alert({
       title: '提示',
-      content: '村社创建成功!快去成为志愿者吧',
+      content: '村社创建成功!快去为村社做贡献吧',
     });
 
     if (res)
-      backAndCallOnPageBack('joinVillage', {
-        id: res.id,
-        createdNew: true,
+      backAndCallOnPageBack('goVillage', {
+        id: res.requireData().id,
+        createdNew: !res.message.includes('已存在'),
         reselectAddress: getReSelectAddress(),
       });
 

+ 14 - 8
src/pages/home/village/index.vue

@@ -20,12 +20,12 @@
             @click="showMyFollowPopup = true"
           />
         </BubbleTip>
-        <!-- <Button
+        <Button
           :textColor="topTab === 'around' ? 'text.titleLight' : 'text.content'"
-          text="周边村社" 
+          text="优秀村社" 
           size="medium"
           @click="topTab = 'around'" 
-        /> -->
+        />
       </FlexRow>
     </FlexCol>
     <Height :height="40" />
@@ -57,18 +57,21 @@
         <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" />
-          <Text text="欢迎关注或者认领村社,认领自己家乡参与建设,或四处看看" fontConfig="contentText" />
+          <Text text="欢迎关注或者认领村社,认领自己家乡参与建设" fontConfig="contentText" />
+          <Text text="或看看其他优秀村社吧" fontConfig="contentText" />
           <Height :height="20" />
           <FlexRow gap="gap.lg">
             <FrameButton text="去认领村社" @click="handleGoSuscribe" primary />
           </FlexRow>
         </FlexCol>
-        <Height :height="150" />
+        <Around
+          @selectVillage="onSelectVillage" 
+        />
       </FlexCol>
-      <!-- <Around 
+      <Around 
         v-else 
         @selectVillage="onSelectVillage" 
-      /> -->
+      />
     </template>
     <LoadingPage v-else />
     <Height :height="200" />
@@ -118,12 +121,15 @@ import JoinDialog from './dialogs/JoinDialog.vue';
 import BubbleTip from '@/components/feedback/BubbleTip.vue';
 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';
 
 const topTab = ref<'village' | 'around'>('village');
 const tab = ref('card');
 const delayShow = ref(false);
 const villageStore = useVillageStore();
 const { isFollowed } = useFollow();
+const { requireLogin } = useRequireLogin();
 
 const showMyFollowPopup = ref(false);
 const joinDialog = ref<InstanceType<typeof JoinDialog>>();
@@ -153,7 +159,7 @@ function handleCloseFollowTip(open: boolean) {
 }
 
 function handleGoSuscribe() {
-  emit('goHome');
+  requireLogin(() => navTo('/pages/home/light/create-village'), '登录后才能加入村社哦');
 }
 
 function onSelectVillage(village: VillageListItem) {

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

@@ -14,7 +14,7 @@
     >
 
       <!-- 标题 -->
-      <FlexRow justify="space-between" gap="gap.lg" wrap align="flex-end" width="100%">
+      <FlexRow justify="space-between" gap="gap.lg" wrap align="center" width="100%">
         <FlexRow gap="gap.md">
           <Text 
             :text="title" 
@@ -520,7 +520,7 @@ const recommendTagName = computed(() => {
 function handleGoJoin() {
   if (isJoined.value)
     return;
-  emit('goJoin');
+  requireLogin(async () => emit('goJoin'), '登录后就可以加入村社啦');
 }
 function handleGoNew() {
   navTo('/pages/article/common/list', {

+ 14 - 13
src/pages/home/village/recommed/around.vue

@@ -1,6 +1,9 @@
 <template>
   <FlexCol padding="space.sm">
-    <HomeTitle title="周边优秀村社" />
+    <FlexRow center>
+      <HomeTitle title="优秀村社" />
+      <Width :width="60" />
+    </FlexRow>
     <SimplePageListLoader :loader="recommendLoader">
       <MasonryGrid>
         <MasonryGridItem
@@ -9,8 +12,7 @@
           :width="340"
         >
           <IndexCommonImageItem 
-            :title="item.title"
-            :desc="item.desc"
+            :title="item.name"
             :image="item.image"
             defaultImage="https://xy.wenlvti.net/app_static/images/village/PlaceholderVillage.jpg"
             @click="emit('selectVillage', item)"
@@ -22,27 +24,26 @@
 </template>
 
 <script setup lang="ts">  
+import { useSimplePageListLoader } from '@/components/composeabe/loader/SimplePageListLoader';
 import FlexCol from '@/components/layout/FlexCol.vue';
 import HomeTitle from '@/common/components/parts/HomeTitle.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 LightVillageApi from '@/api/light/LightVillageApi';
-import { useSimplePageListLoader } from '@/components/composeabe/loader/SimplePageListLoader';
 import SimplePageListLoader from '@/components/loader/SimplePageListLoader.vue';
+import FlexRow from '@/components/layout/FlexRow.vue';
+import Width from '@/components/layout/space/Width.vue';
 
 const emit = defineEmits(['selectVillage']);
 
-const recommendLoader = useSimplePageListLoader(15, async (page, pageSize, params) => {
-  const result = await LightVillageApi.getVillageList(undefined, undefined, undefined, page, pageSize);
+const recommendLoader = useSimplePageListLoader(15, async (page, pageSize, params) => {  
+  const res = page === 1 ? await LightVillageApi.getVillageRankList({ 
+    num: pageSize,
+  }): [];
   return {
-    total: result.total,
-    list: result.list.map((item) => ({
-      id: item.id,
-      title: item.title,
-      image: item.image,
-      desc: item.address,
-    }))
+    total: res.length,
+    list: res
   }
 });
 </script>