codecamp

百度智能小程序 关闭原生全屏内容发布器

swan.closeCommunityEditor

基础库 3.100.4 版本开始支持,以下版本请使用小程序发布器组件。

解释: 关闭原生全屏内容发布器

方法参数

Object object

emojiPath 参数说明

属性名类型必填默认值说明

success

Function

发布成功的回调函数

fail

Function

发布失败的回调函数

complete

Function

接口调用结束的回调函数(调用成功、失败都会执行)

示例 

在开发者工具中打开


图片示例

代码示例

<view class="wrap">
    <view class="card-area">
        <view class="top-description border-bottom">
           <view>原帖标题</view>
           <view>{{content}}</view>
        </view>
        <button type="primary" bindtap="openCommunityEditor">点击回复原帖</button>
    </view>
</view>
Page({
    data: {
        content: '原帖内容'
    },

    openCommunityEditor() {
        swan.openCommunityEditor({
            contentPlaceholder: '请输入帖子正文',
            titlePlaceholder: '请输入标题',
            moduleList: ['title', 'image', 'emoji', 'target'],
            imageConf: {
                maxNum: 9,
                ratio: 1
            },
            navBarTitleText: '发布帖子',
            navBarTextStyle: 'black',
            navBarBackgroundColor: '#ffffff',
            confirmText: '发布',
            confirmColor: '#3388ff',
            cancelText: '取消',
            cancelColor: '#666666',
            targetText: '话题/吧/版块',
            emojiPath: '../../common/emojidata',
            success: res => {
                console.log('openCommunityEditor success', res);
                swan.closeCommunityEditor();
                swan.showToast({
                    title: '发布成功',
                    icon: 'none'
                });
            },
            fail: err => {
                console.log('openCommunityEditor fail', err);
                swan.closeCommunityEditor();
            },
            complete: res => {
                console.log('openCommunityEditor complete', res);
            }
        });
        // 定时器模拟开发者的提示时机,真实时机可据业务场景触发
        setTimeout(() => {
            swan.showModal({
                title: '更新提示',
                content: '您所评论的内容有更新,是否要回到原帖查看,您当前所编辑的内容不会被保存',
                success: res => {
                    if (res.confirm) {
                    swan.closeCommunityEditor();
                        this.setData('content', '更新的内容');
                    }
                    else if (res.cancel) {
                        console.log('用户点击了取消');
                    }
                }
            });
        }, 5000);
    }
});


百度智能小程序 调起原生全屏内容发布器
百度智能小程序 调起半屏内容发布器
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

百度智能小程序开发文档

百度智能小程序 组件

百度智能小程序 地图

百度智能小程序 画布

百度智能小程序 API

百度智能小程序 界面

百度智能小程序 关注小程序引导组件

百度智能小程序 自定义组件

百度智能小程序 媒体

百度智能小程序 设备

百度智能小程序 拨打电话

百度智能小程序 内存警报

百度智能小程序 手机联系人

百度智能小程序 用户截屏事件

百度智能小程序 第三方平台

百度智能小程序 开放接口

百度智能小程序 百度收银支付

百度智能小程序 分包预下载

百度智能小程序 数据分析

百度智能小程序 服务端

百度智能小程序 云开发

百度智能小程序 初始化

百度智能小程序 云函数

百度智能小程序 服务端初始化

百度智能小程序 服务器获取上下文

百度智能小程序 服务端云函数

百度智能小程序 开发教程

百度智能小程序 功能开发

百度智能小程序 基本原理

百度智能小程序 小程序自动化

百度智能小程序 视频教程

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }