希望各位大佬帮帮忙
//发布动态
if (res.confirm) {
var outfile = '';
console.log(files);
if(files!=undefined)
{
if (files.length > 0) {
for (var file in files) {
if (outfile == '') {
outfile = files[file];
}
else {
outfile += ',' + files[file];
}
}
}
}
console.log(outfile);
// const pub = PubContent.replace(/\"/g,"'");
const pub = PubContent.replace(/wx:nodeid="\d+"/g,'');
const content = pub.replace(/\"/g,"'");
// const con = content.replace(/=/g,":");
let data = {
'UserName': 'ycl',
'ApprovalFlag': 1,
'Title': title,
'PubContent': content,
'UploadFile': outfile,
'ShortDes': ShortDes
};
//var abc = JSON.stringify(data).toString().replace(new RegExp("\\\\\"","gm"),"\"");
// var a = abc.PubContent
console.log(JSON.stringify(data));
api.community.publish(JSON.stringify(data), (state, result) => {
console.log(state, result);
if (state == 'success' && result.data.StatusCode == 1000) {
wx.showToast({
title: '发布成功',
duration:1500,
})
} else {
wx.showModal({
title: '提示',
content: '发布失败',
showCancel: false
})
}
})
我们是后台添加html文章,小程序解析。
小程序的结构比较简单,无非【图片】-【文字】-【图片】我们一般都结构化了