update pay ui
This commit is contained in:
12
app.py
12
app.py
@@ -4956,10 +4956,13 @@ def generate_jssdk_signature(url, appid, appsecret):
|
||||
def api_wechat_jssdk_config():
|
||||
"""获取微信 JS-SDK 签名配置(用于开放标签)"""
|
||||
try:
|
||||
print(f"[JS-SDK Config] 收到请求")
|
||||
data = request.get_json() or {}
|
||||
url = data.get('url')
|
||||
print(f"[JS-SDK Config] URL: {url}")
|
||||
|
||||
if not url:
|
||||
print(f"[JS-SDK Config] 错误: 缺少 url 参数")
|
||||
return jsonify({
|
||||
'code': 400,
|
||||
'message': '缺少必要参数 url',
|
||||
@@ -4969,8 +4972,11 @@ def api_wechat_jssdk_config():
|
||||
# URL 校验:必须是允许的域名
|
||||
from urllib.parse import urlparse
|
||||
parsed = urlparse(url)
|
||||
allowed_domains = ['valuefrontier.cn', 'www.valuefrontier.cn', 'localhost', '127.0.0.1']
|
||||
if parsed.netloc.split(':')[0] not in allowed_domains:
|
||||
# 扩展允许的域名列表,包括 API 域名
|
||||
allowed_domains = ['valuefrontier.cn', 'www.valuefrontier.cn', 'api.valuefrontier.cn', 'localhost', '127.0.0.1']
|
||||
domain = parsed.netloc.split(':')[0]
|
||||
print(f"[JS-SDK Config] 解析域名: {domain}")
|
||||
if domain not in allowed_domains:
|
||||
return jsonify({
|
||||
'code': 400,
|
||||
'message': 'URL 域名不在允许范围内',
|
||||
@@ -4982,11 +4988,13 @@ def api_wechat_jssdk_config():
|
||||
url = url.split('#')[0]
|
||||
|
||||
# 生成签名(使用公众号配置)
|
||||
print(f"[JS-SDK Config] 开始生成签名...")
|
||||
config = generate_jssdk_signature(
|
||||
url=url,
|
||||
appid=WECHAT_MP_APPID,
|
||||
appsecret=WECHAT_MP_APPSECRET
|
||||
)
|
||||
print(f"[JS-SDK Config] 签名生成完成: {config is not None}")
|
||||
|
||||
if not config:
|
||||
return jsonify({
|
||||
|
||||
@@ -133,26 +133,31 @@ const WxOpenLaunchWeapp = ({
|
||||
...buttonStyle,
|
||||
};
|
||||
|
||||
// 加载中状态
|
||||
// 加载中状态 - 显示可点击的按钮,避免用户等待太久
|
||||
if (loading) {
|
||||
return (
|
||||
<Box display="flex" alignItems="center" justifyContent="center" py={3}>
|
||||
<Spinner size="sm" mr={2} />
|
||||
<Text fontSize="sm" color="gray.500">正在初始化...</Text>
|
||||
</Box>
|
||||
<ChakraButton
|
||||
colorScheme="green"
|
||||
isLoading
|
||||
loadingText="初始化中..."
|
||||
width="100%"
|
||||
style={buttonStyle}
|
||||
>
|
||||
{typeof children === 'string' ? children : '打开小程序'}
|
||||
</ChakraButton>
|
||||
);
|
||||
}
|
||||
|
||||
// 错误状态
|
||||
// 错误状态 - 提供重试选项
|
||||
if (error) {
|
||||
return (
|
||||
<ChakraButton
|
||||
colorScheme="gray"
|
||||
isDisabled
|
||||
colorScheme="orange"
|
||||
onClick={initWxSdk}
|
||||
width="100%"
|
||||
py={3}
|
||||
style={buttonStyle}
|
||||
>
|
||||
{error}
|
||||
点击重试
|
||||
</ChakraButton>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import { getApiBase } from '@utils/apiConfig';
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: getApiBase(),
|
||||
timeout: 10000,
|
||||
timeout: 30000, // 增加到 30 秒,因为首次需要从微信 API 获取 access_token 和 jsapi_ticket
|
||||
withCredentials: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user