|
@@ -5,6 +5,7 @@
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
<VillageTree
|
|
<VillageTree
|
|
|
ref="villageTreeRef"
|
|
ref="villageTreeRef"
|
|
|
|
|
+ @fruitPick="handlePick"
|
|
|
/>
|
|
/>
|
|
|
<FlexCol :padding="30">
|
|
<FlexCol :padding="30">
|
|
|
<FlexCol>
|
|
<FlexCol>
|
|
@@ -57,10 +58,10 @@
|
|
|
</FlexRow>
|
|
</FlexRow>
|
|
|
|
|
|
|
|
<HomeTitle title="最新动态" />
|
|
<HomeTitle title="最新动态" />
|
|
|
- <SimplePageContentLoader :loader="infoLoader" :emptyView="{ text: '冷冷清清,等你来添光加彩' }">
|
|
|
|
|
|
|
+ <SimplePageContentLoader :loader="activityLoader" :emptyView="{ text: '冷冷清清,等你来添光加彩' }">
|
|
|
<FlexCol gap="gap.lg">
|
|
<FlexCol gap="gap.lg">
|
|
|
<FlexRow
|
|
<FlexRow
|
|
|
- v-for="item in infoLoader.content.value" :key="item.id"
|
|
|
|
|
|
|
+ v-for="item in activityLoader.content.value" :key="item.id"
|
|
|
backgroundColor="background.tertiary"
|
|
backgroundColor="background.tertiary"
|
|
|
radius="radius.md"
|
|
radius="radius.md"
|
|
|
:padding="[20, 30]"
|
|
:padding="[20, 30]"
|
|
@@ -134,12 +135,13 @@
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
-import { ref, watch } from 'vue';
|
|
|
|
|
|
|
+import { onBeforeMount, onMounted, ref, watch } from 'vue';
|
|
|
import { useVillageStore } from '@/store/village';
|
|
import { useVillageStore } from '@/store/village';
|
|
|
import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
|
|
import { useSimpleDataLoader } from '@/components/composeabe/loader/SimpleDataLoader';
|
|
|
-import { useReqireLogin } from '@/common/composeabe/RequireLogin';
|
|
|
|
|
|
|
+import { useRequireLogin } from '@/common/composeabe/RequireLogin';
|
|
|
import { showError } from '@/common/composeabe/ErrorDisplay';
|
|
import { showError } from '@/common/composeabe/ErrorDisplay';
|
|
|
import { navTo } from '@/components/utils/PageAction';
|
|
import { navTo } from '@/components/utils/PageAction';
|
|
|
|
|
+import { RequestApiError, SimpleTimer } from '@imengyu/imengyu-utils';
|
|
|
import HomeTitle from '@/common/components/parts/HomeTitle.vue';
|
|
import HomeTitle from '@/common/components/parts/HomeTitle.vue';
|
|
|
import Text from '@/components/basic/Text.vue';
|
|
import Text from '@/components/basic/Text.vue';
|
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
import FlexCol from '@/components/layout/FlexCol.vue';
|
|
@@ -155,19 +157,18 @@ import Progress from '@/components/display/Progress.vue';
|
|
|
import TreeApi, { type BlessPackageItem, type GrowthLogFeedItem } from '@/api/light/TreeApi';
|
|
import TreeApi, { type BlessPackageItem, type GrowthLogFeedItem } from '@/api/light/TreeApi';
|
|
|
import SimplePageContentLoader from '@/components/loader/SimplePageContentLoader.vue';
|
|
import SimplePageContentLoader from '@/components/loader/SimplePageContentLoader.vue';
|
|
|
import BlessBuyDialog from '../dialogs/BlessBuyDialog.vue';
|
|
import BlessBuyDialog from '../dialogs/BlessBuyDialog.vue';
|
|
|
-import { RequestApiError } from '@imengyu/imengyu-utils';
|
|
|
|
|
|
|
|
|
|
const GROWTH_FEED_COUNT = 6;
|
|
const GROWTH_FEED_COUNT = 6;
|
|
|
const DEFAULT_AVATAR = 'https://xy.wenlvti.net/app_static/images/village/PlaceholderVolunteer.png';
|
|
const DEFAULT_AVATAR = 'https://xy.wenlvti.net/app_static/images/village/PlaceholderVolunteer.png';
|
|
|
|
|
|
|
|
const villageStore = useVillageStore();
|
|
const villageStore = useVillageStore();
|
|
|
-const { requireLoginAsync } = useReqireLogin();
|
|
|
|
|
|
|
+const { requireLoginAsync } = useRequireLogin();
|
|
|
|
|
|
|
|
const blessBuyDialogRef = ref<InstanceType<typeof BlessBuyDialog>>();
|
|
const blessBuyDialogRef = ref<InstanceType<typeof BlessBuyDialog>>();
|
|
|
const villageTreeRef = ref<InstanceType<typeof VillageTree>>();
|
|
const villageTreeRef = ref<InstanceType<typeof VillageTree>>();
|
|
|
const currentBless = ref<BlessPackageItem>();
|
|
const currentBless = ref<BlessPackageItem>();
|
|
|
|
|
|
|
|
-const infoLoader = useSimpleDataLoader(async () => {
|
|
|
|
|
|
|
+const activityLoader = useSimpleDataLoader(async () => {
|
|
|
const villageId = villageStore.currentVillage?.id;
|
|
const villageId = villageStore.currentVillage?.id;
|
|
|
if (!villageId) return [];
|
|
if (!villageId) return [];
|
|
|
|
|
|
|
@@ -219,7 +220,8 @@ const infoLoader = useSimpleDataLoader(async () => {
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
watch(() => villageStore.currentVillage?.id, () => {
|
|
watch(() => villageStore.currentVillage?.id, () => {
|
|
|
- infoLoader.reload();
|
|
|
|
|
|
|
+ activityLoader.reload();
|
|
|
|
|
+ getFruits();
|
|
|
});
|
|
});
|
|
|
const blessingInfoLoader = useSimpleDataLoader(async () => {
|
|
const blessingInfoLoader = useSimpleDataLoader(async () => {
|
|
|
const res = await TreeApi.getBlessList({ page: 1, pageSize: 18 });
|
|
const res = await TreeApi.getBlessList({ page: 1, pageSize: 18 });
|
|
@@ -323,4 +325,22 @@ async function handlePickOrWaterOrFertilize(action: 'pick' | 'water' | 'fertiliz
|
|
|
showError(e);
|
|
showError(e);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+async function getFruits() {
|
|
|
|
|
+ if (!villageStore.currentVillage?.id)
|
|
|
|
|
+ return;
|
|
|
|
|
+ const res = await TreeApi.dropFruit(villageStore.currentVillage.id);
|
|
|
|
|
+ if (res) {
|
|
|
|
|
+ villageTreeRef.value?.createFruits(res.fruitRemain);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+const refreshFruitTimer = new SimpleTimer(undefined, () => getFruits(), 15000);
|
|
|
|
|
+
|
|
|
|
|
+onMounted(() => {
|
|
|
|
|
+ refreshFruitTimer.start();
|
|
|
|
|
+});
|
|
|
|
|
+onBeforeMount(() => {
|
|
|
|
|
+ refreshFruitTimer.stop();
|
|
|
|
|
+});
|
|
|
</script>
|
|
</script>
|