feat(qr-login): 实现扫码登录功能模块

This commit is contained in:
2025-09-21 22:10:22 +08:00
parent 611f0e3216
commit 16559c76ed
15 changed files with 1329 additions and 54 deletions

View File

@@ -1,5 +1,6 @@
import React from 'react';
import { Button } from '@nutui/nutui-react-taro';
import {View} from '@tarojs/components'
import { Scan } from '@nutui/icons-react-taro';
import Taro from '@tarojs/taro';
import { useQRLogin } from '@/hooks/useQRLogin';
@@ -31,7 +32,6 @@ const QRLoginButton: React.FC<QRLoginButtonProps> = ({
size = 'normal',
text = '扫码登录',
showIcon = true,
className = '',
onSuccess,
onError,
usePageMode = false
@@ -40,6 +40,7 @@ const QRLoginButton: React.FC<QRLoginButtonProps> = ({
// 处理点击事件
const handleClick = async () => {
console.log('处理点击事件handleClick', usePageMode)
if (usePageMode) {
// 跳转到专门的扫码登录页面
if (canScan()) {
@@ -74,12 +75,13 @@ const QRLoginButton: React.FC<QRLoginButtonProps> = ({
loading={isLoading}
disabled={disabled}
onClick={handleClick}
className={className}
>
{showIcon && !isLoading && (
<Scan className="mr-1" />
)}
{isLoading ? '扫码中...' : (disabled && !canScan() ? '请先登录' : text)}
<View className="flex items-center justify-center">
{showIcon && !isLoading && (
<Scan className="mr-1" />
)}
{isLoading ? '扫码中...' : (disabled && !canScan() ? '请先登录' : text)}
</View>
</Button>
);
};