Sfoglia il codice sorgente

修改各按钮的处理

lalalashen 2 mesi fa
parent
commit
33d82b79dd

+ 1 - 0
pages/isLand/HuaTian.scss

@@ -3,6 +3,7 @@
 	background-color: rgba(0, 0, 0, 0.6);
 	position: fixed;left:0;top:0;
 	display: flex;flex-direction: column;justify-content: center;align-items: center;
+	z-index: 50;
 }
 .task-board {
   padding: 30rpx;

+ 63 - 12
pages/isLand/HuaTian.vue

@@ -15,9 +15,9 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 收获:点击后,有收获标识的土地上的收获标识图片隐藏,花隐藏,出现杂草
 操作流程:
 默认显示待解锁的田地(其他几个图标都隐藏),点击"解锁荒地",点击"除草",点击"播种",到时间后点击"收获" -->
-	<view class="page">
+	<view class="page" v-if="show">
 		<view class="task-board">
-			<view class="task_day">
+			<view class="task_day" @click="handleTaskDayClick" :class="{'task-day-active': taskDayActive}">
 				<image src="../../static/island/huatian/btn_task_day.png" class="task"></image>
 			</view>
 			<view class="board-title">
@@ -132,6 +132,8 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 		},
 		data() {
 			return {
+				show: false,
+				dataLoaded: false,
 				// 用户ID
 				ssoId: 0,
 				// 田地数据
@@ -174,6 +176,22 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 				weedyFields: [], // 添加可除草的地块列表
 				harvestMode: false, // 添加收获模式状态
 				harvestableFields: [], // 添加可收获的地块列表
+				taskDayActive: false,
+				// 主岛引用
+				mainLand: null,
+			}
+		},
+		watch: {
+			visible: {
+				immediate: true,
+				handler(val) {
+					if (val) {
+						this.fetchData();
+					} else {
+						this.show = false;
+						this.dataLoaded = false;
+					}
+				}
 			}
 		},
 		onLoad() {
@@ -200,6 +218,8 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 		methods: {
 			// 关闭界面
 			onClose() {
+				this.show = false;
+				this.$emit('update:visible', false);
 				this.$emit('close');
 			},
 
@@ -232,8 +252,7 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 								this.flowers = [];
 								for (let i = 1; i <= 7; i++) {
 									// 找到对应的种子数量
-									const seedBag = bagItems.find(item => item.type === 1 && item.tid ===
-										i);
+									const seedBag = bagItems.find(item => item.type === 1 && item.tid === i);
 
 									this.flowers.push({
 										id: i,
@@ -291,12 +310,10 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 											if (land.plant_time) {
 												const plantTime = new Date(land.plant_time);
 												const now = new Date();
-												const growthHours = (now - plantTime) / (1000 *
-													60 * 60);
+												const growthHours = (now - plantTime) / (1000 * 60 * 60);
 
 												// 获取对应种子的生长周期
-												const seed = this.seeds.find(s => s.id === land
-													.state);
+												const seed = this.seeds.find(s => s.id === land.state);
 												const limitHours = seed ? seed.limit_time : 0;
 
 												if (growthHours >= limitHours) {
@@ -308,8 +325,7 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 													// 未成熟,显示生长中
 													field.isGrowing = true;
 													field.seedStage = true;
-													field.remainingTime = Math.ceil((limitHours -
-														growthHours) * 60 * 60);
+													field.remainingTime = Math.ceil((limitHours - growthHours) * 60 * 60);
 													this.startGrowthTimer(fieldIndex);
 												}
 											}
@@ -317,8 +333,7 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 											// 成熟待收割
 											field.hasWeed = false;
 											field.flower = true;
-											field.flowerType = land.flowerType || land
-												.zzid;
+											field.flowerType = land.flowerType || land.zzid;
 											field.growthCompleted = true;
 											field.canHarvest = true;
 										}
@@ -350,11 +365,17 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 													// 如果获取失败,使用默认值
 													this.nextLandPrice = 100;
 												}
+												// 数据加载完成,显示界面
+												this.dataLoaded = true;
+												this.show = true;
 											},
 											fail: (err) => {
 												console.error('获取土地价格异常', err);
 												// 如果获取失败,使用默认值
 												this.nextLandPrice = 100;
+												// 数据加载完成,显示界面
+												this.dataLoaded = true;
+												this.show = true;
 											}
 										});
 										break;
@@ -368,6 +389,8 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 									title: res.data?.msg || '获取数据失败',
 									icon: 'none'
 								});
+								this.dataLoaded = true;
+								this.show = true;
 							}
 						},
 						fail: (err) => {
@@ -376,6 +399,8 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 								title: '网络异常,请重试',
 								icon: 'none'
 							});
+							this.dataLoaded = true;
+							this.show = true;
 						}
 					});
 				} catch (error) {
@@ -384,6 +409,8 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 						title: '网络异常,请重试',
 						icon: 'none'
 					});
+					this.dataLoaded = true;
+					this.show = true;
 				}
 			},
 
@@ -924,6 +951,24 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 					}
 				}, 60000); // 60秒检查一次
 			},
+			handleTaskDayClick() {
+				this.taskDayActive = true;
+				setTimeout(() => {
+					this.taskDayActive = false;
+				}, 200);
+				
+				// 如果mainLand存在,调用其onTaskClick方法
+				if (this.mainLand) {
+					// 关闭当前花田界面
+					// this.onClose();
+					// 打开任务对话框
+					this.mainLand.onTaskClick();
+				}
+			},
+			// 设置mainLand引用
+			setMainLand(mainLand) {
+				this.mainLand = mainLand;
+			},
 		},
 
 	}
@@ -977,4 +1022,10 @@ select_zz:7种花的view,默认应该隐藏,点击播种时显示,播种
 		animation: harvestBlink 1s infinite;
 		z-index: 10;
 	}
+
+	.task-day-active {
+		transform: scale(0.95);
+		opacity: 0.8;
+		transition: all 0.2s ease;
+	}
 </style>

+ 1 - 1
pages/isLand/TaskDialog.vue

@@ -1,5 +1,5 @@
 <template>
-  <custom-dialog :visible="visible" title="" content-width="720rpx" closeImg="/static/island/UI/btn_close.png" closeImgTop="0rpx" @close="onClose">
+  <custom-dialog :visible="visible" title="" content-width="720rpx" background-color="transparent" closeImg="/static/island/UI/btn_close.png" closeImgTop="0rpx" @close="onClose">
     <view class="task-board">
       <view class="board-title">
         <view class="title-dot"></view>

+ 12 - 11
pages/isLand/homeLand.vue

@@ -25,7 +25,7 @@
       <!-- 主岛箭头 -->
       <view class="main-arrow" @click="goToMainLand" :animation="mainArrowAnimation" :style="{ opacity: mainArrowVisible ? 1 : 0 }">
         <image src="/static/island/main_arrow.png" mode="widthFix" style="width: 100rpx;"></image>
-        <text class="main-text">去主岛</text>
+        <text class="main-text">去主岛</text>
       </view>
     </view>
   
@@ -273,10 +273,10 @@ export default {
 			// 播放房子的点击动画
 			this.playAnimation('house');
 			
-			uni.showToast({
-				title: 'House clicked!',
-				icon: 'none'
-			});
+			// uni.showToast({
+			// 	title: 'House clicked!',
+			// 	icon: 'none'
+			// });
 		},
 
 		onTableClick(event) {
@@ -298,10 +298,10 @@ export default {
 			// 播放大厅的点击动画
 			this.playAnimation('task');
 			
-			uni.showToast({
-				title: 'task clicked!',
-				icon: 'none'
-			});
+			// uni.showToast({
+			// 	title: 'task clicked!',
+			// 	icon: 'none'
+			// });
 		},
 
 		playAnimation(type) {
@@ -484,8 +484,9 @@ export default {
 }
 
 .main-arrow {
+//   background: rgba(255, 255, 255, 0.9);
   position: absolute;
-  right: 100rpx;
+  right: 50rpx;
   bottom: 100rpx;  // 改为 bottom 定位
   display: flex;
   flex-direction: column;
@@ -496,7 +497,7 @@ export default {
 
   .main-text {
     color: #ffffff;
-    font-size: 28rpx;
+    font-size: 32rpx;
     text-shadow: 2rpx 2rpx 4rpx rgba(0, 0, 0, 0.5);
     margin-top: 10rpx;
   }

+ 33 - 21
pages/isLand/mainLand.vue

@@ -49,8 +49,8 @@
 
     <!-- 回家箭头 -->
     <view class="home-arrow" @click="goHome" :animation="homeArrowAnimation" :style="{ opacity: homeArrowVisible ? 1 : 0 }">
-      <image src="/static/island/home_arrow.png" mode="widthFix" style="width: 100rpx;"></image>
-      <text class="home-text">回家</text>
+      <!-- <image src="/static/island/home_arrow.png" mode="widthFix" style="width: 100rpx;"></image> -->
+      <text class="home-text">回家</text>
     </view>
 	</view>
   
@@ -80,7 +80,8 @@
     <backpack-dialog :visible.sync="inventoryVisible" @close="onInventoryClose"></backpack-dialog>
     <character-dialog :visible.sync="characterVisible" @close="onCharacterClose"></character-dialog>
     <shop-dialog :visible.sync="shopVisible" :shopName="currentShopName" @close="onShopClose" @buy="onShopBuy"></shop-dialog>
-    <farm-dialog :visible.sync="farmVisible" @close="onFarmClose"></farm-dialog>
+    <hua-tian :visible.sync="huaTianVisible" @close="onHuaTianClose" ref="huaTian"></hua-tian>
+    <task-dialog :visible.sync="taskDialogVisible" @close="onTaskDialogClose"></task-dialog>
   </view> 
 </template>
 
@@ -89,14 +90,16 @@
 import BackpackDialog from '@/components/dialogs/BackpackDialog.vue'
 import CharacterDialog from '@/components/dialogs/CharacterDialog.vue'
 import ShopDialog from '@/components/dialogs/ShopDialog.vue'
-import FarmDialog from './FarmDialog.vue'
+import HuaTian from './HuaTian.vue'
+import TaskDialog from './TaskDialog.vue'
 
 export default {
 	components: {
 		BackpackDialog,
 		CharacterDialog,
 		ShopDialog,
-		FarmDialog
+		HuaTian,
+		TaskDialog
 	},
 	data() {
 		return {
@@ -121,7 +124,8 @@ export default {
 			inventoryVisible: false,
 			characterVisible: false,
 			shopVisible: false,
-			farmVisible: false,
+			huaTianVisible: false,
+			taskDialogVisible: false,
 			homeArrowAnimation: {},
 			homeArrowAnimating: false,
 			homeArrowVisible: false,
@@ -276,13 +280,10 @@ export default {
 			// 播放大厅的点击动画
 			this.playAnimation('farm');
 			
-			// 打开农场对话框
-			this.farmVisible = true;
-			
-			uni.showToast({
-				title: 'farm clicked!111',
-				icon: 'none'
-			});
+			// 打开花田对话框
+			this.huaTianVisible = true;
+			// 将mainLand传递给HuaTian组件
+			this.$refs.huaTian && this.$refs.huaTian.setMainLand(this);
 		},
 
 		onShopClick(event) {
@@ -371,9 +372,9 @@ export default {
 		onShopBuy(item) {
 			console.log('Buying item:', item)
 		},
-		onFarmClose() {
-			console.log('Closing farm dialog...')
-			this.farmVisible = false
+		onHuaTianClose() {
+			console.log('Closing hua tian dialog...')
+			this.huaTianVisible = false
 		},
 		startHomeArrowAnimation() {
 			if (this.homeArrowAnimating) return;
@@ -408,7 +409,18 @@ export default {
 			uni.navigateTo({
 				url: '/pages/isLand/homeLand'
 			});
-		}
+		},
+		// 打开任务对话框
+		onTaskClick() {
+			console.log('Opening task dialog...')
+			this.taskDialogVisible = true
+		},
+		
+		// 关闭任务对话框
+		onTaskDialogClose() {
+			console.log('Closing task dialog...')
+			this.taskDialogVisible = false
+		},
 	}
 }
 </script>
@@ -484,10 +496,10 @@ export default {
 }
 
 .home-arrow {
+//   background: rgba(255, 255, 255, 0.9);
   position: absolute;
-  left: 100rpx;  // 调整到左边位置
-  top: 50%;
-  transform: translateY(-50%);
+  left: 40rpx;  // 调整到左边位置
+  bottom: 460rpx;
   display: flex;
   flex-direction: column;
   align-items: center;
@@ -497,7 +509,7 @@ export default {
 
   .home-text {
     color: #ffffff;
-    font-size: 28rpx;
+    font-size: 32rpx;
     text-shadow: 2rpx 2rpx 4rpx rgba(0, 0, 0, 0.5);
     margin-top: 10rpx;
   }