// pages/sysMsgDetail/sysMsgDetail.js
const app = getApp()
import {
  lastMsg,
  allRead,
} from "../../../api/msg"
import {throttle} from "../../../utils/util"
Page({

  /**
   * 页面的初始数据
   */
  data: {
    msg:{},
    isTriggered:false,
    count:0,
    img_host:'https://oss.prod.applets.igandanyiyuan.com/applet/patient/static'
  },
  getLastMsg(){
    lastMsg().then(data=>{
      let count=0;
       for (const key in data) {
         let item='msg.'+key
         count=count+data[key].count;
         this.setData({
           [item]:data[key],
           isTriggered:false,
           count:count
         })  
       };
    })
  },
  HnaleAllRead(){
   allRead({
      notice_type:3
    }).then(data=>{
      this.getLastMsg();
      wx.showToast({
        title: '一键已读成功',
        icon:"none"
      })
    })
  },
  goServiceList:throttle(function(){
     app.method.navigateTo({
       url: '/patient/pages/sysMsgList/sysMsgList',
     })
  }),
  gofuliMsgList:throttle(function(){
    app.method.navigateTo({
      url: '/patient/pages/fuliMsgList/fuliMsgList',
    })
  }),
  goBack(){
    wx.navigateBack({
      delta: 1,
    })
  },
  handleRefresher(){
    this.getLastMsg();
  },
  goExpress:throttle(function(){
    app.method.navigateTo({
      url: '/patient/pages/refundMsgList/refundMsgList?type=express',
    })
  }),
  refundMsgList:throttle(function(){
    app.method.navigateTo({
      url: '/patient/pages/refundMsgList/refundMsgList',
    })
  }),
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    //this.getLastMsg()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    this.setData({
      img_host:app.hostConfig().imghost
    })
    this.getLastMsg()
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  
})