|
|
@ -157,6 +157,32 @@ Page({ |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 确保topic字段存在
|
|
|
|
|
|
if (post.topic) { |
|
|
|
|
|
console.log('动态话题:', post.topic); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 为了兼容前端模板,添加user对象
|
|
|
|
|
|
if (!post.user) { |
|
|
|
|
|
post.user = { |
|
|
|
|
|
avatar: post.avatar_url || '', |
|
|
|
|
|
nickname: post.username |
|
|
|
|
|
}; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 为了兼容前端模板,添加image字段(使用images数组的第一个元素)
|
|
|
|
|
|
if (!post.image && post.images && post.images.length > 0) { |
|
|
|
|
|
post.image = post.images[0]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 为了兼容前端模板,添加like_count和comment_count字段
|
|
|
|
|
|
if (post.likes !== undefined && post.like_count === undefined) { |
|
|
|
|
|
post.like_count = post.likes; |
|
|
|
|
|
} |
|
|
|
|
|
if (post.comments !== undefined && post.comment_count === undefined) { |
|
|
|
|
|
post.comment_count = post.comments; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
return post; |
|
|
return post; |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
@ -362,6 +388,29 @@ Page({ |
|
|
}); |
|
|
}); |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
// 预览图片
|
|
|
|
|
|
previewImage(e) { |
|
|
|
|
|
const images = e.currentTarget.dataset.images; |
|
|
|
|
|
const currentIndex = parseInt(e.currentTarget.dataset.current); |
|
|
|
|
|
|
|
|
|
|
|
console.log('预览图片:', { |
|
|
|
|
|
images, |
|
|
|
|
|
currentIndex, |
|
|
|
|
|
current: images[currentIndex] |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
wx.previewImage({ |
|
|
|
|
|
current: images[currentIndex], |
|
|
|
|
|
urls: images, |
|
|
|
|
|
success: function(res) { |
|
|
|
|
|
console.log('预览图片成功:', res); |
|
|
|
|
|
}, |
|
|
|
|
|
fail: function(err) { |
|
|
|
|
|
console.error('预览图片失败:', err); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
createPost() { |
|
|
createPost() { |
|
|
wx.navigateTo({ |
|
|
wx.navigateTo({ |
|
|
url: '/pages/eggbar/create-post' |
|
|
url: '/pages/eggbar/create-post' |
|
|
|