Commit a371c6e4 by liimin

feat(ToolBox): 为浮动操作按钮添加首尾样式区分

- 为 FAB 项动态添加 fab-item-first 和 fab-item-last 样式类
- 新增 getFabItemClass 方法根据索引判断按钮位置
- 新增 getTotalCount 方法计算总按钮数量
- 首个按钮图标容器设置顶部圆角样式
- 末尾按钮图标容器设置底部圆角样式
- 移除统一的圆形边框样式改为条件性圆角
- 优化按钮激活状态的缩放动画效果
1 parent 7e21f29f
......@@ -21,7 +21,7 @@
<!-- 动态数据项 -->
<view v-for="(item, index) in displayData"
:key="index"
class="fab-item"
:class="['fab-item', getFabItemClass(index)]"
@click="selectItem(item)">
<view class="icon-box">
<image v-if="item.shortTitleUrl"
......@@ -34,7 +34,7 @@
<!-- 付款方式 -->
<view v-if="showPayBtn"
class="fab-item"
:class="['fab-item', getFabItemClass(displayData.length)]"
@click="toPay">
<view class="icon-box">
<view class="sprite-icon icon-tool-pay"></view>
......@@ -44,7 +44,7 @@
<!-- 完成接待 -->
<view v-if="type !== 'preview'"
class="fab-item"
:class="['fab-item', getFabItemClass(displayData.length + (showPayBtn ? 1 : 0))]"
@click="finish">
<view class="icon-box">
<view class="sprite-icon icon-tool-finish"></view>
......@@ -198,6 +198,37 @@ const hide = (): void => {
show.value = false;
};
/**
* 获取总数量(包括动态数据、付款按钮、完成接待按钮)
*/
const getTotalCount = (): number => {
let count = displayData.value.length;
if (props.showPayBtn) count++;
if (props.type !== 'preview') count++;
return count;
};
/**
* 获取 FAB 项的样式类(根据索引判断是否为首尾元素)
* @param index 当前索引
*/
const getFabItemClass = (index: number): string[] => {
const classes: string[] = ['fab-item'];
const totalCount = getTotalCount();
// 第一个元素
if (index === 0) {
classes.push('fab-item-first');
}
// 最后一个元素
if (index === totalCount - 1) {
classes.push('fab-item-last');
}
return classes;
};
// ============================================================================
// 暴露给父组件的方法
// ==========================================================================
......@@ -252,18 +283,26 @@ defineExpose({
display: flex;
justify-content: center;
cursor: pointer;
margin-bottom: 10px;
// margin-bottom: 10px;
transition: transform 0.2s ease;
&:active {
transform: scale(0.95);
}
&.fab-item-first .icon-box {
border-radius: 5px 5px 0 0;
}
&.fab-item-last .icon-box {
border-radius: 0 0 5px 5px;
}
.icon-box {
position: relative;
width: 56px;
height: 56px;
border-radius: 50%;
// border-radius: 50%;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
background: #ffffff;
display: flex;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!