[AI Generated]: fix(Comp): 修复添加用户弹窗的显隐动画逻辑,拆分初始定位与滑入动画,修正隐藏时的 translateY 方向错误

This commit is contained in:
17792275749
2026-04-08 09:45:56 +08:00
parent 7a662d7c34
commit d2c914df79
3 changed files with 58 additions and 43 deletions
@@ -39,46 +39,28 @@ Component({
methods: { methods: {
// 显示对话框 // 显示对话框
showModal() { showModal() {
// 显示遮罩层 // 先瞬间将弹窗移到屏幕下方(duration:0,不产生过渡)
let animation = wx.createAnimation({ let initAnim = wx.createAnimation({ duration: 0 });
duration: 200, initAnim.translateY(1200).step();
timingFunction: "linear", this.setData({ animationData: initAnim.export(), modalStatus: true });
delay: 0 // 留一帧让渲染生效,再执行滑入动画
})
this.animation = animation;
animation.translateY(1200).step();
this.setData({
animationData: animation.export(),
modalStatus: true
})
setTimeout(() => { setTimeout(() => {
let animation = wx.createAnimation({ duration: 300, timingFunction: 'ease' });
animation.translateY(0).step(); animation.translateY(0).step();
this.setData({ this.setData({ animationData: animation.export() });
animationData: animation.export() }, 50);
})
}, 200);
}, },
//隐藏对话框 // 隐藏对话框
hideModal() { hideModal() {
// 隐藏遮罩层 // 执行滑出动画
let animation = wx.createAnimation({ let animation = wx.createAnimation({ duration: 300, timingFunction: 'ease' });
duration: 200,
timingFunction: "linear",
delay: 0
})
this.animation = animation;
animation.translateY(1200).step(); animation.translateY(1200).step();
this.setData({ this.setData({ animationData: animation.export() });
animationData: animation.export(), // 等动画结束后再隐藏节点
})
setTimeout(() => { setTimeout(() => {
animation.translateY(0).step(); this.setData({ modalStatus: false });
this.setData({ }, 300);
animationData: animation.export(),
modalStatus: false
})
}, 200);
}, },
// 关闭弹窗并重置所有数据 // 关闭弹窗并重置所有数据
@@ -99,7 +99,7 @@
</block> </block>
<!-- 家庭用户模式 --> <!-- 家庭用户模式 -->
<block wx:elif="{{userType === 'family'}}"> <block wx:if="{{userType === 'family'}}">
<!-- 姓名(手动输入) --> <!-- 姓名(手动输入) -->
<view class="input"> <view class="input">
<view>姓名:</view> <view>姓名:</view>
@@ -11,7 +11,7 @@
} }
.modal { .modal {
height: 1100rpx; height: 1200rpx;
position: fixed; position: fixed;
bottom: 0; bottom: 0;
left: 0; left: 0;
@@ -54,11 +54,45 @@
overflow: hidden; overflow: hidden;
} }
.seaction>view:last-of-type {
margin-bottom: 0;
}
.select {
width: 100%;
height: 80rpx;
display: flex;
flex-wrap: nowrap;
align-items: center;
padding: 4rpx;
box-sizing: border-box;
margin-bottom: 40rpx;
border-radius: 16rpx;
background-color: #F3F5F8;
}
.select>view {
color: #808080;
flex: 1;
width: 0;
height: 72rpx;
line-height: 72rpx;
font-size: 32rpx;
border-radius: 16rpx;
text-align: center;
}
.selectActive {
color: #1385FA !important;
font-weight: bold;
background-color: #FFFFFF;
}
.only, .only,
.input, .input,
.inputUnit { .inputUnit {
width: 100%; width: 100%;
height: 104rpx; height: 102rpx;
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
margin-bottom: 32rpx; margin-bottom: 32rpx;
@@ -68,22 +102,21 @@
.input>view:nth-of-type(1), .input>view:nth-of-type(1),
.inputUnit>view:nth-of-type(1) { .inputUnit>view:nth-of-type(1) {
color: #333333; color: #333333;
height: 104rpx; height: 102rpx;
font-size: 32rpx; font-size: 32rpx;
line-height: 104rpx; line-height: 102rpx;
} }
.only>view:nth-of-type(2), .only>view:nth-of-type(2),
.inputUnit>view:nth-of-type(2) { .inputUnit>view:nth-of-type(2) {
flex: 1; flex: 1;
width: 0; width: 0;
height: 104rpx; height: 102rpx;
padding: 0 30rpx; padding: 0 30rpx;
border-radius: 16rpx; border-radius: 16rpx;
display: flex; display: flex;
flex-wrap: nowrap; flex-wrap: nowrap;
align-items: center; align-items: center;
background-color: #F5F7FB;
border: 1rpx solid #E6E6EA; border: 1rpx solid #E6E6EA;
} }
@@ -109,7 +142,7 @@
.input>view:nth-of-type(2) { .input>view:nth-of-type(2) {
flex: 1; flex: 1;
width: 0; width: 0;
height: 104rpx; height: 102rpx;
padding: 0 30rpx; padding: 0 30rpx;
border-radius: 16rpx; border-radius: 16rpx;
border: 1rpx solid #E6E6EA; border: 1rpx solid #E6E6EA;
@@ -131,11 +164,11 @@
.searchBtn { .searchBtn {
color: #FFFFFF; color: #FFFFFF;
width: 120rpx; width: 120rpx;
height: 104rpx; height: 102rpx;
font-size: 28rpx; font-size: 28rpx;
font-weight: bold; font-weight: bold;
text-align: center; text-align: center;
line-height: 104rpx; line-height: 102rpx;
margin-left: 16rpx; margin-left: 16rpx;
border-radius: 16rpx; border-radius: 16rpx;
background-color: #1385FA; background-color: #1385FA;