detail.js 810 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. const app = getApp();
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. id:0,
  8. info:{},
  9. content: '',
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. let id = options.id;
  16. this.setData({id:id});
  17. this.getInfo();
  18. },
  19. /**
  20. * 用户点击右上角分享
  21. */
  22. onShareAppMessage: function () {
  23. let info = this.data.info
  24. return {
  25. title: info.title,
  26. path: "/pages/article/detail/detail?id="+info.id,
  27. imageUrl: info.main_image,
  28. };
  29. },
  30. //详情
  31. getInfo() {
  32. let self = this;
  33. app.get('portal/articles/'+this.data.id,function(res){
  34. self.setData({info:res});
  35. self.setData({ content: res.post_content.replace(/\<img/gi, '<img style="max-width:100%;display:block;" ') });
  36. });
  37. },
  38. })