news-detail.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // pages/news-detail/news-detail.js
  2. var http = require("../../utils/http.js");
  3. var config = require("../../utils/config.js");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. news: {
  10. title: '',
  11. content: '',
  12. id: null
  13. }
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad: function (options) {
  19. // var ths = this;
  20. //加载公告详情
  21. var params = {
  22. // `/shop/notice/info/${options.id}`
  23. url: '/shop/notice/info/' + options.id,
  24. method: "GET",
  25. // data: {
  26. // id: id,
  27. // },
  28. // callBack: function(news){
  29. callBack: res => {
  30. res.content = res.content.replace(/width=/gi, 'sss=');
  31. res.content = res.content.replace(/height=/gi, 'sss=');
  32. res.content = res.content.replace(/ \/\>/gi, ' style="max-width:100% !important;display:block;" \/\>');
  33. this.setData({
  34. news: res
  35. });
  36. }
  37. };
  38. http.request(params);
  39. },
  40. /**
  41. * 生命周期函数--监听页面初次渲染完成
  42. */
  43. onReady: function () {
  44. },
  45. /**
  46. * 生命周期函数--监听页面显示
  47. */
  48. onShow: function () {
  49. },
  50. /**
  51. * 生命周期函数--监听页面隐藏
  52. */
  53. onHide: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面卸载
  57. */
  58. onUnload: function () {
  59. },
  60. /**
  61. * 页面相关事件处理函数--监听用户下拉动作
  62. */
  63. onPullDownRefresh: function () {
  64. },
  65. /**
  66. * 页面上拉触底事件的处理函数
  67. */
  68. onReachBottom: function () {
  69. },
  70. /**
  71. * 用户点击右上角分享
  72. */
  73. onShareAppMessage: function () {
  74. }
  75. })