101 lines
2.4 KiB
Vue
Raw Normal View History

2025-04-09 18:55:14 +08:00
<template>
<view class="float-container">
2025-04-29 13:26:19 +08:00
<view v-for="(item,index) of props.type" :key="index">
<view class="sub-btn" :style="getPosition(index)" v-if="item === 'defaultPopup'"
:class="{active: isOpen}" @click.stop="handleClick('defaultPopup')">
<span>{{ t('public.mrz') }}</span>
</view>
<view class="sub-btn" :style="getPosition(index)" v-if="item === 'scanRecord'"
:class="{active: isOpen}" @click.stop="handleClick('scanRecord')">
<span>{{ t('public.smjl') }}</span>
</view>
2025-04-09 18:55:14 +08:00
</view>
2025-04-29 13:26:19 +08:00
<view class="main-btn" :class="{active: isOpen}" @click.stop="toggleMenu()"></view>
2025-04-09 18:55:14 +08:00
</view>
</template>
<script lang="ts" setup>
2025-04-29 13:26:19 +08:00
import { reactive, ref, defineEmits,defineProps } from 'vue';
import i18n from '../../locale/index'
import { useI18n } from 'vue-i18n'
const getI18n = useI18n()
const { t, locale } = getI18n
2025-04-09 18:55:14 +08:00
const emit = defineEmits(['scanRecord', 'defaultPopup']);
2025-04-29 13:26:19 +08:00
const props = defineProps({
type:{
type:Array,
default: () => {
return ['scanRecord','defaultPopup']
}
}
})
const isOpen = ref(false);
const showPopup = ref(false);
const toggleMenu = () => { isOpen.value = !isOpen.value; }
2025-04-09 18:55:14 +08:00
const getPosition = (index:any) => {
if (!isOpen.value) return {}
return {
transform: `translate(${5}rpx, ${-((160*index)+160)}rpx)`
}
}
const handleClick = (action:any) => {
2025-04-29 13:26:19 +08:00
emit(action);
2025-04-09 18:55:14 +08:00
isOpen.value = !isOpen.value;
}
2025-04-29 13:26:19 +08:00
const open = () => { showPopup.value = true; }
const close = () => { showPopup.value = false; }
2025-04-09 18:55:14 +08:00
</script>
<style scoped lang="scss">
.float-container {
position: fixed;
right: 30rpx;
bottom: 30rpx;
z-index: 9;
.main-btn {
position: relative;
width: 130rpx;
height: 130rpx;
border-radius: 50%;
background: #3370FF;
color: white;
font-size: 50rpx;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 5rpx 20rpx rgba(0, 0, 0, 0.2);
transition: transform 0.3s;
z-index: 10000;
}
.main-btn.active {
transform: rotate(135deg);
// transform: translate(-50%, -50%);
}
.sub-btn {
position: absolute;
width: 130rpx;
height: 130rpx;
border-radius: 50%;
background: white;
display: flex;
align-items: center;
justify-content: center;
font-size: 40rpx;
opacity: 0;
transform: translate(0, 0);
transition: all 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
box-shadow: 0 5rpx 10rpx rgba(0, 0, 0, 0.1);
font-size: 25rpx;
}
.sub-btn.active {
opacity: 1;
}
}
</style>