This commit is contained in:
oneao committed 2026-03-27 17:22:22 +08:00
1 parent 26721a142e
commit 840d33ef3b
32 files changed
+2068 -590

No files matched your search

@@ -0,0 +1,136 @@
<script lang="js" setup>
import QrcodeVue from "qrcode.vue";
import QRCode from "qrcode";
import { loadDataApi } from "@/request/api";
import { useUserStore } from "@/store/user";
const userStore = useUserStore();
// 用户二维码数据
const userData = ref([]);
// 主二维码链接
const mainUrl = "http://ser215.g3soft.cn:8088/g3ocr-app/#/pages-sub/upload/index";
// Element Plus 图片查看器控制
const showPreview = ref(false);
const previewIndex = ref(0);
const srcList = ref([]);
onMounted(() => {
// loadUserDatas();
});
async function loadUserDatas() {
const response = await loadDataApi("b_user", `b_id <> 'g3soft' AND b_canuse = '1'`, "", ["b_id"]);
if (response.success) {
response.data.forEach((item) => {
userData.value.push({
account: item.b_id,
url: `${mainUrl}?orgid=${encodeURIComponent(userStore.userInfo.orgid)}&bid=${encodeURIComponent(item.b_id)}`,
});
});
}
}
// 生成 base64
async function generateQrBase64(urls) {
srcList.value = [];
for (const item of urls) {
const dataUrl = await QRCode.toDataURL(item, { width: 400 });
srcList.value.push(dataUrl);
}
}
// 打开预览
async function openPreview(index) {
const urls = [mainUrl, ...userData.value.map((u) => u.url)];
await generateQrBase64(urls);
previewIndex.value = index;
showPreview.value = true;
}
</script>
<template>
<div class="page-container">
<!-- 主二维码 -->
<div class="qr-section main-qr">
<h2>统一入口</h2>
<qrcode-vue :value="mainUrl" :size="220" :margin="2" @click.native="openPreview(0)" />
</div>
<el-divider />
<!-- 用户二维码 -->
<!-- <div class="qr-section user-qr">
<h2>用户二维码(免登录,需要启用该账户!)</h2>
<div class="user-qr-list">
<div v-for="(user, index) in userData" :key="index" class="user-qr-item">
<div class="account-name">{{ user.account }}</div>
<qrcode-vue
:value="user.url"
:size="200"
@click.native="openPreview(index + 1)"
:margin="2"
/>
</div>
</div>
</div> -->
<!-- Element Plus 图片查看器 -->
<el-image-viewer
v-if="showPreview"
:url-list="srcList"
:initial-index="previewIndex"
show-progress
@close="showPreview = false"
/>
</div>
</template>
<style scoped lang="scss">
@use "@/styles/mixins.scss" as *;
.page-container {
display: flex;
flex-direction: column;
align-items: center;
height: 100%;
overflow-y: auto;
}
.qr-section {
display: flex;
flex-direction: column;
align-items: center;
width: 100%;
margin-top: 16px;
}
.user-qr {
margin-top: 16px;
}
.qr-section h2 {
margin-bottom: 12px;
font-size: 18px;
font-weight: 600;
}
.user-qr-list {
@include flexGapWrap(10px, 36px);
}
.user-qr-item {
display: flex;
flex-direction: column;
align-items: center;
cursor: pointer;
}
.account-name {
margin-bottom: 6px;
font-size: 14px;
font-weight: 500;
color: #333;
}
</style>