swan.openReplyEditor

    解释: 调起半屏内容发布器,并支持开发者配置发布器展示模块。此api版本为单框架,不接入百度服务,即发布的内容无法进入百度app个人主页、无法接入百度互动消息推送。若想自动接入百度服务,请使用半屏内容发布器带服务版

    Object object

    success返回参数说明

    moduleList 列表

    若moduleList传空数组或不传,则默认展示正文、图片模块、表情模块。若传值,则只展示所传 list 中配置的模块。如: 则只展示图片模块。

    开发者在配置 emoji 模块后,可以选择是否使用自定义表情表。若使用自定义表情功能,则将自定义表情的资源文件夹路径传入 emojiPath 字段。若不传 emojiPath 字段则使用默认表情包。

    自定义表情资源文件夹格式

    emoji.json 格式:

    图片

    扫码体验

    请使用百度APP扫码

    swan.openReplyEditor - 图5

    代码示例1 moduleList传emoji并配置自定义图标 :

    在开发者工具中预览效果

    代码示例2 moduleList传image :

    在开发者工具中预览效果

    1. swan.openReplyEditor({
    2. sendBackgroundColor: '#3388ff',
    3. sendText: '发送',
    4. contentPlaceholder: '请输入评论内容',
    5. moduleList: ['image'],
    6. emojiPath: '../../emojidata',
    7. console.log('openReplyEditor success', res);
    8. // 点击了发表按钮
    9. if (res.status === 'reply') {
    10. // 开发者处理返回内容。
    11. // 主动关闭评论发布器
    12. swan.closeReplyEditor({
    13. success: res => {
    14. console.log('closeReplyEditor success', res);
    15. }
    16. // 点击发布器外隐藏发布器,编辑的内容将存为草稿
    17. else if (res.status === 'draft') {
    18. // 处理草稿内容,如ui处理
    19. }
    20. },
    21. fail: function (res) {
    22. console.log('openReplyEditor fail', res);
    23. },
    24. complete: function (res) {
    25. console.log('openReplyEditor complete', res);
    26. })
    • 工具返回的 status 是0,与预期不符,正在修复中