fix: 客户UI改用client API,简化表单字段

- create_validate.ui: 去掉callback_url/project_name,只保留vendor下拉,提交到rl_verify.dspy
- rl_verify.dspy: 自动用orgid作为project_name,返回Message widget含h5_link
- upload_asset.ui: 增加vendor下拉,vendor_group_id改为可选下拉(从已认证组合中选)
- 新增get_org_groups.dspy: 返回当前org已认证的vendor_group_id列表
- rl_upload.dspy: 返回Message widget格式
This commit is contained in:
yumoqing 2026-05-29 10:44:19 +08:00
parent 38650389b1
commit ac50a223b5
5 changed files with 129 additions and 86 deletions

View File

@ -0,0 +1,17 @@
import json
from appPublic.log import debug
org_id = (await get_userorgid()) or '0'
result = await rl_query_groups(org_id)
groups = result.get('groups', [])
rows = []
for g in groups:
vid = g.get('vendor_group_id', '')
vendor = g.get('vendor', '')
if vid:
rows.append({"value": vid, "text": f"{vendor} - {vid}"})
debug(f"get_org_groups: org={org_id}, count={len(rows)}")
return json.dumps(rows, ensure_ascii=False)

View File

@ -1,16 +1,38 @@
import json
vendor_group_id = params_kw.get('vendor_group_id', '') vendor_group_id = params_kw.get('vendor_group_id', '')
source_url = params_kw.get('source_url', '') source_url = params_kw.get('source_url', '')
asset_type = params_kw.get('asset_type', 'Image') asset_type = params_kw.get('asset_type', 'Image')
name = params_kw.get('name', '') name = params_kw.get('name', '')
if not vendor_group_id or not source_url: if not vendor_group_id or not source_url:
return {"success": False, "message": "参数缺失"} return json.dumps({
"widgettype": "Message",
"options": {"message": "请选择认证组合并提供素材URL", "type": "error"}
})
# If source_url is base64 data or local path, convert to public URL # If source_url is base64 data or local path, convert to public URL
if source_url.startswith('data:') or (not source_url.startswith('http') and len(source_url) < 8000): if source_url.startswith('data:') or (not source_url.startswith('http') and len(source_url) < 8000):
source_url = await b64media2url(request, source_url) source_url = await b64media2url(request, source_url)
if not source_url: if not source_url:
return {"success": False, "message": "素材文件转换失败"} return json.dumps({
"widgettype": "Message",
"options": {"message": "素材文件转换失败", "type": "error"}
})
result = await rl_upload_user((await get_userorgid()) or '0', vendor_group_id, source_url, asset_type, name, (await get_user())) org_id = (await get_userorgid()) or '0'
return result user_id = (await get_user()) or ''
result = await rl_upload_user(org_id, vendor_group_id, source_url, asset_type, name, user_id)
if result.get('success'):
asset_id = result.get('vendor_asset_id', '')
return json.dumps({
"widgettype": "Message",
"options": {"message": f"素材上传成功资产ID: {asset_id}", "type": "success"}
})
else:
return json.dumps({
"widgettype": "Message",
"options": {"message": result.get('message', '上传失败'), "type": "error"}
})

View File

@ -1,13 +1,28 @@
import json
vendor = params_kw.get('vendor', '') vendor = params_kw.get('vendor', '')
project_name = params_kw.get('project_name', 'default')
if not vendor: if not vendor:
return {"success": False, "message": "请指定供应商"} return json.dumps({
"widgettype": "Message",
"options": {"message": "请选择供应商", "type": "error"}
})
result = await rl_verify_user( org_id = (await get_userorgid()) or '0'
(await get_userorgid()) or '0', user_id = (await get_user()) or ''
(await get_user()) or '', project_name = org_id # 直接用客户的orgid作为project_name
vendor,
project_name result = await rl_verify_user(org_id, user_id, vendor, project_name)
)
return result if result.get('success'):
h5_link = result.get('h5_link', '')
msg = f"认证会话已创建,请通过以下链接完成真人认证:\n{h5_link}"
return json.dumps({
"widgettype": "Message",
"options": {"message": msg, "type": "success"}
})
else:
return json.dumps({
"widgettype": "Message",
"options": {"message": result.get('message', '认证创建失败'), "type": "error"}
})

View File

@ -16,7 +16,7 @@
{ {
"widgettype": "Title4", "widgettype": "Title4",
"options": { "options": {
"text": "创建真人认证", "text": "真人认证",
"fontWeight": "600" "fontWeight": "600"
} }
}, },
@ -44,86 +44,64 @@
] ]
}, },
{ {
"widgettype": "VScrollPanel", "widgettype": "VBox",
"options": { "options": {
"height": "500px" "padding": "16px",
"spacing": 12
}, },
"subwidgets": [ "subwidgets": [
{ {
"widgettype": "VBox", "widgettype": "Form",
"id": "validate_form",
"options": { "options": {
"padding": "16px", "submit_url": "{{entire_url('api/rl_verify.dspy')}}",
"spacing": 12 "fields": [
{
"uitype": "code",
"name": "vendor",
"label": "供应商",
"dataurl": "{{entire_url('api/get_vendor_list.dspy')}}",
"data_field": "value",
"text_field": "text",
"required": true
}
]
}
},
{
"widgettype": "HBox",
"options": {
"gap": "12px",
"marginTop": "16px"
}, },
"subwidgets": [ "subwidgets": [
{ {
"widgettype": "Form", "widgettype": "Button",
"id": "validate_form",
"options": { "options": {
"submit_url": "{{entire_url('api/rl_asset_group_create.dspy')}}", "label": "开始认证"
"fields": [ },
{ "binds": [
"uitype": "code", {
"name": "vendor", "wid": "self",
"label": "供应商", "event": "click",
"dataurl": "{{entire_url('api/get_vendor_list.dspy')}}", "actiontype": "script",
"data_field": "value", "target": "self",
"text_field": "text", "script": "var f=bricks.getWidgetById('validate_form',bricks.app);if(f)f.submit()"
"required": true }
}, ]
{
"uitype": "str",
"name": "callback_url",
"label": "回调URL",
"placeholder": "https://your-domain.com/reallife_asset/api/rl_callback.dspy",
"required": true
},
{
"uitype": "str",
"name": "project_name",
"label": "项目名",
"placeholder": "default",
"value": "default"
}
]
}
}, },
{ {
"widgettype": "HBox", "widgettype": "Button",
"options": { "options": {
"gap": "12px", "label": "重置"
"marginTop": "16px"
}, },
"subwidgets": [ "binds": [
{ {
"widgettype": "Button", "wid": "self",
"options": { "event": "click",
"label": "提交" "actiontype": "script",
}, "target": "self",
"binds": [ "script": "var f=bricks.getWidgetById('validate_form',bricks.app);if(f)f.reset()"
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var f=bricks.getWidgetById('validate_form',bricks.app);if(f)f.submit()"
}
]
},
{
"widgettype": "Button",
"options": {
"label": "重置"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var f=bricks.getWidgetById('validate_form',bricks.app);if(f)f.reset()"
}
]
} }
] ]
} }

View File

@ -60,13 +60,24 @@
"widgettype": "Form", "widgettype": "Form",
"id": "upload_form", "id": "upload_form",
"options": { "options": {
"submit_url": "{{entire_url('api/rl_asset_create.dspy')}}", "submit_url": "{{entire_url('api/rl_upload.dspy')}}",
"fields": [ "fields": [
{ {
"uitype": "str", "uitype": "code",
"name": "vendor",
"label": "供应商",
"dataurl": "{{entire_url('api/get_vendor_list.dspy')}}",
"data_field": "value",
"text_field": "text",
"required": true
},
{
"uitype": "code",
"name": "vendor_group_id", "name": "vendor_group_id",
"label": "供应商组合ID", "label": "认证组合",
"placeholder": "输入已通过认证的 vendor_group_id", "dataurl": "{{entire_url('api/get_org_groups.dspy')}}",
"data_field": "value",
"text_field": "text",
"required": true "required": true
}, },
{ {
@ -74,7 +85,7 @@
"name": "source_url", "name": "source_url",
"label": "素材URL或base64", "label": "素材URL或base64",
"rows": 4, "rows": 4,
"placeholder": "https://... 可公开访问的图片URL\n或\ndata:image/png;base64,...", "placeholder": "https://... 可公开访问的图片/视频URL\n或\ndata:image/png;base64,...",
"required": true "required": true
}, },
{ {
@ -104,7 +115,7 @@
{ {
"widgettype": "Button", "widgettype": "Button",
"options": { "options": {
"label": "提交" "label": "上传"
}, },
"binds": [ "binds": [
{ {