feat: 微信通道配置界面(公众号配置表单+用户openid绑定)+cockpit入口按钮

This commit is contained in:
ymq 2026-08-15 10:11:51 +08:00
parent 4a9eb227df
commit 319b72c735
2 changed files with 105 additions and 0 deletions

View File

@ -73,6 +73,23 @@
"script": "var pw=new bricks.PopupWindow({title:'\u6a21\u578b\u914d\u7f6e',cwidth:36,cheight:26,auto_open:true});bricks.widgetBuild({widgettype:'urlwidget',options:{url:'/pipeline_core/llm/index.ui',method:'GET'}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});"
}
]
},
{
"widgettype": "Button",
"options": {
"name": "wechat_config",
"label": "\u5fae\u4fe1\u901a\u9053",
"css": "small"
},
"binds": [
{
"wid": "self",
"event": "click",
"actiontype": "script",
"target": "self",
"script": "var pw=new bricks.PopupWindow({title:'\u5fae\u4fe1\u901a\u9053\u914d\u7f6e',cwidth:44,cheight:34,auto_open:true});bricks.widgetBuild({widgettype:'urlwidget',options:{url:'/pipeline-sdlc/wechat_config/index.ui',method:'GET'}},pw.content_w).then(function(w){if(w)pw.content_w.add_widget(w);});"
}
]
}
]
},

View File

@ -0,0 +1,88 @@
{
"widgettype": "VBox",
"options": {"height": "100%", "width": "100%", "padding": "24px", "gap": "16px"},
"subwidgets": [
{
"widgettype": "Title2",
"options": {"text": "微信通道配置"}
},
{
"widgettype": "Text",
"options": {"text": "机构级公众号配置(仅机构管理员)+ 用户微信绑定", "cfontsize": 0.85, "color": "#94a3b8"}
},
{
"widgettype": "VBox",
"id": "admin_section",
"options": {"css": "card", "padding": "16px", "gap": "12px"},
"subwidgets": [
{
"widgettype": "Title3",
"options": {"text": "公众号配置(机构管理员)"}
},
{
"widgettype": "Form",
"id": "wechat_form",
"options": {
"name": "wechat_form",
"cols": 2,
"fields": [
{"name": "name", "uitype": "str", "label": "公众号名称", "cwidth": 12},
{"name": "appid", "uitype": "str", "label": "AppID", "cwidth": 12},
{"name": "appsecret", "uitype": "password", "label": "AppSecret", "cwidth": 12, "placeholder": "留空则不修改"},
{"name": "token", "uitype": "str", "label": "校验Token", "cwidth": 12},
{"name": "encoding_aes_key", "uitype": "str", "label": "加密Key(可选)", "cwidth": 12},
{"name": "enabled", "uitype": "code", "label": "启用", "cwidth": 12, "dataurl": "/pipeline-sdlc/api/wechat_config.dspy?action=opts_enabled", "valueField": "k", "textField": "v"}
]
}
},
{
"widgettype": "Button",
"options": {"name": "save_config", "label": "保存配置", "css": "primary"},
"binds": [
{
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
"script": "var f=bricks.getWidgetById('wechat_form',bricks.app);if(!f||!f.form_element){bricks.alert('表单未加载');return;}var d={};var els=f.form_element.querySelectorAll('[name]');els.forEach(function(e){d[e.getAttribute('name')]=e.value||'';});d.action='save';var body=Object.keys(d).map(function(k){return encodeURIComponent(k)+'='+encodeURIComponent(d[k]);}).join('&');fetch('/pipeline-sdlc/api/wechat_config.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json()}).then(function(j){bricks.alert(j.success?'保存成功':'保存失败: '+(j.error||''));}).catch(function(e){bricks.alert('保存失败: '+e);});"
}
]
}
]
},
{
"widgettype": "VBox",
"id": "bind_section",
"options": {"css": "card", "padding": "16px", "gap": "12px"},
"subwidgets": [
{
"widgettype": "Title3",
"options": {"text": "绑定我的微信"}
},
{
"widgettype": "Text",
"id": "bind_status",
"options": {"text": "加载中...", "cfontsize": 0.9, "color": "#64748b"}
},
{
"widgettype": "HBox",
"options": {"gap": "8px", "alignItems": "center"},
"subwidgets": [
{
"widgettype": "Input",
"id": "openid_input",
"options": {"name": "openid_input", "placeholder": "输入您的微信 openid", "cwidth": 24}
},
{
"widgettype": "Button",
"options": {"name": "bind_btn", "label": "绑定", "css": "primary"},
"binds": [
{
"wid": "self", "event": "click", "actiontype": "script", "target": "self",
"script": "var inp=bricks.getWidgetById('openid_input',bricks.app);var oid=(inp&&inp.options.value)||'';if(!oid){bricks.alert('请输入 openid');return;}var body='action=bind&openid='+encodeURIComponent(oid);fetch('/pipeline-sdlc/api/wechat_binding.dspy',{method:'POST',headers:{'Content-Type':'application/x-www-form-urlencoded'},body:body}).then(function(r){return r.json()}).then(function(j){bricks.alert(j.success?'绑定成功':'绑定失败: '+(j.error||''));if(j.success){var st=bricks.getWidgetById('bind_status',bricks.app);if(st)st.options.text='已绑定 openid: '+oid;}}).catch(function(e){bricks.alert('绑定失败: '+e);});"
}
]
}
]
}
]
}
]
}