Files
h5-meike/components/gmy-float-touch/gmy-float-touch.vue
T
xuchaoandClaude Opus 4.8 f767aa93de fix: 设备适配 —— 宽屏居中锁定手机尺寸 + 全面屏底部安全区
宽屏(桌面/平板):
- pages.json 配置 rpxCalcMaxDeviceWidth=750/rpxCalcBaseDeviceWidth=375,
  窗口超过 750px 时 rpx 换算基准锁定为 375px(uni-app 官方机制),不再随屏幕拉伸
- 页面列宽 750rpx 居中展示,两侧露出底色+阴影形成手机框视觉
- 固定底栏统一 left/right:0+margin:auto 视口居中,与页面列对齐
- 悬浮球及菜单项宽屏时锚定到页面列左缘

全面屏(iPhone 刘海屏):
- 订单底栏/订单详情按钮栏/弹窗确认栏用同色边框向下延伸覆盖 home 指示条区域
- 悬浮按钮(完成/选择)整体上移避开安全区
- 确认订单页底栏改为 bottom 锚定(原来用 JS 计算 top)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-21 08:57:40 +08:00

207 lines
4.6 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template name="gmy-float-touch">
<view>
<view @touchmove.stop.prevent = "doNothing" >
<view class="box" style="z-index: 999;" @click="show" :style="{top:top+'px',left:left + 'px'}" @touchmove="touchmove" @touchend="touchend">
<image :src="mainImg" mode="aspectFill" :animation="animationData" ></image>
<!-- <text style="font-size: 20rpx;color: #fff;">订单</text> -->
</view>
<!-- <view class="menu " :class="{menu0:!isShow&&isleft,menu1:isShow&&isleft ,menu1R:isShow&& !isleft ,menu0R:!isShow&& !isleft}" :style="{top:(top-75) +'px'}" @tap="menuClick(1)" >
<image :src="imgLists[0]" mode=""></image>
</view> -->
<!-- xuchao: 质惠游一期只有门票模块,仅保留"门票订单"菜单项 -->
<view class="menu " :class="{menu0:!isShow&&isleft,menu4:isShow&&isleft ,menu4R:isShow&& !isleft ,menu0R:!isShow&& !isleft}" :style="{top:top+'px'}" @tap="menuClick(4)">
<image :src="imgLists[3]" mode="aspectFill"></image>
</view>
</view>
</view>
</template>
<script>
export default{
name:"gmy-float-touch",
data(){
return {
isShow:false,
top:500,
left:3,
right:3,
isleft:true,
animationData:''
}
},
props:{
imgLists:{
type:Array
},
mainImg:{
type:String,
default:"../../static/main.png"
}
},
methods:{
doNothing:function(){},
show:function(){
this.isShow = !this.isShow;
this.spred();
},
touchmove:function(e){
if(this.isShow){
return
}
var position = e.touches[0];
var wHeight = this.getSystemInfo('H');
if(position.pageY>50 && position.pageY+50 < wHeight){
this.top = position.pageY-20;
}
this.left = position.pageX;
},
touchend:function(e){
var wWidth = this.getSystemInfo('W');
const pageX = e.changedTouches[0].clientX;
if(pageX > wWidth*0.5){
this.isleft = false;
this.left = wWidth-50;
}
else{
this.isleft = true;
this.left = 3;
}
},
menuClick:function(index){
this.$emit("menuClick",index);
},
getSystemInfo:function(type){
var result;
const screen = uni.getSystemInfoSync();
const wHeight = screen.windowHeight;
const wWidth = screen.windowWidth;
switch(type){
case 'H':result = wHeight;break;
case 'W':result = wWidth;break;
default: result = 'Err';
}
return result;
},
spred:function(e){
var animation = uni.createAnimation({
duration: 200,
timingFunction: 'ease',
});
this.animationData = animation.export();
if(this.isShow){
animation.rotate(135).step();
}
else{
animation.rotate(0).step();
}
this.animationData = animation.export();
},
}
}
</script>
<style lang="scss">
image{
width: 80upx;
height: 80upx;
z-index: 99;
// margin:10upx 20upx 10upx 20upx;
}
.box{
position: fixed;
left: 5upx;
top: 70%;
width: 80upx;
height: 80upx;
// border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
// background-color: rgba($color: #777, $alpha: 0.4);
}
.menu{
color:white;
position: fixed;
width: 80upx;
height: 80upx;
// border-radius: 50%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
// background-color: rgba($color: #777, $alpha: 0.4);
}
.menu0{
left: 5upx;
opacity: 0;
transition: top 0.2s, left 0.2s, opacity 0.2s;
}
.menu1{
left: 20upx;
transition: top 0.2s, left 0.2s, opacity 0.2s;
}
.menu2{
left: 10upx;
transition: top 0.2s, left 0.2s, opacity 0.2s;
}
.menu3{
left: 205upx;
transition: top 0.2s, left 0.2s, opacity 0.2s;
}
.menu4{
left: 106upx;
transition: top 0.2s, left 0.2s, opacity 0.2s;
}
.menu5{
left: 5upx;
transition: top 0.2s, left 0.2s, opacity 0.2s;
}
.menu0R{
right: 10upx;
opacity: 0;
transition: top 0.2s, right 0.2s, opacity 0.2s;
}
.menu1R{
right: 20upx;
transition: top 0.2s, right 0.2s, opacity 0.2s;
}
.menu2R{
right: 20upx;
transition: top 0.2s, right 0.2s, opacity 0.2s;
}
.menu3R{
right: 210upx;
transition: top 0.2s, right 0.2s, opacity 0.2s;
}
.menu4R{
right: 106upx;
transition: top 0.2s, right 0.2s, opacity 0.2s;
}
.menu5R{
right: 20upx;
transition: top 0.2s, right 0.2s, opacity 0.2s;
}
/* #ifdef H5 */
// xuchao: 宽屏时页面列居中(375px),悬浮球及菜单同步锚定到列左缘,避免脱离页面
@media screen and (min-width: 751px) {
.box {
left: calc(50vw - 184px) !important;
}
.menu0, .menu0R {
left: calc(50vw - 184px) !important;
right: auto !important;
}
.menu4, .menu4R {
left: calc(50vw - 134px) !important;
right: auto !important;
}
}
/* #endif */
</style>