detail.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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: async function (options) {
  26. const res = await app.$get(`/news/${options.id}`);
  27. var result = res.data;
  28. result.content = formatRichText(result.content);
  29. this.setData({ detailInfo: result });
  30. // wx.request({
  31. // url: `${app.globalData.publicUrl}/api/st/system/news/${options.id}`,
  32. // method: "get",
  33. // data: {},
  34. // success: res => {
  35. // var result = res.data.data;
  36. // result.content = formatRichText(result.content)
  37. // this.setData({ detailInfo: result })
  38. // },
  39. // error: err => {
  40. // wx.showToast({
  41. // title: err.msg,
  42. // icon: 'error'
  43. // })
  44. // }
  45. // })
  46. },
  47. /**
  48. * 生命周期函数--监听页面初次渲染完成
  49. */
  50. onReady: function () {
  51. },
  52. /**
  53. * 生命周期函数--监听页面显示
  54. */
  55. onShow: function () {
  56. // if (typeof this.getTabBar === 'function' &&
  57. // this.getTabBar()) {
  58. // this.getTabBar().setData({
  59. // selected: 3
  60. // })
  61. // }
  62. },
  63. /**
  64. * 生命周期函数--监听页面隐藏
  65. */
  66. onHide: function () {
  67. },
  68. /**
  69. * 生命周期函数--监听页面卸载
  70. */
  71. onUnload: function () {
  72. },
  73. /**
  74. * 页面相关事件处理函数--监听用户下拉动作
  75. */
  76. onPullDownRefresh: function () {
  77. },
  78. /**
  79. * 页面上拉触底事件的处理函数
  80. */
  81. onReachBottom: function () {
  82. },
  83. /**
  84. * 用户点击右上角分享
  85. */
  86. onShareAppMessage: function () {
  87. }
  88. })