|
@@ -3,7 +3,9 @@
|
|
|
<FlexCol :margin="[10,0,0,0]">
|
|
<FlexCol :margin="[10,0,0,0]">
|
|
|
<Text textAlign="center" text="一人添果,全村增光;乡源树茂,故土名扬" fontConfig="primaryTitle" fontSize="35rpx" />
|
|
<Text textAlign="center" text="一人添果,全村增光;乡源树茂,故土名扬" fontConfig="primaryTitle" fontSize="35rpx" />
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
- <VillageTree />
|
|
|
|
|
|
|
+ <VillageTree
|
|
|
|
|
+ ref="villageTreeRef"
|
|
|
|
|
+ />
|
|
|
<FlexCol :padding="30">
|
|
<FlexCol :padding="30">
|
|
|
<FlexCol>
|
|
<FlexCol>
|
|
|
<FlexRow center>
|
|
<FlexRow center>
|
|
@@ -36,15 +38,15 @@
|
|
|
|
|
|
|
|
<Height height="space.xl" />
|
|
<Height height="space.xl" />
|
|
|
<FlexRow justify="space-around" :padding="[0, 30]">
|
|
<FlexRow justify="space-around" :padding="[0, 30]">
|
|
|
- <Touchable center direction="column" flexBasis="22%">
|
|
|
|
|
|
|
+ <Touchable center direction="column" flexBasis="22%" @click="handlePick">
|
|
|
<Image src="https://xy.wenlvti.net/app_static/images/village/IconCollect.png" :width="130" mode="widthFix" />
|
|
<Image src="https://xy.wenlvti.net/app_static/images/village/IconCollect.png" :width="130" mode="widthFix" />
|
|
|
<Text text="拾果" fontConfig="contentText" />
|
|
<Text text="拾果" fontConfig="contentText" />
|
|
|
</Touchable>
|
|
</Touchable>
|
|
|
- <Touchable center direction="column" flexBasis="22%">
|
|
|
|
|
|
|
+ <Touchable center direction="column" flexBasis="22%" @click="handleFertilize">
|
|
|
<Image src="https://xy.wenlvti.net/app_static/images/village/IconFertilization.png" :width="130" mode="widthFix" />
|
|
<Image src="https://xy.wenlvti.net/app_static/images/village/IconFertilization.png" :width="130" mode="widthFix" />
|
|
|
<Text text="施肥" fontConfig="contentText" />
|
|
<Text text="施肥" fontConfig="contentText" />
|
|
|
</Touchable>
|
|
</Touchable>
|
|
|
- <Touchable center direction="column" flexBasis="22%">
|
|
|
|
|
|
|
+ <Touchable center direction="column" flexBasis="22%" @click="handleWater">
|
|
|
<Image src="https://xy.wenlvti.net/app_static/images/village/IconWatering.png" :width="130" mode="widthFix" />
|
|
<Image src="https://xy.wenlvti.net/app_static/images/village/IconWatering.png" :width="130" mode="widthFix" />
|
|
|
<Text text="浇水" fontConfig="contentText" textAlign="center" />
|
|
<Text text="浇水" fontConfig="contentText" textAlign="center" />
|
|
|
</Touchable>
|
|
</Touchable>
|
|
@@ -71,7 +73,10 @@
|
|
|
:size="80"
|
|
:size="80"
|
|
|
radius="50%"
|
|
radius="50%"
|
|
|
/>
|
|
/>
|
|
|
- <Text :text="item.content" fontConfig="contentText" :innerStyle="{ flex: 1 }" />
|
|
|
|
|
|
|
+ <FlexCol flex="1">
|
|
|
|
|
+ <Text :text="item.nickname" fontConfig="contentText" :innerStyle="{ flex: 1 }" />
|
|
|
|
|
+ <Text :text="item.content" fontConfig="contentText" :innerStyle="{ flex: 1 }" />
|
|
|
|
|
+ </FlexCol>
|
|
|
<BackgroundBox
|
|
<BackgroundBox
|
|
|
backgroundImage="https://xy.wenlvti.net/app_static/images/village/TagNormal.png"
|
|
backgroundImage="https://xy.wenlvti.net/app_static/images/village/TagNormal.png"
|
|
|
:backgroundCutBorder="[10, 10, 10, 10]"
|
|
:backgroundCutBorder="[10, 10, 10, 10]"
|
|
@@ -84,7 +89,12 @@
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
</SimplePageContentLoader>
|
|
</SimplePageContentLoader>
|
|
|
|
|
|
|
|
- <HomeTitle title="乡源赐福" />
|
|
|
|
|
|
|
+ <HomeTitle
|
|
|
|
|
+ title="乡源赐福"
|
|
|
|
|
+ showMore
|
|
|
|
|
+ moreText="我的订单"
|
|
|
|
|
+ @moreClicked="handleGoBlessOrders"
|
|
|
|
|
+ />
|
|
|
<FlexRow wrap>
|
|
<FlexRow wrap>
|
|
|
<Touchable
|
|
<Touchable
|
|
|
v-for="(item, index) in blessingInfoLoader.content.value"
|
|
v-for="(item, index) in blessingInfoLoader.content.value"
|
|
@@ -116,13 +126,20 @@
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
</FlexCol>
|
|
</FlexCol>
|
|
|
|
|
|
|
|
- <BlessBuyDialog ref="blessBuyDialogRef" :currentBless="currentBless" />
|
|
|
|
|
|
|
+ <BlessBuyDialog
|
|
|
|
|
+ ref="blessBuyDialogRef"
|
|
|
|
|
+ :currentBless="currentBless"
|
|
|
|
|
+ @buyBless="handleBuyBlessConfirm"
|
|
|
|
|
+ />
|
|
|
</template>
|
|
</template>
|
|
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
|
import { ref, watch } from 'vue';
|
|
import { 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 { showError } from '@/common/composeabe/ErrorDisplay';
|
|
|
|
|
+import { navTo } from '@/components/utils/PageAction';
|
|
|
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';
|
|
@@ -138,13 +155,16 @@ 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 blessBuyDialogRef = ref<InstanceType<typeof BlessBuyDialog>>();
|
|
const blessBuyDialogRef = ref<InstanceType<typeof BlessBuyDialog>>();
|
|
|
|
|
+const villageTreeRef = ref<InstanceType<typeof VillageTree>>();
|
|
|
const currentBless = ref<BlessPackageItem>();
|
|
const currentBless = ref<BlessPackageItem>();
|
|
|
|
|
|
|
|
const infoLoader = useSimpleDataLoader(async () => {
|
|
const infoLoader = useSimpleDataLoader(async () => {
|
|
@@ -178,12 +198,24 @@ const infoLoader = useSimpleDataLoader(async () => {
|
|
|
return {
|
|
return {
|
|
|
id: `${logType}-${item.id}`,
|
|
id: `${logType}-${item.id}`,
|
|
|
head: DEFAULT_AVATAR,
|
|
head: DEFAULT_AVATAR,
|
|
|
|
|
+ nickname: item.nickname,
|
|
|
content,
|
|
content,
|
|
|
levelText,
|
|
levelText,
|
|
|
};
|
|
};
|
|
|
}
|
|
}
|
|
|
const { list } = await TreeApi.getRandomGrowthLogFeed(GROWTH_FEED_COUNT, { villageId });
|
|
const { list } = await TreeApi.getRandomGrowthLogFeed(GROWTH_FEED_COUNT, { villageId });
|
|
|
- return list.map(mapGrowthFeedToInfoItem);
|
|
|
|
|
|
|
+ const res = list.map(mapGrowthFeedToInfoItem);
|
|
|
|
|
+ if (res.length > 0)
|
|
|
|
|
+ return res;
|
|
|
|
|
+ return [
|
|
|
|
|
+ {
|
|
|
|
|
+ id: 'default',
|
|
|
|
|
+ head: DEFAULT_AVATAR,
|
|
|
|
|
+ content: '冷冷清清,等你来添光加彩',
|
|
|
|
|
+ nickname: '',
|
|
|
|
|
+ levelText: '第一条',
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
watch(() => villageStore.currentVillage?.id, () => {
|
|
watch(() => villageStore.currentVillage?.id, () => {
|
|
@@ -198,10 +230,97 @@ function handleBuyBless(bless: BlessPackageItem) {
|
|
|
currentBless.value = bless;
|
|
currentBless.value = bless;
|
|
|
blessBuyDialogRef.value?.show();
|
|
blessBuyDialogRef.value?.show();
|
|
|
}
|
|
}
|
|
|
|
|
+async function handleGoBlessOrders() {
|
|
|
|
|
+ if (!await requireLoginAsync('登录后查看我的赐福订单'))
|
|
|
|
|
+ return;
|
|
|
|
|
+ navTo('/pages/home/village/bless/my-orders', {
|
|
|
|
|
+ villageId: villageStore.currentVillage?.id
|
|
|
|
|
+ });
|
|
|
|
|
+}
|
|
|
|
|
+async function handleBuyBlessConfirm() {
|
|
|
|
|
+ if (!currentBless.value || !villageStore.currentVillage?.id)
|
|
|
|
|
+ return;
|
|
|
|
|
+ if (!await requireLoginAsync('登录后为村社赐福,留下你的大名吧'))
|
|
|
|
|
+ return;
|
|
|
|
|
+ try {
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '请稍后...',
|
|
|
|
|
+ });
|
|
|
|
|
+ const order = await TreeApi.createBlessOrder(villageStore.currentVillage?.id, currentBless.value.id);
|
|
|
|
|
+ if (order) {
|
|
|
|
|
+ console.log(order);
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ showError(error);
|
|
|
|
|
+ } finally {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
function handleGoBless() {
|
|
function handleGoBless() {
|
|
|
uni.pageScrollTo({
|
|
uni.pageScrollTo({
|
|
|
scrollTop: 1000,
|
|
scrollTop: 1000,
|
|
|
duration: 300,
|
|
duration: 300,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+function handleFertilize() {
|
|
|
|
|
+ handlePickOrWaterOrFertilize('fertilize');
|
|
|
|
|
+}
|
|
|
|
|
+function handlePick() {
|
|
|
|
|
+ handlePickOrWaterOrFertilize('pick');
|
|
|
|
|
+}
|
|
|
|
|
+function handleWater() {
|
|
|
|
|
+ handlePickOrWaterOrFertilize('water');
|
|
|
|
|
+}
|
|
|
|
|
+async function handlePickOrWaterOrFertilize(action: 'pick' | 'water' | 'fertilize') {
|
|
|
|
|
+ if (!villageStore.currentVillage?.id)
|
|
|
|
|
+ return;
|
|
|
|
|
+ switch (action) {
|
|
|
|
|
+ case 'pick':
|
|
|
|
|
+ if (!await requireLoginAsync('登录后就可以为乡源树拾果了'))
|
|
|
|
|
+ return;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'water':
|
|
|
|
|
+ if (!await requireLoginAsync('登录后就可以为乡源树浇水了'))
|
|
|
|
|
+ return;
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'fertilize':
|
|
|
|
|
+ if (!await requireLoginAsync('登录后就可以为乡源树施肥了'))
|
|
|
|
|
+ return;
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ uni.showLoading({
|
|
|
|
|
+ title: '请稍后...',
|
|
|
|
|
+ });
|
|
|
|
|
+ let res = '';
|
|
|
|
|
+ switch (action) {
|
|
|
|
|
+ case 'pick':
|
|
|
|
|
+ res = await TreeApi.pick(villageStore.currentVillage.id);
|
|
|
|
|
+ villageTreeRef.value?.playStateAnimation('collect');
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'water':
|
|
|
|
|
+ res = await TreeApi.water(villageStore.currentVillage.id);
|
|
|
|
|
+ villageTreeRef.value?.playStateAnimation('water');
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 'fertilize':
|
|
|
|
|
+ res = await TreeApi.fertilize(villageStore.currentVillage.id);
|
|
|
|
|
+ villageTreeRef.value?.playStateAnimation('fertilize');
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ uni.showToast({
|
|
|
|
|
+ title: res,
|
|
|
|
|
+ });
|
|
|
|
|
+ } catch (e) {
|
|
|
|
|
+ uni.hideLoading();
|
|
|
|
|
+ console.log(e);
|
|
|
|
|
+
|
|
|
|
|
+ if (e instanceof RequestApiError && typeof e.data === 'string') {
|
|
|
|
|
+ showError(e.data);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ showError(e);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
</script>
|
|
</script>
|