Selaa lähdekoodia

💊 优化采集页显示

快乐的梦鱼 1 kuukausi sitten
vanhempi
commit
324b25be03

+ 3 - 3
src/api/inhert/VillageApi.ts

@@ -1,4 +1,4 @@
-import { CONVERTER_ADD_DEFAULT, DataModel, transformArrayDataModel, type KeyValue } from '@imengyu/js-request-transform';
+import { CONVERTER_ADD_DEFAULT, DataModel, transformArrayDataModel, transformDataModel, type KeyValue } from '@imengyu/js-request-transform';
 import { AppServerRequestModule } from '../RequestModules';
 import { findAProp, transformSomeToArray } from '../Utils';
 import { LoginResult } from '../auth/UserApi';
@@ -248,8 +248,8 @@ export class VillageApi extends AppServerRequestModule<DataModel> {
     return transformArrayDataModel<VillageListItem>(VillageListItem, transformSomeToArray(res.data), `村落`, true);
   }
   async getVolunteerInfo() {
-    const res = await this.post('/village/volunteer/getInfo', '获取志愿者信息', {}, undefined, VolunteerInfo);
-    return res.data as VolunteerInfo;
+    const res = await this.post<KeyValue>('/village/volunteer/getInfo', '获取志愿者信息', {}, undefined);
+    return transformDataModel<VolunteerInfo>(VolunteerInfo, res.requireData());
   }
   async getVolunteerRanklist(category?: number) {
     const res = await this.post<any[]>('/village/volunteer/getRanklist', '志愿者排行榜', {

+ 1 - 1
src/api/inhert/VillageInfoApi.ts

@@ -249,7 +249,7 @@ export class VillageInfoApi extends AppServerRequestModule<DataModel> {
       data: any[],
     }>(`/village/collect/list`, '获取信息详情', {
       collect_module_id: collectModuleId,
-      [subKey ? subKey : 'type']: subId,
+      [subKey ? subKey : 'type']: subId && subId >= 0 ? subId : undefined,
       village_id: villageId,
       village_volunteer_id: villageVolunteerId,
       catalog_id: catalogId,

+ 2 - 2
src/common/components/FrameButton.vue

@@ -11,8 +11,8 @@
     gap="gap.md"
     @click="emit('click')"
   >
-    <ActivityIndicator v-if="loading" :size="36" :color="primary ? 'white' : 'black'" />
-    <Text :text="text" fontConfig="lightTitle" :fontSize="36" :color="primary ? 'white' : 'black'" />
+    <ActivityIndicator v-if="loading" :size="36" :color="primary ? 'white' : 'text.content'" />
+    <Text :text="text" fontConfig="lightTitle" :fontSize="36" :color="primary ? 'white' : 'text.content'" />
   </BackgroundImageButton>
 </template>
 

+ 3 - 3
src/common/composeabe/UserTools.ts

@@ -13,10 +13,10 @@ export function useUserTools() {
       return false;
     }
     try {
-      const volunteerInfo = await VillageApi.getVolunteerInfo();
-      volunteerInfo.value = volunteerInfo;
+      volunteerInfo.value = await VillageApi.getVolunteerInfo();
       return volunteerInfo.value !== null;
-    } catch {
+    } catch (e) {
+      console.error(e);
       return false;
     }
   }

+ 2 - 1
src/pages.json

@@ -295,7 +295,8 @@
           "path": "forms/list-ordinary",
           "style": {
             "navigationBarTitleText": "普通信息列表",
-            "enablePullDownRefresh": true
+            "enablePullDownRefresh": true,
+            "navigationStyle": "custom"
           }
         },
         {

+ 164 - 105
src/pages/dig/forms/list-ordinary.vue

@@ -1,83 +1,102 @@
 <template>
-  <FlexCol padding="space.md" gap="space.md">
-    <Result v-if="error" 
-      :title="error"
-    />
-    <template v-else>
-      <FlexRow justify="space-between" align="center" gap="space.sm">
-        <SearchBar
-          v-model="searchText"
-          placeholder="搜一搜" 
-          :innerStyle="{ width: '280rpx' }"
-          @search="search"
-        />
-        <picker @change="handleCatalogChange" :value="currentCatalogIndex" :range="currentCatalogList" range-key="name">
-          <FlexRow align="center" border="primary" radius="radius.md" padding="padding.sm">
-            <Text :text="(currentCatalog?.title || '未选择栏目')" :lines="1" :maxWidth="180" />
-            <Icon icon="arrow-down" :size="40" />
+  <CommonTopBanner :title="currentTitle">
+    <FlexCol padding="space.md" gap="space.md">
+      <Result v-if="error" 
+        :title="error"
+      />
+      <template v-else>
+        <FlexRow justify="space-between" align="center" gap="space.sm">
+          <FlexRow align="center" gap="space.sm" backgroundColor="white" radius="50">
+            <SearchBar
+              v-model="searchText"
+              placeholder="搜一搜" 
+              :innerStyle="{ width: '280rpx' }"
+              @search="search"
+            />
+            <picker @change="handleCatalogChange" :value="currentCatalogIndex" :range="currentCatalogList" range-key="name">
+              <FlexRow center gap="space.md">
+                <Text :text="(currentCatalog?.title || '未选择栏目')" :lines="1" :maxWidth="180" />
+                <Icon icon="arrow-down" :size="40" />
+              </FlexRow>
+            </picker>
+            <Width :width="10" />
           </FlexRow>
-        </picker>
-        <Button type="primary" @click="newData">+ 编写</Button>
-      </FlexRow>
-      <FlexCol 
-        v-if="!isJoined" 
-        center 
-        gap="gap.lg" 
-        border="primary" 
-        backgroundColor="background.tertiary"
-        radius="radius.md" 
-        padding="padding.md"
-      > 
-        <Image 
-          src="https://xy.wenlvti.net/app_static/images/village/PlaceholderVolunteer.png" 
-          mode="widthFix" 
-          :width="200" 
-          :height="200" 
-        />
-        <Text>您还不是当前村社的志愿者</Text>
-        <Text>欢迎注册,加入志愿者队伍,点亮村落</Text>
-        <Button type="primary" @click="goJoin">去点亮村落</Button>
-      </FlexCol>
-      <Height :height="20" />
-      <SimplePageListLoader :loader="listLoader" :noEmpty="true">
-        <FlexCol :gap="20">
-          <Touchable 
-            v-for="item in listLoader.list.value"
-            :key="item.id" 
-            :gap="20"
-            :padding="[15,20]"
-            radius="radius.md"
-            align="center"
-            backgroundColor="white"
-            direction="row"
-            touchable
-            @click="goDetail(item)"
+
+          <BackgroundImageButton 
+            backgroundImage="https://xy.wenlvti.net/app_static/images/village/ButtonPrimary.png"
+            :backgroundCutBorder="20"
+            :backgroundCutBorderSize="20"
+            :padding="[16, 40]"
+            @click="newData"
           >
-            <Image 
-              :src="item.image"
-              :showFailed="false"
-              :width="100"
-              :height="100"
-              radius="radius.sm"
-              mode="aspectFill"
-              round
-            />
-            <FlexCol>
-              <H4 :size="36">{{ item.title }}</H4>
-              <Text :size="23">{{ item.desc }}</Text>
-            </FlexCol>
-          </Touchable>
+            <Text text="+ 编写" />
+          </BackgroundImageButton>
+        </FlexRow>
+        <FlexCol 
+          v-if="!isJoined" 
+          center 
+          gap="gap.lg" 
+          border="primary" 
+          backgroundColor="background.tertiary"
+          radius="radius.md" 
+          padding="padding.md"
+        > 
+          <Image 
+            src="https://xy.wenlvti.net/app_static/images/village/PlaceholderVolunteer.png" 
+            mode="widthFix" 
+            :width="200" 
+            :height="200" 
+          />
+          <Text>您还不是当前村社的志愿者</Text>
+          <Text>欢迎注册,加入志愿者队伍,点亮村落</Text>
+          <Button type="primary" @click="goJoin">去点亮村落</Button>
         </FlexCol>
-        <template #empty>
-          <Empty image="search" description="这里还没有数据,快来编写完善吧!">
-            <Height :height="40" />
-            <Button type="primary" :text="`+ 新增${subTitle}数据`" @click="newData" />
-          </Empty>
-        </template>
-      </SimplePageListLoader>
-    </template>
-    <XBarSpace />
-  </FlexCol>
+        <Height :height="5" />
+        <SimplePageListLoader :loader="listLoader" :noEmpty="true">
+          <FlexCol :gap="20">
+            <BackgroundBox 
+              v-for="item in listLoader.list.value"
+              :key="item.id" 
+              direction="row"
+              backgroundImage="https://xy.wenlvti.net/app_static/images/village/BoxMid.png"
+              :backgroundCutBorder="30"
+              :backgroundCutBorderSize="30"
+              :padding="[16, 30]"
+              align="center"
+            >
+              <Touchable 
+                :gap="20"
+                :padding="[15,20]"
+                touchable
+                flex="1"
+                @click="goDetail(item)"
+              >
+                <Image 
+                  :src="item.image"
+                  :showFailed="false"
+                  :width="100"
+                  :height="100"
+                  radius="radius.sm"
+                  mode="aspectFill"
+                />
+                <FlexCol>
+                  <H4 :size="36" fontFamily="SongtiSCBlack">{{ item.title }}</H4>
+                  <Text :size="23">{{ item.desc }}</Text>
+                </FlexCol>
+              </Touchable>
+            </BackgroundBox>
+          </FlexCol>
+          <template #empty>
+            <Empty image="search" description="这里还没有数据,快来编写完善吧!">
+              <Height :height="40" />
+              <Button type="primary" :text="`+ 新增${subTitle}数据`" @click="newData" />
+            </Empty>
+          </template>
+        </SimplePageListLoader>
+      </template>
+      <XBarSpace />
+    </FlexCol>
+  </CommonTopBanner>
 </template>
 
 <script setup lang="ts">
@@ -92,7 +111,7 @@ import { useUserTools } from '@/common/composeabe/UserTools';
 import { navTo } from '@/components/utils/PageAction';
 import { confirm, alert } from '@/components/utils/DialogAction';
 import SimplePageListLoader from '@/components/loader/SimplePageListLoader.vue';
-import VillageInfoApi from '@/api/inhert/VillageInfoApi';
+import VillageInfoApi, { CommonInfoModel } from '@/api/inhert/VillageInfoApi';
 import Image from '@/components/basic/Image.vue';
 import Empty from '@/components/feedback/Empty.vue';
 import Button from '@/components/basic/Button.vue';
@@ -108,6 +127,10 @@ import Result from '@/components/feedback/Result.vue';
 import { CollectableModulesIdMap, getVillageInfoForm } from './forms';
 import VillageApi, { type VillageCatalogListItem } from '@/api/inhert/VillageApi';
 import Icon from '@/components/basic/Icon.vue';
+import CommonTopBanner from '@/common/components/CommonTopBanner.vue';
+import BackgroundBox from '@/components/display/block/BackgroundBox.vue';
+import BackgroundImageButton from '@/components/basic/BackgroundImageButton.vue';
+import Width from '@/components/layout/space/Width.vue';
 
 const subTitle = ref('');
 const searchText = ref('');
@@ -135,16 +158,35 @@ const listLoader = useSimplePageListLoader<{
     throw new Error("params.collectModuleId");
   if (!params.villageId)
     throw new Error("params.villageId");
-  let res = await VillageInfoApi.getList(
-    params.collectModuleId,
-    params.subKey ? params.subId : undefined,
-    params.subKey,
-    params.villageId,
-    authStore.isAdmin && params.villageVolunteerId ? undefined : params.villageVolunteerId,
-    currentCatalog.value?.id || 0,
-    page,
-    pageSize,
-  )
+  let res = [] as CommonInfoModel[];
+
+  if (params.collectModuleId === CollectableModulesIdMap['overview']) {
+    //村社概览特殊处理
+    const info = await VillageInfoApi.getInfoByVillageId(params.villageId);
+    const overviewId = info.myOverviewId || info.overviewId;
+    if (overviewId) {
+      res = [
+        new CommonInfoModel().setSelfValues({
+          id: info.myOverviewId || info.overviewId || 0,
+          title: info.title,
+          image: info.image,
+          villageVolunteerId: params.villageVolunteerId,
+        }),
+      ];
+    }
+  } else {
+    res = await VillageInfoApi.getList(
+      params.collectModuleId,
+      params.subKey ? params.subId : undefined,
+      params.subKey,
+      params.villageId,
+      authStore.isAdmin && params.villageVolunteerId ? undefined : params.villageVolunteerId,
+      currentCatalog.value?.id || 0,
+      page,
+      pageSize,
+    )
+  }
+
   if (searchText.value)
     res = res.filter((p) => p.title.includes(searchText.value));
   const list = res.map((item) => {
@@ -187,24 +229,44 @@ function newData() {
   });
 }
 function goDetail(item: { id: number, villageVolunteerId: number }) {
+
+  let goToFormDisplay = false;
+  let canEdit = false;
+
   if (!authStore.isAdmin 
     && (!isJoined.value || item.villageVolunteerId !== volunteerInfo.value?.id)
   ) {
     //非当前村社志愿者或者不是自己提交的文章,只能查看详情
-    navTo('/pages/home/discover/details', {
-      villageId: querys.value.villageId,
-      id: item.id,
-    });
+    //村社概览表单特殊处理
+    if ([
+      CollectableModulesIdMap['overview'],
+      CollectableModulesIdMap['environment'], 
+      CollectableModulesIdMap['distribution'],
+      CollectableModulesIdMap['ich'],
+      CollectableModulesIdMap['relic'],
+      CollectableModulesIdMap['folkCulture'],
+      CollectableModulesIdMap['building'],
+    ].includes(currentLoadData.value.collectModuleId)) {
+      goToFormDisplay = true;
+    }
   } else {
-    navTo('common', { 
+    goToFormDisplay = true;
+    canEdit = true;
+  }
+
+  if (goToFormDisplay) {
+    navTo('common', {
       id: item.id,
       villageId: querys.value.villageId,
       villageVolunteerId: querys.value.villageVolunteerId,
       catalogId: currentCatalog.value?.id || 0,
       collectModuleId: currentLoadData.value.collectModuleId,
-      subKey: currentLoadData.value.subKey,
-      subId: currentLoadData.value.subId,
-      subTitle: currentLoadData.value.subTitle,
+      isView: !canEdit,
+    });
+  } else {
+    navTo('/pages/home/discover/details', {
+      villageId: querys.value.villageId,
+      id: item.id,
     });
   }
 }
@@ -217,6 +279,7 @@ function goJoin() {
   });
 }
 
+const currentTitle = ref('');
 const catalogs = ref<VillageCatalogListItem[]>([]);
 const currentCatalogIndex = ref(0);
 const currentCatalogList = computed(() => {
@@ -238,8 +301,7 @@ const currentLoadData = ref({
 
 function handleCatalogChange(e: any) {
   currentCatalogIndex.value = e.detail.value;
-  currentCatalog.value = catalogs.value[currentCatalogIndex.value];
-  loadListCatalog(currentCatalog.value as VillageCatalogListItem);
+  loadListCatalog(catalogs.value[currentCatalogIndex.value] as VillageCatalogListItem);
 }
 
 function loadListCatalog(catalog: VillageCatalogListItem) {
@@ -267,7 +329,8 @@ function loadListCatalog(catalog: VillageCatalogListItem) {
       villageId: querys.value.villageId,
       villageVolunteerId: volunteerInfo.value?.id || 0,
     }
-  } catch {
+  } catch (e) {
+    console.error(e);
     error.value = '任务不存在';
     return;
   }
@@ -280,12 +343,10 @@ const { querys } = useLoadQuerys({
   villageVolunteerId: 0,
   title: '',
 }, async (querys) => {
-  isJoined.value = await getIsJoinedVillage(querys.villageId);
-
   //普通用户进入预览模式
   await getIsVolunteer();
+  isJoined.value = await getIsJoinedVillage(querys.villageId);
 
-  const catalogList = [] as VillageCatalogListItem[]; 
   function pushCatalogWithCurrentCatalog(catalog: VillageCatalogListItem) {
     if (catalog.collectModuleId === querys.collectModuleId) {
       catalogs.value.push(catalog);
@@ -302,14 +363,12 @@ const { querys } = useLoadQuerys({
   });
 
   if (catalogs.value.length === 0) {
-    error.value = '未找到指定的采集目录';
+    error.value = `本村暂未开通此栏目 (${querys.collectModuleId})`;
     return;
   }
   loadListCatalog(catalogs.value[0] as VillageCatalogListItem);
 
-  if (querys.title) {
-    uni.setNavigationBarTitle({  title: querys.title, })
-  }
+  currentTitle.value = querys.title || '共编村史';
 });
 
 onPullDownRefresh(() => {

+ 19 - 11
src/pages/home/dig.vue

@@ -14,17 +14,23 @@
       />
       <HomeTitle title="我的村社" />
       <RequireLogin unLoginMessage="欢迎您成为志愿者!在这之前您需要登录或者注册完善基础信息后才能投稿和查看我认领的村社哦">
-        <Result
+        <FlexCol 
           v-if="notVolunteerError"
-          status="warning"
-          title="您还不是志愿者"
-          subTitle="请联系管理员认领,或者绑定已有志愿者账号"
+          gap="gap.lg" 
+          padding="padding.md"
+          center
         >
-          <FlexCol center>
-            <Height :size="20" />
-            <Button type="primary" text="绑定已有志愿者账号" @click="navTo('/pages/dig/sharereg/bind')" />
-          </FlexCol>
-        </Result>
+          <Image src="https://xy.wenlvti.net/app_static/images/home/BadgeNew.png" :width="320" mode="widthFix" />
+          <CommonDivider />
+          <Text 
+            textAlign="center"
+            text="认领属于你的村庄,参与建设家乡 或者先随便看看,了解更多乡村故事" 
+            fontConfig="contentSpeicalText" 
+          />
+          <FlexRow justify="space-around" gap="gap.md">
+            <FrameButton primary text="去认领村庄" @click="navTo('/pages/home/light/submit-map')" width="220rpx" />
+          </FlexRow>
+        </FlexCol>
         <SimplePageContentLoader
           v-else
           :loader="villageListLoader"
@@ -101,11 +107,11 @@
       <HomeTitle v-if="authStore.isLogged" title="我的贡献" />
       <FlexRow v-if="authStore.isLogged" backgroundColor="white" radius="radius.md" :padding="[40,20]">
         <FlexCol :flex="1" :gap="10" center>
-          <Text :fontSize="60" fontFamily="Rockwell" color="primary">{{ volunteerInfoLoader.content.value?.points || 0 }}</Text>
+          <Text fontConfig="lightGoldTitle">{{ volunteerInfoLoader.content.value?.points || 0 }}</Text>
           <Text>文化积分</Text>
         </FlexCol>
         <FlexCol :flex="1" :gap="10" center>
-          <Text :fontSize="60" fontFamily="Rockwell" color="primary">Lv.{{ volunteerInfoLoader.content.value?.level || 1 }}</Text>
+          <Text fontConfig="lightGoldTitle">Lv.{{ volunteerInfoLoader.content.value?.level || 1 }}</Text>
           <Text>等级</Text>
         </FlexCol>
       </FlexRow>
@@ -147,6 +153,8 @@ import Dialog from '@/components/dialog/Dialog.vue';
 import HomeTitle from '@/common/components/parts/HomeTitle.vue';
 import HomeLargeTitle from '@/common/components/parts/HomeLargeTitle.vue';
 import type { RequestApiError } from '@imengyu/imengyu-utils';
+import FrameButton from '@/common/components/FrameButton.vue';
+import CommonDivider from '@/common/components/CommonDivider.vue';
 
 const showOnlinePreviewDialog = ref(false);
 const authStore = useAuthStore();