Browse Source

获取余额事件

ck@123911.net 2 tháng trước cách đây
mục cha
commit
db4959bdf7
3 tập tin đã thay đổi với 43 bổ sung3 xóa
  1. 1 0
      pages/isLand/homeLand.scss
  2. 41 3
      pages/isLand/homeLand.vue
  3. 1 0
      pages/isLand/mainLand.scss

+ 1 - 0
pages/isLand/homeLand.scss

@@ -67,6 +67,7 @@
       pointer-events: auto; /* 货币计数器接收事件 */
       
       .currency-item {
+			min-width: 160rpx;
         display: flex;
         align-items: center;
         background: url('/static/island/UI/money_kuang.png') no-repeat center center;

+ 41 - 3
pages/isLand/homeLand.vue

@@ -38,11 +38,11 @@
         <view class="currency-display" >
           <view class="currency-item">
             <image src="/static/island/UI/wd_icon_coin.png" mode="widthFix" class="currency-icon"></image>
-            <text class="currency-value">9999</text>
+            <text class="currency-value">{{userInfo.num_gmd}}</text>
           </view>
           <view class="currency-item">
             <image src="/static/island/UI/wd_icon_xingyuan.png" mode="widthFix" class="currency-icon"></image>
-            <text class="currency-value">9999</text>
+            <text class="currency-value">{{userInfo.num_gmg}}</text>
           </view>
         </view>
         <view class="ui-buttons">
@@ -151,6 +151,11 @@ export default {
 			],
 			craftingVisible: false,
 			guideManager: null,
+			userInfo: {
+				num_gmd: 0,
+				num_gmg: 0,
+			},
+			moneyTimer: null, // 添加定时器变量
 		}
 	},
 	onLoad() {
@@ -162,6 +167,12 @@ export default {
 				console.log('屏幕宽度:', self.screenWidth);
 			}
 		});
+		this.getUserMoney();
+		
+		// 启动定时器,每2秒更新一次铃钱
+		this.moneyTimer = setInterval(() => {
+			this.getUserMoney();
+		}, 2000);
 	},
 	onShow() {
 		// 检查是否需要显示引导
@@ -178,6 +189,13 @@ export default {
 			}, 1000);
 		}, 300);
 	},
+	onUnload() {
+		// 清除定时器
+		if (this.moneyTimer) {
+			clearInterval(this.moneyTimer);
+			this.moneyTimer = null;
+		}
+	},
 	methods: {
 		loadData() {
 			// 可以在这里加载其他数据
@@ -439,7 +457,27 @@ export default {
 			setTimeout(() => {
 				this.$refs.guideManager && this.$refs.guideManager.startGuide('homeLand');
 			}, 500);
-		}
+		},
+		// 获取用户铃钱
+		getUserMoney() {
+			uni.request({
+				url: this.$apiHost + '/User/getinfo',
+				method: 'GET',
+				data: {
+					uuid: getApp().globalData.uuid
+				},
+				header: {
+					'Content-Type': 'application/x-www-form-urlencoded',
+					'sign': getApp().globalData.headerSign,
+				},
+				success: (res) => {
+					if (res.data) {
+						console.log("res.getUserMoney", res.data)
+						this.userInfo = res.data;
+					}
+				}
+			})
+		},
 	},
 	beforeDestroy() {
 		this.mainArrowAnimating = false;

+ 1 - 0
pages/isLand/mainLand.scss

@@ -69,6 +69,7 @@
         pointer-events: auto; /* 货币计数器接收事件 */
         
         .currency-item {
+			min-width: 160rpx;
           display: flex;
           align-items: center;
           background: url('/static/island/UI/money_kuang.png') no-repeat center center;