shop-front-end/src/components/QrCodeHover/index.vue

58 lines
1.5 KiB
Vue
Raw Normal View History

2025-03-21 16:59:44 +08:00
<template>
<div class="qr-container w-[40px] h-[48px] flex-c navbar-bg-hover" @mouseenter="showQr = true"
@mouseleave="showQr = false">
<el-icon :size="20">
<IconifyIconOffline :icon="Iphone" />
</el-icon>
<div v-if="showQr" class="qr-popover">
<ReQrcode text="http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth" :options="{ width: 200 }" />
<div class="qr-tip">微信扫码访问</div>
2025-03-31 09:41:56 +08:00
<el-button class="copy-btn" type="primary" size="small" @click="copyLink">
复制链接
</el-button>
2025-03-21 16:59:44 +08:00
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
2025-03-31 09:41:56 +08:00
import { ElMessage } from 'element-plus'
2025-03-21 16:59:44 +08:00
import ReQrcode from '@/components/ReQrcode'
import Iphone from "@iconify-icons/ep/iphone";
2025-03-31 09:41:56 +08:00
import { copyTextToClipboard } from "@pureadmin/utils";
2025-03-21 16:59:44 +08:00
const showQr = ref(false)
2025-03-31 09:41:56 +08:00
const copyLink = () => {
const success = copyTextToClipboard('http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth');
success ? ElMessage.success('链接复制成功') : ElMessage.error('复制失败,请手动复制');
}
2025-03-21 16:59:44 +08:00
</script>
<style lang="scss" scoped>
.qr-container {
position: relative;
.qr-popover {
position: absolute;
top: 100%;
right: 0;
padding: 12px;
background: #fff;
border-radius: 4px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
z-index: 999;
2025-03-31 09:41:56 +08:00
display: flex;
flex-direction: column;
align-items: center;
2025-03-21 16:59:44 +08:00
}
.qr-tip {
text-align: center;
font-size: 12px;
color: #666;
margin-top: 8px;
}
}
</style>