diff --git a/wwwroot/api/get_org_groups.dspy b/wwwroot/api/get_org_groups.dspy new file mode 100644 index 0000000..bcfd351 --- /dev/null +++ b/wwwroot/api/get_org_groups.dspy @@ -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) diff --git a/wwwroot/api/rl_upload.dspy b/wwwroot/api/rl_upload.dspy index a841994..2941913 100644 --- a/wwwroot/api/rl_upload.dspy +++ b/wwwroot/api/rl_upload.dspy @@ -1,16 +1,38 @@ +import json + vendor_group_id = params_kw.get('vendor_group_id', '') source_url = params_kw.get('source_url', '') asset_type = params_kw.get('asset_type', 'Image') name = params_kw.get('name', '') 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.startswith('data:') or (not source_url.startswith('http') and len(source_url) < 8000): source_url = await b64media2url(request, 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())) -return result +org_id = (await get_userorgid()) or '0' +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"} + }) diff --git a/wwwroot/api/rl_verify.dspy b/wwwroot/api/rl_verify.dspy index 10fbe3d..3646d59 100644 --- a/wwwroot/api/rl_verify.dspy +++ b/wwwroot/api/rl_verify.dspy @@ -1,13 +1,28 @@ +import json + vendor = params_kw.get('vendor', '') -project_name = params_kw.get('project_name', 'default') if not vendor: - return {"success": False, "message": "请指定供应商"} + return json.dumps({ + "widgettype": "Message", + "options": {"message": "请选择供应商", "type": "error"} + }) -result = await rl_verify_user( - (await get_userorgid()) or '0', - (await get_user()) or '', - vendor, - project_name -) -return result +org_id = (await get_userorgid()) or '0' +user_id = (await get_user()) or '' +project_name = org_id # 直接用客户的orgid作为project_name + +result = await rl_verify_user(org_id, user_id, vendor, project_name) + +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"} + }) diff --git a/wwwroot/create_validate.ui b/wwwroot/create_validate.ui index 7aeb3a0..7461d25 100644 --- a/wwwroot/create_validate.ui +++ b/wwwroot/create_validate.ui @@ -16,7 +16,7 @@ { "widgettype": "Title4", "options": { - "text": "创建真人认证", + "text": "真人认证", "fontWeight": "600" } }, @@ -44,86 +44,64 @@ ] }, { - "widgettype": "VScrollPanel", + "widgettype": "VBox", "options": { - "height": "500px" + "padding": "16px", + "spacing": 12 }, "subwidgets": [ { - "widgettype": "VBox", + "widgettype": "Form", + "id": "validate_form", "options": { - "padding": "16px", - "spacing": 12 + "submit_url": "{{entire_url('api/rl_verify.dspy')}}", + "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": [ { - "widgettype": "Form", - "id": "validate_form", + "widgettype": "Button", "options": { - "submit_url": "{{entire_url('api/rl_asset_group_create.dspy')}}", - "fields": [ - { - "uitype": "code", - "name": "vendor", - "label": "供应商", - "dataurl": "{{entire_url('api/get_vendor_list.dspy')}}", - "data_field": "value", - "text_field": "text", - "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" - } - ] - } + "label": "开始认证" + }, + "binds": [ + { + "wid": "self", + "event": "click", + "actiontype": "script", + "target": "self", + "script": "var f=bricks.getWidgetById('validate_form',bricks.app);if(f)f.submit()" + } + ] }, { - "widgettype": "HBox", + "widgettype": "Button", "options": { - "gap": "12px", - "marginTop": "16px" + "label": "重置" }, - "subwidgets": [ + "binds": [ { - "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.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()" - } - ] + "wid": "self", + "event": "click", + "actiontype": "script", + "target": "self", + "script": "var f=bricks.getWidgetById('validate_form',bricks.app);if(f)f.reset()" } ] } diff --git a/wwwroot/upload_asset.ui b/wwwroot/upload_asset.ui index 58c708e..e9e761e 100644 --- a/wwwroot/upload_asset.ui +++ b/wwwroot/upload_asset.ui @@ -60,13 +60,24 @@ "widgettype": "Form", "id": "upload_form", "options": { - "submit_url": "{{entire_url('api/rl_asset_create.dspy')}}", + "submit_url": "{{entire_url('api/rl_upload.dspy')}}", "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", - "label": "供应商组合ID", - "placeholder": "输入已通过认证的 vendor_group_id", + "label": "认证组合", + "dataurl": "{{entire_url('api/get_org_groups.dspy')}}", + "data_field": "value", + "text_field": "text", "required": true }, { @@ -74,7 +85,7 @@ "name": "source_url", "label": "素材URL或base64", "rows": 4, - "placeholder": "https://... 可公开访问的图片URL\n或\ndata:image/png;base64,...", + "placeholder": "https://... 可公开访问的图片/视频URL\n或\ndata:image/png;base64,...", "required": true }, { @@ -104,7 +115,7 @@ { "widgettype": "Button", "options": { - "label": "提交" + "label": "上传" }, "binds": [ {