fix: 用dspy原生bare function(get_user/entire_url/bind_customer),去掉env间接调用
This commit is contained in:
parent
79494622b9
commit
2bbe82fd23
@ -2,19 +2,18 @@
|
|||||||
# 参数: code=促销码id 或 id=discount_qr id
|
# 参数: code=促销码id 或 id=discount_qr id
|
||||||
# 已登录: 直接绑定; 未登录: 提示登录/注册
|
# 已登录: 直接绑定; 未登录: 提示登录/注册
|
||||||
|
|
||||||
env = request._run_ns
|
|
||||||
code = params_kw.get('code', '')
|
code = params_kw.get('code', '')
|
||||||
qr_id = params_kw.get('id', '')
|
qr_id = params_kw.get('id', '')
|
||||||
|
|
||||||
user = await env.get_user()
|
user = await get_user()
|
||||||
|
|
||||||
if not user:
|
if not user:
|
||||||
# 未登录 - 显示登录/注册引导
|
# 未登录 - 显示登录/注册引导
|
||||||
back_url = ''
|
back_url = ''
|
||||||
if code:
|
if code:
|
||||||
back_url = env.entire_url('./promote/index.dspy') + f'?code={code}'
|
back_url = entire_url('./promote/index.dspy') + f'?code={code}'
|
||||||
elif qr_id:
|
elif qr_id:
|
||||||
back_url = env.entire_url('./promote/index.dspy') + f'?id={qr_id}'
|
back_url = entire_url('./promote/index.dspy') + f'?id={qr_id}'
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
@ -38,7 +37,7 @@ if not user:
|
|||||||
"label": "登录",
|
"label": "登录",
|
||||||
"css": "primary",
|
"css": "primary",
|
||||||
"actiontype": "link",
|
"actiontype": "link",
|
||||||
"url": env.entire_url('/rbac/user/login.ui') + f"?back={back_url}" if back_url else env.entire_url('/rbac/user/login.ui')
|
"url": entire_url('/rbac/user/login.ui') + f"?back={back_url}" if back_url else entire_url('/rbac/user/login.ui')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -47,7 +46,7 @@ if not user:
|
|||||||
"label": "注册",
|
"label": "注册",
|
||||||
"css": "secondary",
|
"css": "secondary",
|
||||||
"actiontype": "link",
|
"actiontype": "link",
|
||||||
"url": env.entire_url('/rbac/user/register') + f"?back={back_url}" if back_url else env.entire_url('/rbac/user/register')
|
"url": entire_url('/rbac/user/register') + f"?back={back_url}" if back_url else entire_url('/rbac/user/register')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -57,11 +56,10 @@ if not user:
|
|||||||
elif code:
|
elif code:
|
||||||
# 已登录 + 促销码参数 - 绑定促销码
|
# 已登录 + 促销码参数 - 绑定促销码
|
||||||
try:
|
try:
|
||||||
# bind_customer expects promo_code_id
|
|
||||||
bind_params = params_kw.copy()
|
bind_params = params_kw.copy()
|
||||||
bind_params['promo_code_id'] = code
|
bind_params['promo_code_id'] = code
|
||||||
ret = await bind_customer(request, bind_params)
|
ret = await bind_customer(request, bind_params)
|
||||||
home_url = env.entire_url('/')
|
home_url = entire_url('/')
|
||||||
if ret.get('status') == 'success':
|
if ret.get('status') == 'success':
|
||||||
result = {
|
result = {
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user