swan.closeCommunityEditor
Object object
示例
请使用百度APP扫码
- 在 swan 文件中
- 在 js 文件中
data: {
content: '原帖内容'
},
onLoad(e) {
},
openCommunityEditor() {
swan.openCommunityEditor({
contentPlaceholder: '请输入帖子正文',
titlePlaceholder: '请输入标题',
moduleList: ['title', 'image', 'emoji', 'target'],
imageConf: {
maxNum: 9,
ratio: 1
},
navBarTitleText: '发布帖子',
navBarTextStyle: 'black',
navBarBackgroundColor: '#ffffff',
confirmText: '发布',
cancelText: '取消',
cancelColor: '#666666',
targetText: '话题/吧/版块',
emojiPath: '../../emojidata',
success: function (res) {
// 将图片上传到服务器
// swan.uploadFile({
// url: 'https://smartprogram.baidu.com/xxx', // 仅为示例,并非真实的接口地址
// filePath: res.tempFilePaths[0], // 要上传文件资源的路径
// name: 'myfile',
// success: function (res) {
// console.log(res.statusCode);
// // 上传成功关闭发布器
// swan.closeCommunityEditor();
// },
// fail: function (err) {
// console.log('错误码:' + err.errCode);
// console.log('错误信息:' + err.errMsg);
// }
// });
swan.closeCommunityEditor();
swan.showToast({
title: '发布成功',
icon: 'none'
});
},
console.log('openCommunityEditor fail', err);
swan.closeCommunityEditor();
complete: function (res) {
console.log('openCommunityEditor complete', res);
}
});
// 定时器模拟开发者的提示时机,真实时机可据业务场景触发
let that = this;
setTimeout(function () {
swan.showModal({
title: '更新提示',
content: '您所评论的内容有更新,是否要回到原帖查看',
success(res) {
console.log(res)
if (res.confirm) {
swan.closeCommunityEditor();
that.setData('content', '更新的内容')
}
else if(res.cancel) {
console.log('用户点击了取消');
}
}
});
}, 5000);
}
});