vue嵌套H5到APP,安卓键盘顶起页面内容错乱解决方案

news/2024/10/18 16:48:37/

1.h5嵌套到APP,input输入框页面被键盘顶起错乱
2.解决方案:不能使用定位,使用margin-top
3.如果想满屏兼容比如登陆页面 按钮在下面 不允许出现滚动则则需要手动计算margin-top的高度
4.需求 :登陆页面内嵌H5,兼容各个类型的手机不允许出现滑动,满屏展示

<template><view class="box" :style="minHeight"><view @click="goBack"><u-icon name="close" size="32"></u-icon></view><view class="bolid-text">注册CCAPP账号</view><view class="think-text">推荐使用手机验证码登录</view><view class="phone-text">手机号</view><view class="input-sty"><u-input v-model="user.phoneNo" type="number" border="none" placeholder="请输入手机号" /></view><view class="valide-text">短信验证码</view><view class="input-sty"><view style="width: 80%;"><u-input v-model="user.verifyCode" type="number" border="none" maxlength="6" placeholder="请输入验证码" /></view><view><tui-countdown-verify :seconds="90" :successVal="successVal" @send="send" :params="1" radius="70rpx"borderColor="#05CBA3" color="#05CBA3" :resetVal="resetVal"></tui-countdown-verify></view></view><view class="shop" v-show="chanelFlag">渠道门店:{{channelName}}</view><view class="registersIos" :style="{backgroundColor: text =='注册' ? '#04CBA3' :'#696969 ',marginTop: minHeight}" @click="goSubmit">{{text}}</view><view class="xieyiIos">继续即表示您同意 <text style="color: #05CBA3;margin: 0 10rpx;text-decoration: underline;" @click="goProtocol">用户协议</text><text style="color: #05CBA3;margin: 0 10rpx;text-decoration: underline;"@click="goPrivacy">隐私条款</text></view><u-toast ref="uToast" /></view>
</template><script>// let wx1 = require("../../static/jweixin-1.6.0")import {ajax} from '@/ajax.js';import {setPageMinHeight} from '@/fn.js'import tuiCountdownVerify from "@/components/tui-countdown-verify.vue";import {loading,hideLoading,} from "@/fn.js";export default {components: {tuiCountdownVerify,},data() {return {uid: "",value: '',successVal: 0,iswx: false,resetVal: 0,channelName: '',text: '注册',user: {phoneNo: '',verifyCode: '',sharePhoneNo: '',},chanelFlag: false,system:'',minHeight:0}},mounted() {this.minHeight = uni.getSystemInfoSync().windowHeight - 350 + 'rpx' // 重要代码!!!计算出注册按钮到上个盒子的margin-top距离console.log(this.minHeight)},onLoad(e) {if (e.uid) {this.uid = e.uid}this.system = this.detectOS()console.log(this.system)if (e.sharePhoneNo) {uni.setStorageSync('sharePhoneNo', e.sharePhoneNo) //分享者的手机号码}// this.getChannel()if (uni.getStorageSync('sharePhoneNo')) {this.getChannel()this.chanelFlag = true;}let ua = window.navigator.userAgent.toLowerCase();if (ua.match(/MicroMessenger/i) == 'micromessenger') {this.iswx = true;}},onReady() {this.refCode = this.$refs.uCode;},methods: {/*用户协议*/goProtocol() {uni.navigateTo({url: '/pages/agreement/agreement'})},/*隐私政策*/goPrivacy() {uni.navigateTo({url: '/pages/agreement/clause'})},/*返回上一级别*/goBack() {uni.navigateBack(1)},/*获取渠道*/getChannel() {let that = this;ajax("get", '/health/channel/getBySharePhoneNo/' + uni.getStorageSync('sharePhoneNo')).then(res => {console.log('cc')console.log(res)console.log(res.hasOwnProperty("data"))console.log('cc')if(res.hasOwnProperty("data")){that.channelName = res.data.channelName}else{that.channelName = uni.getStorageSync('sharePhoneNo')}})},handleLaunchFn(e) {alert('success', e)},handleErrorFn(e) {alert('fail', e);},handleReadyFn(e) {alert('fail', e);},openMini() {loading()ajax('get', '/applet/nav/toApplet/' + this.uid).then(res => {hideLoading()let cData = JSON.parse(res.msg)location.href = cData.openlink});},/*发送验证码*/send() {let that = this;let reg = /^1[3456789]\d{9}$/;if (this.user.phoneNo == '') {this.resetVal++;this.$refs.uToast.show({message: '请输入手机号码',duration: 500})return false;}if (!reg.test(this.user.phoneNo)) {this.resetVal++;this.$refs.uToast.show({message: '手机号码不正确',duration: 500})return false;}// that.$u.api.getCode({// 	data: {// 		user: {// 			mobile: that.user.mobile// 		}// 	}// }).then(res => {// 	that.successVal++;// 	that.$refs.uToast.show({// 		message: '验证码已发送',// 	})// }).catch(err => {// 	that.resetVal++;// })ajax("get", "/health/user/getVerifyCode", {phoneNo: that.user.phoneNo}).then(res => {that.successVal++;that.$refs.uToast.show({message: '验证码已发送',})})},/*注册*/goSubmit() {let that = this;that.user.sharePhoneNo = uni.getStorageSync('sharePhoneNo')if (that.text == '注册') {ajax("post", "/health/user/login", that.user).then(res => {that.successVal++;that.$refs.uToast.show({message: '注册成功',})if (that.iswx) {let timer = setTimeout(() => {clearTimeout(timer)let timer = null;uni.navigateTo({url: '/pages/browser/index?sharePhoneNo='+ that.user.sharePhoneNo})}, 1000)} else {uni.navigateTo({url: '/pages/loadapp/loadapp?type=a&sharePhoneNo=' + that.user.sharePhoneNo})}}).then(res => {that.text = '注册成功'})} else {uni.navigateTo({url: '/pages/browser/index?sharePhoneNo='+ that.user.sharePhoneNo})}},/*判断页面是ios还是安卓*/detectOS() {var userAgent = navigator.userAgent || navigator.vendor || window.opera;// 检测iOS设备if (/iPad|iPhone|iPod/.test(userAgent) && !window.MSStream) {return 'iOS';}// 检测Android设备if (/Android/.test(userAgent)) {return 'Android';}// 如果不是iOS或Android,则返回其他return 'Other';},}}
</script><style scoped>.box {width: 100%;padding-top: 80rpx;padding-left: 76rpx;padding-right: 76rpx;box-sizing: border-box;height: 100vh;position: relative;/* overflow-y: scroll */}.bolid-text {font-family: PingFangSC, PingFang SC;font-weight: 800;font-size: 48rpx;color: #000000;margin-top: 74rpx;}.think-text {font-family: PingFangSC, PingFang SC;font-weight: 400;font-size: 24rpx;color: #B6B6B6;margin-top: 12rpx;}.phone-text {font-family: PingFangSC, PingFang SC;font-weight: 800;font-size: 32rpx;color: #000000;margin-top: 86rpx;}.valide-text {font-family: PingFangSC, PingFang SC;font-weight: 800;font-size: 32rpx;color: #000000;margin-top: 52rpx;}.input-sty {border-bottom: 2rpx solid #E6E6E6;display: flex;align-items: center;margin-top: 20rpx;padding-bottom: 16rpx;}.u-input {padding: 12rpx 0 !important;}.shop {box-sizing: border-box;margin-top: 62rpx;height: 96rpx;border-radius: 12rpx;border: 2rpx solid #04CBA3;font-family: PingFangSC, PingFang SC;font-weight: 600;font-size: 28rpx;color: #04CBA3;display: flex;justify-content: flex-start;align-items: center;word-break:break-all;padding-left: 20rpx;padding-right: 20rpx;box-sizing: border-box;background-color: #E5FAF5;position: absolute;top: 725rpx;left: 76rpx;}.registersAndro {width: 60%;height: 88rpx;border-radius: 12rpx;color: #FFFFFF;display: flex;justify-content: center;align-items: center;margin-top: 200rpx}.registersIos{width: 60%;height: 88rpx;border-radius: 12rpx;color: #FFFFFF;display: flex;justify-content: center;align-items: center;margin: 0 auto;/* margin-top: calc(100vh - 1000rpx); */}.xieyiAndro {font-family: PingFangSC, PingFang SC;font-weight: 400;font-size: 28rpx;color: #919191;margin: 40rpx auto 0;text-align: center;}.xieyiIos{font-family: PingFangSC, PingFang SC;font-weight: 400;font-size: 28rpx;color: #919191;text-align: center;width: 100%;margin-top: 52rpx;}
</style>

http://www.ppmy.cn/news/1470468.html

相关文章

服务器数据恢复—raid5热备盘同步失败导致阵列崩溃如何恢复数据?

服务器存储数据恢复环境&故障&#xff1a; 某品牌DS5300存储&#xff0c;包含一个存储机头和多个磁盘柜&#xff0c;组建了多组RAID5磁盘阵列。 某个磁盘柜中的一组RAID5阵列由15块数据盘和1块热备硬盘组建。该磁盘柜中的某块硬盘离线&#xff0c;热备盘自动替换并开始同步…

后端不提供文件流接口,前台js使用a标签实现当前表格数据(数组非blob数据)下载成Excel

前言&#xff1a;开发过程中遇到的一些业务场景&#xff0c;如果第三方不让使用&#xff0c;后端不提供接口&#xff0c;就只能拿到table数据(Array)&#xff0c;实现excel文件下载。 废话不多说&#xff0c;直接上代码&#xff0c;方法后续自行封装即可&#xff1a; functio…

CPN Tools学习——时间和队列【重要】

-Timed Color Sets 时间颜色集 -Token Stamps 令牌时间戳 -Event Clock 全局/事件/模拟时钟 -Time Delays on Transitions过渡的时间延迟 - List Color Set列表颜色集 - Queue排队 1.时间颜色集 在定时CPN模型令牌中有&#xff1a; &#xff08;1&#xff09;象征性的颜…

Redis-数据类型-String

文章目录 1、通过客户端连接redis2、查看当前数据库的key的数量3、切换数据库3.1、切换到1数据库3.2、切换到2数据库3.3、切换到默认的数据库&#xff0c;0数据库 4、当前数据库没有数据5、添加键值对6、查看当前库所有key7、清空当前库8、设置存活的秒数&#xff08;例如验证码…

24年计算机等级考试22个常见问题解答❗

24年9月计算机等级考试即将开始&#xff0c;整理了报名中容易遇到的22个问题&#xff0c;大家对照入座&#xff0c;避免遇到了不知道怎么办&#xff1f; 1、报名条件 2、报名入口 3、考生报名之后后悔了&#xff0c;不想考了&#xff0c;能否退费&#xff1f; 4、最多能够报多少…

分类算法和回归算法区别

分类算法和回归算法在机器学习中扮演着不同的角色&#xff0c;它们的主要区别体现在输出类型、应用场景以及算法目标上。以下是对两者区别和使用场景的详细分析&#xff1a; 一、区别 1.输出类型&#xff1a; 分类算法&#xff1a;输出是离散的类别标签&#xff0c;通常表示为…

Sping事件发布机制

一、Spring事件发布 Spring事件发布机制是一种非常重要的通信方式&#xff0c;使用观察者设计模式&#xff0c;可以用于状态通知、业务解耦、异步处理的业务场景。 Spring事件发布对应的几个概念&#xff1a; 1、事件及事件源&#xff08;ApplicationEvent&#xff09; 对…

虚拟机使用桥接模式网络配置

1、获取本机的网络详细信息 windowr 输入cmd 使用ipconfig -all 一样即可 在自己的虚拟机中设置网络 虚拟机中的ip ---------192.168.36.*&#xff0c;不要跟自己的本机ip冲突 网关-----------192.168.36.254 一样即可 dns -----------一样即可&#xff0c;我多写了几个&am…