
const app = getApp();
import HTTP from "../../../../../requestFn/Api"
Page({
  data: {
    title:"",
    created_at:"",
  },
  onLoad(options) {
    const that = this;
    const {
      garden_id
    } = app.globalData; 
    const eventChannel = that.getOpenerEventChannel()
    eventChannel.on('acceptDataFromOpenerPage', function (data) {
      const {
        id,
        read,
        content,
        title,
        created_at
      } = data.data[0];
      that.setData({
        id,
        read,
        title,
        created_at,
        content
      })
      wx.setNavigationBarTitle({
        title,
      })
      that.addNoticeTime(garden_id,id,read)
    })
  },
  addNoticeTime(garden_id, id, read) {
    if (!read) {
      HTTP.AddRead_count({
        garden_id,
        id
      }).then(res => {
      })
    }
  }
})