Explorar o código

📦 修改编写村史入口

快乐的梦鱼 hai 1 mes
pai
achega
a731aea8c5

+ 6 - 2
src/common/composeabe/UserTools.ts

@@ -1,9 +1,11 @@
-import VillageApi from "@/api/inhert/VillageApi";
+import VillageApi, { VolunteerInfo } from "@/api/inhert/VillageApi";
 import { useAuthStore } from "@/store/auth";
+import { ref } from "vue";
 
 export function useUserTools() {
 
   const authStore = useAuthStore();
+  const volunteerInfo = ref<VolunteerInfo | null>(null);
 
   async function getIsVolunteer() {
 
@@ -13,7 +15,8 @@ export function useUserTools() {
 
     try {
       const volunteerInfo = await VillageApi.getVolunteerInfo();
-      return volunteerInfo !== null;
+      volunteerInfo.value = volunteerInfo;
+      return volunteerInfo.value !== null;
     } catch {
       return false;
     }
@@ -21,5 +24,6 @@ export function useUserTools() {
 
   return {
     getIsVolunteer,
+    volunteerInfo,
   };
 }

+ 2 - 0
src/common/config/Theme.ts

@@ -52,6 +52,8 @@ export function configAppTheme() {
     };
 
 
+    theme.varOverrides.border.primary = '1px solid #aca696';
+    theme.varOverrides.border.secondary = '1px solid #5F3F2C';
     theme.varOverrides['ImageDefaultImage'] = 'https://xy.wenlvti.net/app_static/EmptyImage.png';
     return [theme, defaultDarkTheme];
   });

+ 18 - 0
src/components/theme/Theme.ts

@@ -14,6 +14,24 @@ export const DefaultTheme : ThemeConfig = {
       '4xl': '70rpx',
       '5xl': '80rpx',
     },
+    padding: {
+      xs: '10rpx',
+      sm: '15rpx',
+      md: '20rpx',
+      lg: '30rpx',
+      xl: '40rpx',
+      '2xl': '50rpx',
+      '3xl': '60rpx',
+    },
+    margin: {
+      xs: '10rpx',
+      sm: '15rpx',
+      md: '20rpx',
+      lg: '30rpx',
+      xl: '40rpx',
+      '2xl': '50rpx',
+      '3xl': '60rpx',
+    },
     fontSize: {
       xs: 22,
       sm: 26,

+ 40 - 3
src/pages/dig/details.vue

@@ -1,5 +1,5 @@
 <template>
-  <FlexCol :padding="30" :gap="20">
+  <FlexCol v-if="volunteerInfo" :padding="30" :gap="20">
     <Image
       src="https://mn.wenlvti.net/app_static/xiangan/banner_dig_1.jpg" 
       mode="widthFix"
@@ -19,7 +19,6 @@
         <Text :fontSize="40" fontFamily="Rockwell" color="primary" :text="`Lv.${querys.level}`" />
       </FlexRow>
     </FlexRow>
-
     <Touchable 
       direction="column" 
       touchable 
@@ -35,7 +34,6 @@
       <Text :fontSize="22" color="gray">写随手记,记录下村社文化发现和思考,自动分类</Text>
       <Text :fontSize="22" color="gray">也可点击下方进入指定的分类采集信息</Text>
     </Touchable>
-
     <FlexCol :gap="20">
       <Alert
         v-if="!authStore.isAdmin && isEmpty"
@@ -53,6 +51,30 @@
     </FlexCol>
     <XBarSpace />
   </FlexCol>
+  <FlexCol v-else padding="padding.md">
+    <FlexCol 
+      v-if="!volunteerInfo" 
+      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>
+      <FlexRow gap="gap.md">
+        <Button type="primary" @click="goJoin">去点亮村落</Button>
+        <Button @click="back()">返回</Button>
+      </FlexRow>
+    </FlexCol>
+  </FlexCol>
 </template>
 
 <script setup lang="ts">
@@ -60,6 +82,9 @@ import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
 import { useAuthStore } from '@/store/auth';
 import { useCollectStore } from '@/store/collect';
 import { useTaskEntryForm } from './forms/composeable/TaskEntryForm';
+import { useUserTools } from '@/common/composeabe/UserTools';
+import { onMounted } from 'vue';
+import { back, navTo } from '@/components/utils/PageAction';
 import Icon from '@/components/basic/Icon.vue';
 import Text from '@/components/basic/Text.vue';
 import Touchable from '@/components/feedback/Touchable.vue';
@@ -71,6 +96,8 @@ import CollectModuleList from './components/CollectModuleList.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
 import Width from '@/components/layout/space/Width.vue';
 import Alert from '@/components/feedback/Alert.vue';
+import Result from '@/components/feedback/Result.vue';
+import Button from '@/components/basic/Button.vue';
 
 const { querys } = useLoadQuerys({ 
   name: '',
@@ -82,6 +109,7 @@ const { querys } = useLoadQuerys({
 
 const authStore = useAuthStore();
 const { canCollect, isEmpty } = useCollectStore();
+const { getIsVolunteer, volunteerInfo } = useUserTools();
 const { goForm } = useTaskEntryForm();
 
 function goCollect() {
@@ -95,4 +123,13 @@ function goCollect() {
   } */
   goForm('collect', 1, '随手记')
 }
+
+function goJoin() {
+  navTo('/pages/home/light/submit', {
+    villageId: querys.value.villageId,
+  });
+}
+onMounted(async () => {
+  await getIsVolunteer();
+});
 </script>

+ 66 - 18
src/pages/dig/forms/list.vue

@@ -1,5 +1,5 @@
 <template>
-  <FlexCol :padding="30">
+  <FlexCol padding="space.md" gap="space.md">
     <Result v-if="error" 
       :title="error"
     />
@@ -11,8 +11,27 @@
           :innerStyle="{ width: querys.isView ? '600rpx' : '460rpx' }"
           @search="search"
         />
-        <Button v-if="!querys.isView" type="primary" @click="newData">+ 新增</Button>
+        <Button v-if="!querys.isView" type="primary" @click="newData">+ 编写</Button>
       </FlexRow>
+      <FlexCol 
+        v-if="!volunteerInfo" 
+        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" />
       <FlexCol :gap="20">
         <Touchable 
@@ -59,13 +78,15 @@
 <script setup lang="ts">
 import { ref } from 'vue';
 import { onPullDownRefresh } from '@dcloudio/uni-app';
-import { alert } from '@/components/dialog/CommonRoot';
 import { DataDateUtils } from '@imengyu/js-request-transform';
 import { useSimplePageListLoader } from '@/components/composeabe/loader/SimplePageListLoader';
 import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
 import { useCollectStore } from '@/store/collect';
 import { useAuthStore } from '@/store/auth';
+import { TaskMenuDef, type TaskMenuDefGoForm, type TaskMenuDefItem } from './tasks';
+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 Image from '@/components/basic/Image.vue';
@@ -79,12 +100,12 @@ import Height from '@/components/layout/space/Height.vue';
 import H4 from '@/components/typography/H4.vue';
 import Touchable from '@/components/feedback/Touchable.vue';
 import XBarSpace from '@/components/layout/space/XBarSpace.vue';
-import { TaskMenuDef } from './tasks';
 import Result from '@/components/feedback/Result.vue';
 
 const subTitle = ref('');
 const searchText = ref('');
 const collectStore = useCollectStore();
+const { getIsVolunteer, volunteerInfo } = useUserTools();
 const authStore = useAuthStore();
 const error = ref('');
 
@@ -106,15 +127,13 @@ const listLoader = useSimplePageListLoader<{
     throw new Error("params.subType");
   if (!params.villageId)
     throw new Error("params.villageId");
-  if (!params.villageVolunteerId)
-    throw new Error("params.villageId");
   let res = await VillageInfoApi.getList(
     collectStore.getCollectModuleId(params.subType),
     params.subType,
     params.subKey ? params.subId : undefined,
     params.subKey,
     params.villageId,
-    querys.value.isView && authStore.isAdmin ? undefined : params.villageVolunteerId,
+    querys.value.isView && authStore.isAdmin && params.villageVolunteerId ? undefined : params.villageVolunteerId,
     querys.value.catalogId,
     page,
     pageSize,
@@ -135,9 +154,21 @@ const listLoader = useSimplePageListLoader<{
     list: list,
     total: list.length,
   };
-});
+}, false);
 
 function newData() {
+  if (!volunteerInfo.value) {
+    confirm({ 
+      title: '提示', 
+      content: "您还不是当前村社的志愿者,请先加入志愿者队伍", 
+      confirmText: '去点亮村落',
+    }).then((res) => {
+      if (res) {
+        goJoin();
+      }
+    });
+    return;
+  }
   if (querys.value.isView) {
     alert({ title: '提示', content: "查看模式下不能新增数据" });
     return;
@@ -167,6 +198,11 @@ function goDetail(id: number) {
 function search() {
   listLoader.reload();
 }
+function goJoin() {
+  navTo('/pages/home/light/submit', {
+    villageId: querys.value.villageId,
+  });
+}
 
 const { querys } = useLoadQuerys({ 
   taskName: '',
@@ -180,33 +216,45 @@ const { querys } = useLoadQuerys({
   subTitle: '',
   isView: false,
 }, async (querys) => {
+
   if (querys.taskName) {
     //普通用户进入预览模式
+    await getIsVolunteer();
+
     const menuDef = TaskMenuDef[querys.taskName];
     if (!menuDef) {
       error.value = '任务不存在';
       return;
     }
-    if (!querys.taskFindCatalogName) {
-      error.value = '查询目录名称不能为空';
-      return;
+    let catalog : TaskMenuDefItem | undefined ;
+    if (querys.taskFindCatalogName) {
+      querys.subTitle = querys.taskFindCatalogName;
+      catalog = menuDef.list.find((p) => p.name === querys.taskFindCatalogName);
+    } else {
+      catalog = menuDef.list[0];
     }
-    const catalog = menuDef.list.find((p) => p.name === querys.taskFindCatalogName);
-    if (!catalog) {
+    if (!catalog || !catalog.goForm) {
       error.value = '查询目录不存在';
       return;
     }
-    querys.catalogId = catalog.id;
+    const goForm = catalog.goForm as TaskMenuDefGoForm;
+    querys.subType = goForm[0];
+    querys.subId = goForm[1];
+    querys.subKey = goForm[2] || 'type';
+    querys.subTitle = goForm[4] || querys.subTitle;
+    querys.catalogId = goForm[5] || 0;
+    querys.villageVolunteerId = volunteerInfo.value?.id || 0;
     listLoader.load(false, querys)
 
   } else {
     //原有采集页进入
-    if (querys.subTitle) {
-      subTitle.value = querys.subTitle;
-      uni.setNavigationBarTitle({  title: subTitle.value + '列表', })
-    }
     listLoader.load(false, querys)
   }
+
+  if (querys.subTitle) {
+    subTitle.value = querys.subTitle;
+    uni.setNavigationBarTitle({  title: subTitle.value + '列表', })
+  }
 });
 
 onPullDownRefresh(() => {

+ 8 - 1
src/pages/dig/forms/tasks.ts

@@ -2,7 +2,14 @@ export type TaskMenuDefGroup = {
   banner: string;
   list: TaskMenuDefItem[];
 }
-export type TaskMenuDefGoForm = [string, number, string|undefined, string|undefined, string|undefined, number|undefined];
+export type TaskMenuDefGoForm = [
+  string,
+  number, 
+  string|undefined, 
+  string|undefined, 
+  string|undefined, 
+  number|undefined
+];
 export type TaskMenuDefItem = {
   title: string;
   desc: string;

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

@@ -107,7 +107,7 @@
       </Button>
     </FlexRow>
 
-    <HomeTitle title="最新动态" />
+    <!-- <HomeTitle title="最新动态" />
     <Construction text="测试数据,没有接口!">
       <FlexCol gap="gap.lg">
         <FlexRow 
@@ -127,7 +127,7 @@
           <Text :text="item.content" fontConfig="contentText" :innerStyle="{ flex: 1 }" />
         </FlexRow>
       </FlexCol>
-    </Construction>
+    </Construction> -->
 
     <HomeTitle title="乡村排名" showMore @moreClicked="navTo('/pages/home/village/rank/village', {
       regionId: currentRegion ?? undefined,

+ 9 - 1
src/pages/home/village/introd/card.vue

@@ -385,10 +385,18 @@ function handleGoJoin() {
 function handleGoNew() {
   navTo('/pages/home/light/help/new');
 }
-function handleGoCollect(taskName?: string) {
+function handleGoCollect(taskName?: string, taskFindCatalogName?: string) {
+  if (!taskName) {
+    navTo('/pages/dig/details', {
+      villageId: villageStore.currentVillage?.id ?? undefined,
+    });
+    return;
+  }
+  
   navTo('/pages/dig/forms/list', {
     villageId: villageStore.currentVillage?.id ?? undefined,
     taskName: taskName,
+    taskFindCatalogName: taskFindCatalogName,
   });
 }
 function handleGoPublish() {