detail.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. // pages/home/index.js
  2. const app = getApp()
  3. import { formatRichText } from '../../utils/wangeditor';
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. height: app.globalData.height * 2 + 25,
  10. windowHeight: app.globalData.windowHeight,
  11. navbarData: {
  12. name: '新闻信息'
  13. },
  14. detailInfo: {}
  15. },
  16. // 返回
  17. back: function () {
  18. wx.switchTab({
  19. url: '/pages/news/index',
  20. })
  21. },
  22. /**
  23. * 生命周期函数--监听页面加载
  24. */
  25. onLoad: function (options) {
  26. console.log(options.id);
  27. wx.request({
  28. url: `${app.globalData.publicUrl}/api/st/system/news/${options.id}`,
  29. method: "get",
  30. header: { 'x-tenant': app.globalData.tenant },
  31. data: {},
  32. success: res => {
  33. var result = res.data.data;
  34. result.content = formatRichText(result.content)
  35. this.setData({ detailInfo: result })
  36. },
  37. error: err => {
  38. wx.showToast({
  39. title: err.msg,
  40. icon: 'error'
  41. })
  42. }
  43. })
  44. },
  45. /**
  46. * 生命周期函数--监听页面初次渲染完成
  47. */
  48. onReady: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面显示
  52. */
  53. onShow: function () {
  54. // if (typeof this.getTabBar === 'function' &&
  55. // this.getTabBar()) {
  56. // this.getTabBar().setData({
  57. // selected: 3
  58. // })
  59. // }
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload: function () {
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh: function () {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom: function () {
  80. },
  81. /**
  82. * 用户点击右上角分享
  83. */
  84. onShareAppMessage: function () {
  85. }
  86. })