Browse Source

💊 限制相册加入后才能上传

快乐的梦鱼 1 month ago
parent
commit
94ed099887
2 changed files with 25 additions and 5 deletions
  1. 20 2
      src/pages/home/village/gallery/index.vue
  2. 5 3
      src/pages/home/village/introd/card.vue

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

@@ -73,12 +73,13 @@
 </template>
 
 <script setup lang="ts">
-import { computed } from 'vue';
+import { computed, onMounted, ref } from 'vue';
 import { useSimplePageListLoader } from '@/components/composeabe/loader/SimplePageListLoader';
 import { useAuthStore } from '@/store/auth';
 import { backAndCallOnPageBack, callPrevOnPageBack, navTo } from '@/components/utils/PageAction';
 import { useLoadQuerys } from '@/components/composeabe/LoadQuerys';
 import { confirm } from '@/components/dialog/CommonRoot';
+import { useUserTools } from '@/common/composeabe/UserTools';
 import Text from '@/components/basic/Text.vue';
 import BackgroundBox from '@/components/display/block/BackgroundBox.vue';
 import IconButton from '@/components/basic/IconButton.vue';
@@ -92,7 +93,6 @@ import Empty from '@/components/feedback/Empty.vue';
 import Height from '@/components/layout/space/Height.vue';
 import GalleryApi, { type GalleryItem } from '@/api/light/GalleryApi';
 import VillageGalleryUpload from '../components/VillageGalleryUpload.vue';
-import Avatar from '@/components/display/Avatar.vue';
 
 const { querys } = useLoadQuerys({
   villageId: 0,
@@ -100,6 +100,8 @@ const { querys } = useLoadQuerys({
 });
 
 const authStore = useAuthStore();
+const { getIsJoinedVillage } = useUserTools();
+const isJoined = ref(false);
 
 const galleryLoader = useSimplePageListLoader(30, async (page, pageSize) => {
   return await GalleryApi.getAlbumList({
@@ -133,6 +135,18 @@ function editImage(item: GalleryItem) {
 }
 
 function uploadImage() {
+  if (!isJoined.value) {
+    confirm({
+      content: '您还没有加入村社,无法上传图片哦,请先加入村社后再上传图片',
+      icon: 'prompt',
+      confirmText: '去加入',
+    }).then((res) => {
+      if (res) {
+        backAndCallOnPageBack('backShowVillageJoin', {});
+      }
+    });
+    return;
+  }
   if (isOverMaxCount.value) {
     confirm({
       content: '您最多只能上传' + querys.value.maxCount + '张图片哦,升级村社等级可以获得更多照片上传权益',
@@ -150,6 +164,10 @@ function uploadImage() {
   });
 }
 
+onMounted(async () => {
+  isJoined.value = await getIsJoinedVillage(querys.value.villageId);
+});
+
 defineExpose({
   onPageBack: (name: string, data: Record<string, unknown>) => {
     if (data.needRefresh) {

+ 5 - 3
src/pages/home/village/introd/card.vue

@@ -635,13 +635,15 @@ defineExpose({
   onPageBack: (name: string, data: Record<string, unknown>) => {
     if (name === 'refreshVillageGrallery') {
       villageGalleryRef.value?.refresh();
-    } else if (name === 'showVillageUpgrade') {
-      upgradeRef.value?.show();
     } else if (name === 'refreshOfficialAccount') {
       const tag = listActiveTag.value;
       listActiveTag.value = '';
       setTimeout(() => listActiveTag.value = tag, 100);
-    }
+    } else if (name === 'showVillageUpgrade') {
+      upgradeRef.value?.show();
+    } else if (name === 'backShowVillageJoin') {
+      handleGoJoin();
+    } 
   },
 });
 </script>