details.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. import {
  2. ApiModel
  3. } from "../../utils/api";
  4. const _Http = new ApiModel();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. pageType: {}, //类型 0 为广场进入 1为发布历史进入
  11. tnoticeid: {}, //公告id
  12. msgObj: {}, //详情
  13. coverFiles: [], //封面
  14. defaultFiles: [], //附件
  15. },
  16. /**
  17. * 生命周期函数--监听页面加载
  18. */
  19. onLoad: function (options) {
  20. //默认通告广场
  21. let data = {
  22. "accesstoken": wx.getStorageSync('userData').token,
  23. "classname": "customer.notice.notice",
  24. "method": "query_noticeMain",
  25. "content": {
  26. "tnoticeid": options.id
  27. }
  28. };
  29. //历史发布
  30. if (options.type == 1) {
  31. data.classname = "customer.noticemag.noticemag";
  32. };
  33. //开始阅读
  34. _Http.basic(data).then(res => {
  35. console.log(res)
  36. let attinfos = res.data[0].attinfos,
  37. coverFiles = [],
  38. defaultFiles = [];
  39. for (let i = 0; i < attinfos.length; i++) {
  40. (attinfos[i].ftype == "default") ? defaultFiles.push(attinfos[i]): coverFiles.push(attinfos[i])
  41. }
  42. this.setData({
  43. tnoticeid: options.id,
  44. msgObj: res.data[0],
  45. coverFiles,
  46. defaultFiles,
  47. pageType: options.type
  48. })
  49. })
  50. },
  51. /**
  52. * 生命周期函数--监听页面初次渲染完成
  53. */
  54. onReady: function () {
  55. },
  56. /**
  57. * 生命周期函数--监听页面显示
  58. */
  59. onShow: function () {
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload: function () {
  70. if (this.data.pageType == 0) {
  71. _Http.basic({
  72. "accesstoken": wx.getStorageSync('userData').token,
  73. "classname": "customer.notice.notice",
  74. "method": "noticeexit",
  75. "content": {
  76. "tnoticeid": this.data.tnoticeid
  77. }
  78. }).then(res => {
  79. console.log(res)
  80. })
  81. }
  82. },
  83. /**
  84. * 页面相关事件处理函数--监听用户下拉动作
  85. */
  86. onPullDownRefresh: function () {
  87. },
  88. /**
  89. * 页面上拉触底事件的处理函数
  90. */
  91. onReachBottom: function () {
  92. },
  93. /**
  94. * 用户点击右上角分享
  95. */
  96. onShareAppMessage: function () {
  97. }
  98. })