detail.js 2.0 KB

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