Переглянути джерело

📦 乡源树浇水,施肥动画

快乐的梦鱼 1 день тому
батько
коміт
ffcfa91718

+ 2 - 1
src/components/utils/DialogAction.ts

@@ -8,12 +8,13 @@ import { type App } from "vue";
  * 显示一个文本提示框
  * @param content - 要显示的提示内容
  */
-function toast(content: string) {
+function toast(content: string, duration?: number) {
   if (typeof content!=='string')
     content = '' + content;
   uni.showToast({
     title: content,
     icon: 'none',
+    duration: duration || 2000,
   })
 }
 /**

Різницю між файлами не показано, бо вона завелика
+ 11 - 11
src/pages/home/village/components/VillageTree.vue


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

@@ -174,7 +174,7 @@ onMounted(async () => {
     });
   }
   if (isDevEnv) {
-    //tab.value = 'tree';
+    tab.value = 'tree';
   }
   await waitTimeOut(1000);
 });

+ 20 - 6
src/pages/home/village/introd/tree.vue

@@ -9,6 +9,8 @@
       :treeName="currentVillage.treeName"
       :treeAnimProps="currentVillage.treeImageAnimProps"
       @fruitPick="handlePick"
+      @waterEnd="handleWaterAnimEnd"
+      @fertilizeEnd="handleFertilizeAnimEnd"
     />
     <FlexCol :padding="30">
       <FlexCol>
@@ -288,6 +290,7 @@ async function handleBlessPaySuccessRefresh() {
 }
 
 const popAnimText = ref('');
+const popAnimTextNext = ref('');
 
 function handleFertilize() {
   handlePickOrWaterOrFertilize('fertilize');
@@ -323,18 +326,22 @@ async function handlePickOrWaterOrFertilize(action: 'pick' | 'water' | 'fertiliz
       case 'pick':
         const res = await TreeApi.pick(villageStore.currentVillage.id);
         villageTreeRef.value?.playStateAnimation('collect');
-        toast(res);
+        toast(res, 4000);
         break;
-      case 'water':
+      case 'water': {
         await TreeApi.water(villageStore.currentVillage.id);
+        const addLight = 3;
         villageTreeRef.value?.playStateAnimation('water');
-        toast('浇水成功!感谢您的贡献');
+        toast(`浇水成功!又获得乡源光啦`, 4000);
         break;
-      case 'fertilize':
-         await TreeApi.fertilize(villageStore.currentVillage.id);
+      }
+      case 'fertilize': {
+        await TreeApi.fertilize(villageStore.currentVillage.id);
+        const addLight = 3;
         villageTreeRef.value?.playStateAnimation('fertilize');
-        toast('施肥成功!感谢您的贡献');
+        toast(`浇水成功!又获得乡源光啦`, 4000);
         break;
+      }
     }
     refreshVillageTreeInfo();
     uni.hideLoading();
@@ -348,6 +355,13 @@ async function handlePickOrWaterOrFertilize(action: 'pick' | 'water' | 'fertiliz
   }
 }
 
+function handleWaterAnimEnd() {
+  popAnimText.value = popAnimTextNext.value;  
+}
+function handleFertilizeAnimEnd() {
+  popAnimText.value = popAnimTextNext.value;
+}
+
 async function getFruits() {
   if (!villageStore.currentVillage?.id) 
     return;