2 Commits 24b551c439 ... 33d82b79dd

Author SHA1 Message Date
  lalalashen 33d82b79dd 修改各按钮的处理 2 months ago
  lalalashen 173d658303 商店和任务等触发按钮修改 2 months ago

+ 52 - 1
components/dialogs/ShopDialog.vue

@@ -119,7 +119,48 @@ export default {
             isNew: false
           }
         ],
-        1: [],
+        1: [
+          { 
+            icon: '/static/island/items/item_wood1.png', 
+            name: '杂木材', 
+            detail: '普通木材,用来造普通的东西',
+            price: 100,
+            owned: 3,
+            isNew: false
+          },
+          { 
+            icon: '/static/island/items/item_wood2.png', 
+            name: '松木材', 
+            detail: '松树木材,比一般木材硬一点,可以用来造强度更好的东西',
+            price: 100,
+            owned: 3,
+            isNew: false
+          },
+          { 
+            icon: '/static/island/items/item_mine1.png', 
+            name: '石材', 
+            detail: '匀称规整的石头,适合用来造房子和石器',
+            price: 100,
+            owned: 3,
+            isNew: false
+          },
+          { 
+            icon: '/static/island/items/item_mine2.png', 
+            name: '铁矿石', 
+            detail: '铁矿石,可以练出铁锭',
+            price: 100,
+            owned: 3,
+            isNew: false
+          },
+          { 
+            icon: '/static/island/items/item_blueprint1.png', 
+            name: '斧头图纸', 
+            detail: '制造斧头的图纸,购买学习后可以制作斧头',
+            price: 100,
+            owned: 3,
+            isNew: false
+          }
+        ],
         2: []
       }
     }
@@ -135,6 +176,16 @@ export default {
     },
     dialogVisible(val) {
       this.$emit('update:visible', val)
+    },
+    shopName: {
+      immediate: true,
+      handler(val) {
+        if (val === '材料商店') {
+          this.currentTab = 1
+        } else {
+          this.currentTab = 0
+        }
+      }
     }
   },
   methods: {

+ 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>

+ 14 - 16
pages/isLand/homeLand.vue

@@ -19,13 +19,13 @@
       </view>
 
       <view style="position: absolute;width:200rpx;left:1000rpx; bottom:450rpx;align-items: center;">
-        <image class="taskBoard-image" src="/static/island/building/taskBoard.png" mode="widthFix" style="width:670rpx; position: static;" @click="onTaskClick" :animation="taskAnimationData">	</image>
+        <image class="taskBoard-image" src="/static/island/building/taskBoard.png" mode="widthFix" style="width:670rpx; position: static;" @click="showTask" :animation="taskAnimationData">	</image>
       </view>
 
       <!-- 主岛箭头 -->
       <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>
   
@@ -44,10 +44,7 @@
           </view>
         </view>
         <view class="ui-buttons">
-          <button class="ui-button" @click="showInventory">背包</button>
-          <button class="ui-button" @click="showCharacter">角色</button>
-          <button class="ui-button" @click="showShop">商店</button>
-          <button class="ui-button" @click="showTask">任务</button>
+		  <image src="/static/island/icon_backpack.png" mode="widthFix" style="width:100rpx" @click="showInventory"></image>
         </view>
       </view>
     </view>
@@ -276,10 +273,10 @@ export default {
 			// 播放房子的点击动画
 			this.playAnimation('house');
 			
-			uni.showToast({
-				title: 'House clicked!',
-				icon: 'none'
-			});
+			// uni.showToast({
+			// 	title: 'House clicked!',
+			// 	icon: 'none'
+			// });
 		},
 
 		onTableClick(event) {
@@ -301,10 +298,10 @@ export default {
 			// 播放大厅的点击动画
 			this.playAnimation('task');
 			
-			uni.showToast({
-				title: 'task clicked!',
-				icon: 'none'
-			});
+			// uni.showToast({
+			// 	title: 'task clicked!',
+			// 	icon: 'none'
+			// });
 		},
 
 		playAnimation(type) {
@@ -487,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;
@@ -499,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;
   }

+ 89 - 38
pages/isLand/mainLand.vue

@@ -36,7 +36,7 @@
 		</view>
 
 		<view style="position: absolute;width: 360rpx;left: 910rpx; bottom:108rpx;align-items: center;">
-			<image class="shop-image" src="/static/island/building/2.png" mode="widthFix" style="width:360rpx; position: static;">	</image>
+			<image class="shop-image" src="/static/island/building/2.png" mode="widthFix" style="width:360rpx; position: static;" @click="onShopClick" :animation="shopAnimationData">	</image>
 		</view>
 
 		<view style="position: absolute;width: 360rpx;left: 1498rpx; bottom:75rpx;align-items: center;">
@@ -44,13 +44,13 @@
 		</view>
 
 		<view style="position: absolute;width: 360rpx;left: 1400rpx; bottom:380rpx;align-items: center;">
-			<image class="house-image" src="/static/island/building/1.png" mode="widthFix" style="width:360rpx; position: static;">	</image>
+			<image class="house-image" src="/static/island/building/1.png" mode="widthFix" style="width:360rpx; position: static;" @click="onHouseClick" :animation="houseAnimationData">	</image>
 		</view>
 
     <!-- 回家箭头 -->
     <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>
   
@@ -69,34 +69,37 @@
           </view>
         </view>
         <view class="ui-buttons">
-          <button class="ui-button" @click="showInventory">背包</button>
-          <button class="ui-button" @click="showCharacter">角色</button>
-          <button class="ui-button" @click="showShop">商店</button>
+          <image src="/static/island/icon_backpack.png" mode="widthFix" style="width:100rpx" @click="showInventory" class="ui-icon-button"></image>
+          <!-- <button class="ui-button" @click="showCharacter">角色</button>
+          <button class="ui-button" @click="showShop">商店</button> -->
         </view>
       </view>
     </view>
 
     <!-- 对话框组件 -->
-    <inventory-dialog :visible.sync="inventoryVisible" @close="onInventoryClose"></inventory-dialog>
+    <backpack-dialog :visible.sync="inventoryVisible" @close="onInventoryClose"></backpack-dialog>
     <character-dialog :visible.sync="characterVisible" @close="onCharacterClose"></character-dialog>
-    <shop-dialog :visible.sync="shopVisible" @close="onShopClose" @buy="onShopBuy"></shop-dialog>
-    <farm-dialog :visible.sync="farmVisible" @close="onFarmClose"></farm-dialog>
+    <shop-dialog :visible.sync="shopVisible" :shopName="currentShopName" @close="onShopClose" @buy="onShopBuy"></shop-dialog>
+    <hua-tian :visible.sync="huaTianVisible" @close="onHuaTianClose" ref="huaTian"></hua-tian>
+    <task-dialog :visible.sync="taskDialogVisible" @close="onTaskDialogClose"></task-dialog>
   </view> 
 </template>
 
 
 <script>
-import InventoryDialog from '@/components/dialogs/InventoryDialog.vue'
+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: {
-		InventoryDialog,
+		BackpackDialog,
 		CharacterDialog,
 		ShopDialog,
-		FarmDialog
+		HuaTian,
+		TaskDialog
 	},
 	data() {
 		return {
@@ -113,16 +116,20 @@ export default {
 			islandHeight: 0,
 			houseAnimationData: {},
 			farmAnimationData: {},
+			shopAnimationData: {},
 			houseAnimating: false,
 			farmAnimating: false,
+			shopAnimating: false,
 			baseTranslate: { x: -50, y: 50 },
 			inventoryVisible: false,
 			characterVisible: false,
 			shopVisible: false,
-			farmVisible: false,
+			huaTianVisible: false,
+			taskDialogVisible: false,
 			homeArrowAnimation: {},
 			homeArrowAnimating: false,
 			homeArrowVisible: false,
+			currentShopName: '商店',
 		}
 	},
 	onLoad() {
@@ -255,15 +262,14 @@ export default {
 		onHouseClick(event) {
 			if(this.houseAnimating) return;
 			// 处理点击事件
-			console.log('House clicked!');
+			console.log('house clicked!');
 			
-			// 播放房的点击动画
+			// 播放房的点击动画
 			this.playAnimation('house');
 			
-			uni.showToast({
-				title: 'House clicked!',
-				icon: 'none'
-			});
+			// 设置商店名称为"房屋商店"
+			this.currentShopName = '材料商店';
+			this.shopVisible = true;
 		},
 
 		onFarmClick(event) {
@@ -274,13 +280,24 @@ export default {
 			// 播放大厅的点击动画
 			this.playAnimation('farm');
 			
-			// 打开农场对话框
-			this.farmVisible = true;
+			// 打开花田对话框
+			this.huaTianVisible = true;
+			// 将mainLand传递给HuaTian组件
+			this.$refs.huaTian && this.$refs.huaTian.setMainLand(this);
+		},
+
+		onShopClick(event) {
+			if(this.shopAnimating) return;
+			// 处理点击事件
+			console.log('shop clicked!');
 			
-			uni.showToast({
-				title: 'farm clicked!111',
-				icon: 'none'
-			});
+			// 播放商店的点击动画
+			this.playAnimation('shop');
+			
+			// 设置商店名称为"花店"
+			this.currentShopName = '花店';
+			// 打开商店对话框
+			this.shopVisible = true;
 		},
 
 		playAnimation(type) {
@@ -291,6 +308,8 @@ export default {
 				this.houseAnimating = true;
 			} else if (type === 'farm') {
 				this.farmAnimating = true;
+			} else if (type === 'shop') {
+				this.shopAnimating = true;
 			}
 
 			// 创建动画实例
@@ -310,6 +329,8 @@ export default {
 				this.houseAnimationData = animation.export();
 			} else if (type === 'farm') {
 				this.farmAnimationData = animation.export();
+			} else if (type === 'shop') {
+				this.shopAnimationData = animation.export();
 			}
 
 			// 动画结束后重置状态
@@ -318,6 +339,8 @@ export default {
 					self.houseAnimating = false;
 				} else if (type === 'farm') {
 					self.farmAnimating = false;
+				} else if (type === 'shop') {
+					self.shopAnimating = false;
 				}
 			}, 800);
 		},
@@ -349,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;
@@ -386,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>
@@ -416,14 +450,24 @@ export default {
     flex-direction: column;
     gap: 20rpx;
     
+    .ui-icon-button {
+      transition: transform 0.2s ease;
+      
+      &:active {
+        transform: scale(0.9);
+        opacity: 0.8;
+      }
+    }
+    
     .ui-button {
-      background: rgba(255, 255, 255, 0.9);
-      border: none;
+      //   background: rgba(255, 255, 255, 0.9);
+      //   border: none;
+      width: 120rpx;
       padding: 16rpx 32rpx;
       border-radius: 8rpx;
       font-size: 28rpx;
       color: #333;
-      box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
+      //   box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
       min-width: 120rpx;
       
       &:active {
@@ -431,6 +475,13 @@ export default {
         transform: scale(0.95);
       }
     }
+    
+    .backpack-button {
+      background-image: url('/static/island/icon_backpack.png');
+      background-size: cover;
+      background-position: center;
+      background-repeat: no-repeat;
+    }
   }
 }
 
@@ -445,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;
@@ -458,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;
   }

BIN
static/island/icon_backpack.png