<template>
|
<view v-if="show" class="swm-mask" @touchmove.stop.prevent @tap.stop>
|
<view class="swm-card" @tap.stop>
|
<view class="swm-figure">
|
<view v-if="status === 'waiting'" class="swm-scan-box">
|
<view class="swm-scan-line" />
|
<view class="swm-scan-corner tl" />
|
<view class="swm-scan-corner tr" />
|
<view class="swm-scan-corner bl" />
|
<view class="swm-scan-corner br" />
|
</view>
|
<view v-else-if="status === 'done'" class="swm-check">
|
<view class="swm-check-mark" />
|
</view>
|
<view v-else class="swm-warn">
|
<view class="swm-warn-bar" />
|
<view class="swm-warn-dot" />
|
</view>
|
</view>
|
<view class="swm-title">{{ titleText }}</view>
|
<view class="swm-sub">{{ subText }}</view>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { computed } from "vue";
|
|
const props = defineProps({
|
show: { type: Boolean, default: false },
|
status: { type: String, default: "waiting" },
|
title: { type: String, default: "" },
|
subTitle: { type: String, default: "" },
|
});
|
|
const titleText = computed(() => {
|
if (props.title) return props.title;
|
if (props.status === "done") return "扫码完成";
|
if (props.status === "timeout") return "扫码超时";
|
return "等待扫码";
|
});
|
|
const subText = computed(() => {
|
if (props.subTitle) return props.subTitle;
|
if (props.status === "done") return "正在处理扫码结果";
|
if (props.status === "timeout") return "未收到扫码数据,请重试";
|
return "请对准二维码/条码进行扫描";
|
});
|
</script>
|
|
<style scoped lang="scss">
|
.swm-mask {
|
position: fixed;
|
left: 0;
|
top: 0;
|
right: 0;
|
bottom: 0;
|
z-index: 9999;
|
background: rgba(0, 0, 0, 0.5);
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
}
|
|
.swm-card {
|
width: 620rpx;
|
padding: 36rpx 32rpx 30rpx;
|
background: #ffffff;
|
border-radius: 24rpx;
|
box-shadow: 0 16rpx 44rpx rgba(0, 0, 0, 0.22);
|
display: flex;
|
flex-direction: column;
|
align-items: center;
|
}
|
|
.swm-figure {
|
width: 260rpx;
|
height: 260rpx;
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
margin-bottom: 18rpx;
|
}
|
|
.swm-title {
|
font-size: 34rpx;
|
font-weight: 700;
|
color: rgba(0, 0, 0, 0.88);
|
margin-bottom: 10rpx;
|
}
|
|
.swm-sub {
|
font-size: 26rpx;
|
color: rgba(0, 0, 0, 0.55);
|
text-align: center;
|
line-height: 38rpx;
|
}
|
|
.swm-scan-box {
|
width: 220rpx;
|
height: 220rpx;
|
border-radius: 22rpx;
|
background: rgba(25, 137, 250, 0.06);
|
position: relative;
|
overflow: hidden;
|
}
|
|
.swm-scan-line {
|
position: absolute;
|
left: 14rpx;
|
right: 14rpx;
|
height: 6rpx;
|
top: 18rpx;
|
border-radius: 6rpx;
|
background: linear-gradient(90deg, rgba(25, 137, 250, 0), #1989fa, rgba(25, 137, 250, 0));
|
animation: swmScan 1.2s linear infinite;
|
}
|
|
.swm-scan-corner {
|
position: absolute;
|
width: 34rpx;
|
height: 34rpx;
|
border-color: #1989fa;
|
border-style: solid;
|
}
|
|
.swm-scan-corner.tl {
|
left: 0;
|
top: 0;
|
border-width: 6rpx 0 0 6rpx;
|
border-top-left-radius: 20rpx;
|
}
|
|
.swm-scan-corner.tr {
|
right: 0;
|
top: 0;
|
border-width: 6rpx 6rpx 0 0;
|
border-top-right-radius: 20rpx;
|
}
|
|
.swm-scan-corner.bl {
|
left: 0;
|
bottom: 0;
|
border-width: 0 0 6rpx 6rpx;
|
border-bottom-left-radius: 20rpx;
|
}
|
|
.swm-scan-corner.br {
|
right: 0;
|
bottom: 0;
|
border-width: 0 6rpx 6rpx 0;
|
border-bottom-right-radius: 20rpx;
|
}
|
|
@keyframes swmScan {
|
0% {
|
transform: translateY(0);
|
opacity: 0.9;
|
}
|
90% {
|
opacity: 0.95;
|
}
|
100% {
|
transform: translateY(180rpx);
|
opacity: 0.55;
|
}
|
}
|
|
.swm-check {
|
width: 180rpx;
|
height: 180rpx;
|
border-radius: 90rpx;
|
background: rgba(18, 185, 129, 0.12);
|
border: 6rpx solid rgba(18, 185, 129, 0.85);
|
position: relative;
|
}
|
|
.swm-check-mark {
|
position: absolute;
|
left: 58rpx;
|
top: 72rpx;
|
width: 56rpx;
|
height: 30rpx;
|
border-left: 10rpx solid rgba(18, 185, 129, 0.95);
|
border-bottom: 10rpx solid rgba(18, 185, 129, 0.95);
|
transform: rotate(-45deg);
|
}
|
|
.swm-warn {
|
width: 180rpx;
|
height: 180rpx;
|
border-radius: 90rpx;
|
background: rgba(245, 158, 11, 0.12);
|
border: 6rpx solid rgba(245, 158, 11, 0.9);
|
position: relative;
|
}
|
|
.swm-warn-bar {
|
position: absolute;
|
left: 50%;
|
top: 44rpx;
|
width: 10rpx;
|
height: 72rpx;
|
border-radius: 10rpx;
|
transform: translateX(-50%);
|
background: rgba(245, 158, 11, 0.95);
|
}
|
|
.swm-warn-dot {
|
position: absolute;
|
left: 50%;
|
bottom: 42rpx;
|
width: 14rpx;
|
height: 14rpx;
|
border-radius: 14rpx;
|
transform: translateX(-50%);
|
background: rgba(245, 158, 11, 0.95);
|
}
|
</style>
|