/**
* 小程序码显示组件
* 用于 PC 端显示小程序码供用户扫描
*/
import React from 'react';
import {
Box,
VStack,
Text,
Image,
Button,
Modal,
ModalOverlay,
ModalContent,
ModalHeader,
ModalBody,
ModalCloseButton,
useDisclosure,
Icon,
} from '@chakra-ui/react';
import { Smartphone } from 'lucide-react';
// 默认小程序码图片(可替换为实际的小程序码)
// 注意:需要在微信公众平台生成小程序码图片
const DEFAULT_QR_CODE = 'https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=weixin://dl/business/?t=placeholder';
/**
* PC 端小程序码显示组件
* @param {Object} props
* @param {string} [props.path] - 小程序页面路径(用于显示提示)
* @param {string} [props.qrCodeUrl] - 小程序码图片 URL
* @param {React.ReactNode} props.children - 按钮内容
* @param {string} [props.title] - 弹窗标题
* @param {string} [props.description] - 描述文案
* @param {Object} [props.buttonProps] - 按钮属性
*/
const QRCodeDisplay = ({
path = '',
qrCodeUrl,
children,
title = '扫码打开小程序',
description = '请使用微信扫描下方二维码',
buttonProps = {},
}) => {
const { isOpen, onOpen, onClose } = useDisclosure();
// 使用传入的二维码或默认二维码
const qrCode = qrCodeUrl || DEFAULT_QR_CODE;
return (
<>
}
{...buttonProps}
>
{children || '打开小程序'}
{title}
{/* 小程序码图片 */}
加载中...
}
/>
{/* 说明文案 */}
{description}
打开微信,扫一扫即可访问
{/* 提示信息 */}
温馨提示
• 请确保手机已安装微信 App
• 扫码后点击"打开小程序"按钮
{path && (
• 将跳转到: {path}
)}
>
);
};
export default QRCodeDisplay;