Kaynağa Gözat

🎨 优化村社显示细节

快乐的梦鱼 1 hafta önce
ebeveyn
işleme
2676f52ab2

+ 12 - 0
src/common/composeabe/UserTools.ts

@@ -1,4 +1,5 @@
 import VillageApi, { VolunteerInfo } from "@/api/inhert/VillageApi";
+import OfficialApi from "@/api/light/OfficialApi";
 import { useSimpleDataLoader } from "@/components/composeabe/loader/SimpleDataLoader";
 import { useAuthStore } from "@/store/auth";
 import { useVillageStore } from "@/store/village";
@@ -22,6 +23,16 @@ export function useUserTools() {
       return false;
     }
   }
+  async function getIsManagement(villageId: number) {
+    if (!authStore.isLogged) {
+      return false;
+    }
+    try {
+      return await OfficialApi.checkTopicRule(villageId);
+    } catch (e) {
+      return false;
+    }
+  }
   async function getIsJoinedVillage(villageId: number) {
     if (!authStore.isLogged) {
       return false;
@@ -55,6 +66,7 @@ export function useUserTools() {
     getIsVolunteer,
     getIsJoinedVillage,
     getCanCollect,
+    getIsManagement,
     volunteerInfo,
   };
 }

+ 1 - 1
src/components/basic/Text.vue

@@ -7,7 +7,7 @@
     {{ text }}
     <!-- #endif -->
     <!-- #ifndef APP-NVUE -->
-    <slot>{{ text || '' }}</slot>
+    <slot>{{ text ?? '' }}</slot>
     <!-- #endif -->
   </text>
 </template>

+ 4 - 3
src/pages/dig/components/CollectModuleList.vue

@@ -46,6 +46,7 @@ const props = withDefaults(defineProps<{
   taskTitle: string,
   taskPid: number,
   isView?: boolean,
+  isManagement?: boolean,
 }>(), {
   isView: false,
 });
@@ -56,7 +57,7 @@ async function loadList() {
 
   const res = (await VillageApi.getCatalogList(
     props.villageId, 
-    authStore.isAdmin ? undefined : props.villageVolunteerId,
+    authStore.isAdmin || props.isManagement ? undefined : props.villageVolunteerId,
     props.taskPid
   ));
   if (res.length === 0)
@@ -67,7 +68,7 @@ async function loadList() {
         const formDefine = item.collectModuleId ? getVillageInfoForm(item.collectModuleId, -1) : undefined;
         return {
           ...item,
-          extra: authStore.isAdmin && item.total >= 0 ? `已采编 ${item.total}` : '',
+          extra: authStore.isAdmin || props.isManagement && item.total >= 0 ? `已采编 ${item.total}` : '',
           enable: canCollectCatalog(item.id) || item.haschild,
           catalogItem: item,
           collectModuleId: item.collectModuleId,
@@ -112,7 +113,7 @@ const currentTaskDefItems = ref<(TaskMenuDefItem & { collectModuleId: number })[
 const currentTaskBanner = ref('');
 const handleClick = (item: TaskMenuDefItem) => {
   
-  if (!item.enable && !authStore.isAdmin) {
+  if (!item.enable && (!authStore.isAdmin && !props.isManagement)) {
     uni.showToast({
       title: '您没有完成任务的权限,如需要请联系管理员',
       icon: 'none',

+ 7 - 6
src/pages/dig/details.vue

@@ -1,6 +1,6 @@
 <template>
   <CommonTopBanner title="共编村史">
-    <FlexCol v-if="isJoined" :padding="30" :gap="20">
+    <FlexCol v-if="isJoined || authStore.isAdmin || isManagement" :padding="30" :gap="20">
       <Image
         src="https://mn.wenlvti.net/app_static/xiangan/banner_dig_1.jpg" 
         mode="widthFix"
@@ -16,9 +16,9 @@
         <FlexRow align="center">
           <Text :fontSize="30" color="text.content" :text="`文化积分: `" />
           <Width :width="20" />
-          <Text :fontSize="40" fontFamily="SongtiSCBlack" color="primary" :text="querys.points" />
+          <Text :fontSize="40" fontFamily="SongtiSCBlack" color="primary" :text="volunteerInfo?.points" />
           <Width :width="20" />
-          <Text :fontSize="40" fontFamily="SongtiSCBlack" color="primary" :text="`Lv.${querys.level}`" />
+          <Text :fontSize="40" fontFamily="SongtiSCBlack" color="primary" :text="`Lv.${volunteerInfo?.level}`" />
           <Width :width="20" />
           <Touchable direction="row" align="center" :gap="10" @click="navTo('/pages/dig/about/point')">
             <Icon icon="help-filling" color="primary" :size="40" />
@@ -92,17 +92,16 @@ import BoxMid from '@/common/components/box/BoxMid.vue';
 
 const { querys } = useLoadQuerys({ 
   name: '',
-  points: 0,
-  level: 0,
   villageId: 0,  
   villageVolunteerId: 0,
 });
 
 const authStore = useAuthStore();
 const { canCollect, isEmpty } = useCollectStore();
-const { getIsJoinedVillage } = useUserTools();
+const { getIsJoinedVillage, getIsManagement, getIsVolunteer, volunteerInfo } = useUserTools();
 const { goForm } = useTaskEntryForm();
 const isJoined = ref(false);
+const isManagement = ref(false);
 
 function goCollect() {
   /* if (!canCollect('collect')) {
@@ -122,6 +121,8 @@ function goJoin() {
   });
 }
 onMounted(async () => {
+  await getIsVolunteer();
+  isManagement.value = await getIsManagement(querys.value.villageId);
   isJoined.value = await getIsJoinedVillage(querys.value.villageId);
 });
 </script>

+ 17 - 2
src/pages/dig/forms/list-ordinary.vue

@@ -66,6 +66,7 @@
                 </FlexCol>
               </Touchable>
               <FrameButton text="待审核" size="small" @click="navTo('/pages/dig/about/goving')" />
+              <FrameButton v-if="isManagement" text="管理" size="small" @click="goEdit(item)" />
             </BackgroundBox>
           </FlexCol>
           <template #empty>
@@ -114,8 +115,9 @@ import FrameButton from '@/common/components/FrameButton.vue';
 
 const subTitle = ref('');
 const searchText = ref('');
-const { getIsVolunteer, getCanCollect, volunteerInfo } = useUserTools();
+const { getIsVolunteer, getCanCollect, getIsManagement, volunteerInfo } = useUserTools();
 const canCollect = ref(false);
+const isManagement = ref(false);
 const authStore = useAuthStore();
 const error = ref('');
 
@@ -197,6 +199,18 @@ function goDetail(item: { id: number, villageVolunteerId: number }) {
     id: item.id,
   });
 }
+function goEdit(item: { id: number, villageVolunteerId: number }) {
+  navTo('common', { 
+    id: item.id,
+    villageId: querys.value.villageId,
+    villageVolunteerId: item.villageVolunteerId,
+    catalogId: currentLoadData.value.catalogId,
+    collectModuleId: querys.value.collectModuleId,
+    subKey: currentLoadData.value.subKey,
+    subId: currentLoadData.value.subId,
+    subTitle: currentLoadData.value.subTitle,
+  });
+}
 function search() {
   listLoader.reload();
 }
@@ -299,6 +313,7 @@ const { querys } = useLoadQuerys({
   villageId: 0,  
   title: '',
 }, async (querys) => {
+  isManagement.value = await getIsManagement(querys.villageId);
   try {
     //普通用户进入预览模式
     await getIsVolunteer();
@@ -317,7 +332,7 @@ const { querys } = useLoadQuerys({
   }
   (await VillageApi.getCatalogList(
     querys.villageId, 
-    authStore.isAdmin ? undefined : volunteerInfo.value?.id || 0,
+    authStore.isAdmin || isManagement.value ? undefined : volunteerInfo.value?.id || 0,
   )).forEach((catalog) => {
     pushCatalogWithCurrentCatalog(catalog);
   });

+ 6 - 7
src/pages/dig/forms/list.vue

@@ -71,7 +71,6 @@ import { DataDateUtils } from '@imengyu/js-request-transform';
 import { useSimplePageListLoader } from '@/components/composeabe/loader/SimplePageListLoader';
 import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
 import { useAuthStore } from '@/store/auth';
-import { type TaskMenuDefGoForm } from './tasks';
 import { useUserTools } from '@/common/composeabe/UserTools';
 import { navTo } from '@/components/utils/PageAction';
 import { confirm, alert } from '@/components/utils/DialogAction';
@@ -89,19 +88,18 @@ import H4 from '@/components/typography/H4.vue';
 import Touchable from '@/components/feedback/Touchable.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import Result from '@/components/feedback/Result.vue';
-import { CollectableModulesIdMap, getVillageInfoForm } from './forms';
-import VillageApi from '@/api/inhert/VillageApi';
+import { getVillageInfoForm } from './forms';
 import CommonTopBanner from '@/common/components/CommonTopBanner.vue';
-import BackgroundBox from '@/components/display/block/BackgroundBox.vue';
-import BackgroundImageButton from '@/components/basic/BackgroundImageButton.vue';
 import PrimaryButton from '@/common/components/PrimaryButton.vue';
 import BoxMid from '@/common/components/box/BoxMid.vue';
 
 const subTitle = ref('');
 const searchText = ref('');
-const { getIsVolunteer, getIsJoinedVillage, volunteerInfo } = useUserTools();
+const { getIsVolunteer, getIsJoinedVillage, getIsManagement, volunteerInfo } = useUserTools();
 const isJoined = ref(false);
+const isManagement = ref(false);
 const authStore = useAuthStore();
+
 const error = ref('');
 
 const listLoader = useSimplePageListLoader<{
@@ -140,7 +138,7 @@ const listLoader = useSimplePageListLoader<{
       title: item.title,
       villageVolunteerId: item.villageVolunteerId,
       desc: DataDateUtils.formatDate(item.updatedAt, 'YYYY-MM-dd') + (
-        authStore.isAdmin ? (' 投稿人:' + item.villageVolunteerName) : ''
+        authStore.isAdmin || isManagement.value ? (' 投稿人:' + item.villageVolunteerName) : ''
       )
     }
   })
@@ -211,6 +209,7 @@ const { querys } = useLoadQuerys({
   isView: false,
 }, async (querys) => {
   isJoined.value = await getIsJoinedVillage(querys.villageId);
+  isManagement.value = await getIsManagement(querys.villageId);
 
   if (querys.collectModuleId) {
     //普通用户进入预览模式

+ 34 - 20
src/pages/home/village/dialogs/BlessBuyDialog.vue

@@ -82,26 +82,40 @@ const props = defineProps<{
 }>();
 const emit = defineEmits(['buyBless']);
 
-const infoGrids = computed(() => [
-  {
-    label: '村社加乡源光',
-    image: 'https://xy.wenlvti.net/app_static/images/home/bless/IconLight.png',
-    value: props.currentBless?.addLight || 0,
-    unit: '光',
-  },
-  {
-    label: '用户得乡源果',
-    image: 'https://xy.wenlvti.net/app_static/images/home/bless/IconFruit.png',
-    value: props.currentBless?.addFruit || 0,
-    unit: '个',
-  },
-  {
-    label: '得乡源果倍率',
-    image: 'https://xy.wenlvti.net/app_static/images/home/bless/IconFruit.png',
-    value: props.currentBless?.multiple || 0,
-    unit: '倍',
-  },
-]);
+const infoGrids = computed(() => {
+  const arr = [] as {
+    label: string;
+    image: string;
+    value: number;
+    unit: string;
+  }[];
+
+  if (props.currentBless?.addLight) {
+    arr.push({
+      label: '村社加乡源光',
+      image: 'https://xy.wenlvti.net/app_static/images/home/bless/IconLight.png',
+      value: props.currentBless?.addLight || 0,
+      unit: '光',
+    });
+  } 
+  if (props.currentBless?.addFruit) {
+    arr.push({
+      label: '用户得乡源果',
+      image: 'https://xy.wenlvti.net/app_static/images/home/bless/IconFruit.png',
+      value: props.currentBless?.addFruit || 0,
+      unit: '个',
+    });
+  }
+  if (props.currentBless?.multiple) {
+    arr.push({
+      label: '得乡源果倍率',
+      image: 'https://xy.wenlvti.net/app_static/images/home/bless/IconFruit.png',
+      value: props.currentBless?.multiple || 0,
+      unit: '倍',
+    });
+  }
+  return arr;
+});
 const effectiveDate = computed(() => {
   return DateUtils.formatDate(DateUtils.dateAddDays(new Date(), props.currentBless?.days || 0), 'YYYY-MM-DD');
 });

+ 2 - 2
src/pages/home/village/index.vue

@@ -66,7 +66,7 @@
     <FlexCol v-else-if="topTab === 'village'" gap="gap.md">
       <FlexCol v-if="!isLight" 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="primaryTitle" />
         <Text text="欢迎关注或者认领村社,认领自己家乡参与建设,或四处看看" fontConfig="contentText" />
         <Height :height="20" />
         <FlexRow gap="gap.lg">
@@ -178,7 +178,7 @@ function onSelectVillage(village: VillageListItem) {
   showMyFollowPopup.value = false;
 }
 
-watch(() => villageStore.currentVillage, (newVal) => {
+watch(() => villageStore.currentVillage?.id, (newVal) => {
   if (newVal && topTab.value === 'around')
     topTab.value = 'village';
   tab.value = 'card';

+ 52 - 18
src/pages/home/village/introd/card.vue

@@ -170,24 +170,36 @@
     <!-- 魅力乡源 -->
     <HomeTitle title="魅力乡源" showMore @moreClicked="handleGoCollect()">
       <template #right>
-        <Touchable 
-          :padding="[15, 20]"
-          :innerStyle="{ 
-            marginRight: '20rpx'
-          }"
-          borderStyle="solid"
-          borderColor="border.secondary"
-          borderWidth="1px"
-          backgroundColor="background.quaternary"
-          radius="radius.md"
-          direction="row"
-          center
-          gap="gap.sm"
-          @click="handleGoCollect()"
-        >
-          <Icon name="https://xy.wenlvti.net/app_static/images/village/IconHistory.png" :size="30" />
-          <Text text="共编村史" fontConfig="contentText" />
-        </Touchable>
+        <FlexRow align="center" gap="gap.md">
+          <Touchable
+            :padding="[15, 20]"
+            direction="row"
+            center
+            gap="gap.md"
+            @click="handleGoDigManage()"
+          >
+            <Icon name="https://xy.wenlvti.net/app_static/images/village/IconLargeFolkloreVibe.png" :size="30" />
+            <Text text="管理" fontConfig="contentText" />
+          </Touchable>
+          <Touchable 
+            :padding="[15, 20]"
+            :innerStyle="{ 
+              marginRight: '20rpx'
+            }"
+            borderStyle="solid"
+            borderColor="border.secondary"
+            borderWidth="1px"
+            backgroundColor="background.quaternary"
+            radius="radius.md"
+            direction="row"
+            center
+            gap="gap.sm"
+            @click="handleGoCollect()"
+          >
+            <Icon name="https://xy.wenlvti.net/app_static/images/village/IconHistory.png" :size="30" />
+            <Text text="共编村史" fontConfig="contentText" />
+          </Touchable>
+        </FlexRow>
       </template>
     </HomeTitle>
     <ProvideVar :vars="{
@@ -483,6 +495,28 @@ async function handleGoOfficalManage() {
     topic: recommendTagName.value,
   });
 }
+async function handleGoDigManage() {
+  assertNotNull(villageStore.currentVillage?.id)
+  const isAdmin = (authStore.isAdmin || await OfficialApi.checkTopicRule(villageStore.currentVillage.id));
+  if (!isAdmin) {
+    const goUpgrade = await confirm({
+      title: '提示',
+      content: '您还不是管理员,您可以联系村社管理员将你添加为管理员,若当前村社暂无管理员,您可以点击“去升级”将您升级为管理员。',
+      confirmText: '去升级',
+      cancelText: '取消',
+    });
+    if (goUpgrade) {
+      navTo('/pages/home/village/upgrade/my-upgrade-management', {
+        villageId: villageStore.currentVillage.id,
+      });
+    }
+    return;
+  }
+  navTo('/pages/dig/details', {
+    name: villageStore.currentVillage.title,
+    villageId: villageStore.currentVillage.id,
+  });
+}
 
 const { currentNoticeContent, noticeListLoader } = useGetNotice(() => villageStore.currentVillage?.id || 0);