update pay ui

This commit is contained in:
2025-12-12 13:38:54 +08:00
parent 435692ce0f
commit 2a4e2a41ec
2 changed files with 12 additions and 89 deletions

99
app.py
View File

@@ -4637,50 +4637,15 @@ def wechat_callback():
update_wechat_session(state, {'status': new_status, 'user_info': {'user_id': user.id}})
print(f"✅ 微信扫码状态已更新: {new_status}, user_id: {user.id}")
# ⚡ PC 扫码模式:返回简单页面,不重定向(避免 iframe 导航整个页面
# 前端会通过轮询检测到状态变化,自动关闭弹窗
return '''
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>授权成功</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.success {
text-align: center;
color: #52c41a;
}
.success svg {
width: 64px;
height: 64px;
margin-bottom: 16px;
}
.success p {
font-size: 16px;
color: #333;
}
</style>
</head>
<body>
<div class="success">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14"></path>
<polyline points="22 4 12 14.01 9 11.01"></polyline>
</svg>
<p>授权成功</p>
</div>
</body>
</html>
''', 200
# ⚡ PC 扫码模式:重定向到前端回调页面
# 微信扫码登录会跳转整个页面,所以需要重定向到前端处理
pc_redirect_params = urllib.parse.urlencode({
'wechat_login': 'success',
'state': state,
'is_new_user': '1' if is_new_user else '0',
})
print(f"✅ PC 微信登录成功,重定向到前端回调页面")
return redirect(f"/home/wechat-callback?{pc_redirect_params}")
except Exception as e:
print(f"❌ 微信登录失败: {e}")
@@ -4692,50 +4657,8 @@ def wechat_callback():
if wechat_session_exists(state):
update_wechat_session(state, {'status': 'auth_failed', 'error': str(e)})
# ⚡ 返回错误页面,不重定向
return '''
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>授权失败</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
background: #f5f5f5;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
.error {
text-align: center;
color: #ff4d4f;
}
.error svg {
width: 64px;
height: 64px;
margin-bottom: 16px;
}
.error p {
font-size: 16px;
color: #333;
}
</style>
</head>
<body>
<div class="error">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
<circle cx="12" cy="12" r="10"></circle>
<line x1="15" y1="9" x2="9" y2="15"></line>
<line x1="9" y1="9" x2="15" y2="15"></line>
</svg>
<p>授权失败,请重试</p>
</div>
</body>
</html>
''', 200
# ⚡ 重定向到首页并显示错误
return redirect('/home?error=wechat_login_failed')
@app.route('/api/auth/login/wechat', methods=['POST'])

View File

@@ -492,7 +492,7 @@ export default function WechatRegister() {
width="300"
height="350"
scrolling="no"
sandbox="allow-scripts allow-same-origin allow-forms allow-popups"
sandbox="allow-scripts allow-same-origin allow-forms allow-popups allow-top-navigation"
allow="clipboard-write"
style={{
border: 'none',