Browse Source

监听键盘高度 控制 底部文字显示隐藏

Qukatie 2 days ago
parent
commit
a037e20054
1 changed files with 17 additions and 21 deletions
  1. 17 21
      pages/login/index.vue

+ 17 - 21
pages/login/index.vue

@@ -47,11 +47,11 @@
 
 
 		</view>
-		<view class="pact">
+		<view class="pact"  v-show="!keyboardShow">
 			<view class="pact-a">
 				<radio value="pactChecked" activeBackgroundColor="#3ba662" activeBorderColor="#3ba662"
 					borderColor="#3ba662" color="#fff" @click="pactChange" />
-				<view>我已阅读并同意<text @click="toPact">《用户协议》</text>和<text @click="toPact">《隐私协议》</text></view>
+				<view>我已阅读并同意<text>《用户协议》</text>和<text>《隐私协议》</text></view>
 			</view>
 		</view>
 	</view>
@@ -66,6 +66,7 @@
 	export default {
 		data() {
 			return {
+				keyboardShow:false,
 				loading: false,
 				pactChecked: false,
 				second: 60, //默认60秒
@@ -77,27 +78,22 @@
 			};
 		},
 		onLoad() {
-			this.checkNetworkPermission();
 		},
-		methods: {
-			async checkNetworkPermission() {
-				try {
-					const status = await uni.getNetworkType();
-					console.log('网络状态:', status);
-				} catch (error) {
-					console.error('网络权限检测失败:', error);
-					uni.showModal({
-						title: '网络权限未授权',
-						content: '请开启网络权限以正常使用应用功能',
-						confirmText: '去设置',
-						success: (res) => {
-							if (res.confirm) {
-								uni.openSetting();
-							}
-						}
-					});
+		onShow() {
+			// 监听键盘高度变化
+			uni.onKeyboardHeightChange((res) => {
+				// 根据键盘高度调整布局
+				if (res.height > 0) {
+					this.keyboardShow=true
+				} else {
+					this.keyboardShow=false
 				}
-			},
+			});
+		},
+		onUnload() {
+		  uni.offKeyboardHeightChange();
+		},
+		methods: {
 			pactChange() {
 				this.pactChecked = true
 			},