const app = getApp()

Page({
  data: {
    baseImgUrl: app.FILE_SERVER_URL,
    nineType: 0,
    ec: {
      lazyLoad: true
    },
    filterIndex: 0,
    itemList: [{
        icon: "icon_tab1",
        name: "履职清单",
        href: "/pages/duty/index/index"
      },
      // {
      //   icon: "icon_tab2",
      //   name: "专项任务",
      //   href: "/pages/task/index/index"
      // },
      {
        icon: "icon_tab3",
        name: "一企一档",
        href: "/pages/ent-obj/index/index"
      },
      {
        icon: "icon_tab4",
        name: "隐患核查",
        href: "/pages/danger/list/index"
      },
      // {
      //   icon: "icon_tab5",
      //   name: "群防群治",
      //   href: "/pages/people/index/index",
      // },
      // {
      //   icon: "icon-emergency",
      //   name: "应急管理",
      //   href: "/pages/emergency/index/index",
      // },
      // {
      //   icon: "icon_tab6",
      //   name: "发布通知",
      //   href: "/pages/msg/push-index/index",
      // },
    ],
    filter: [{
      lab: '今日数据',
      val: 0
    }, {
      lab: '本月数据',
      val: 1
    }],
    dLegend: [{
      name: '已整改',
      num: 0,
      color: '#2678FF'
    }, {
      name: '整改中',
      num: 0,
      color: '#FF9C00'
    }, {
      name: '未整改',
      num: 0,
      color: '#FF4E00'
    }],

    // 数据统计
    tab1: [{
      icon: "icon_tab1",
      name: "工作日志",
      href: "/pages/statistic/g-z-r-z/index/index"
    }, {
      icon: "icon_tab2",
      name: "工作统计",
      href: "/pages/statistic/g-z-t-j/index/index"
    }, {
      icon: "icon_tab3",
      name: "应急统计",
      href: "/pages/statistic/y-j/index/index"
    }, {
      icon: "icon_tab4",
      name: "基本信息",
      href: "/pages/statistic/j-b-x-x/index/index"
    }],
    // 工作台
    tab2: [{
        icon: "icon_w_1",
        name: "上报动态",
        href: "/pages/work/s-b/index/index",
      },
      {
        icon: "icon_w_2",
        name: "待办事项",
        href: "/pages/work/d-b-s-x/index/index?id=0"
      },
      {
        icon: "icon_w_3",
        name: "已办事项",
        href: "/pages/work/d-b-s-x/index/index?id=1"
      },
      {
        icon: "icon_w_4",
        name: "有事找党员",
        href: "/pages/party-member/index/index"
      },
      {
        icon: "icon_w_5",
        name: "风险池",
        href: "/pages/risk-pool/index"
      },
    ],
    // 应急指挥
    tab3: [{
        icon: "icon_yj_1",
        name: "应急预案",
        href: "/pages/emergency/y-a/index/index",
      },
      {
        icon: "icon_yj_2",
        name: "应急上报",
        href: "/pages/emergency/s-b/index/index"
      },
      {
        icon: "icon_yj_3",
        name: "应急通讯录",
        href: "/pages/emergency/t-x/index/index"
      },
      {
        icon: "icon_yj_3",
        name: "指挥体系",
        href: "/pages/emergency/t-x-l/index/index"
      },
    ],

    // 公告
    notice: [],

    showPop: false,
    msgData: null,
    checkInfo: {},

    userInfo: {}
  },

  /**
   * 跳转
   */
  toSkip: function (params) {
    const item = params.currentTarget.dataset.item;
    const url = params.currentTarget.dataset.url;
    if (url || item?.href) {
      wx.navigateTo({
        url: url || item.href,
      })
    }
  },

  /**
   * 获取banner
   */
  getBanner: function () {
    app.axios("GET", "app", "/notice/lastFourNotice", {
      page: 1,
      limit: 4,
      userId: app.globalData.userInfo.userId
    }, false).then(res => {
      wx.stopPullDownRefresh();
      if (res.code == 1) {
        this.data.notice = res.data;
        this.setData(this.data)
      }
    })
  },

  /**
   * 通知详情
   */
  toMsgDetail: function (params) {
    const item = params.currentTarget.dataset.item;
    wx.navigateTo({
      url: `/pages/web/index?id=${item.govNoticeId}`,
    })
  },

  onLoad(option) {
    this.data.userInfo = app.globalData.userInfo;
    this.getBanner();
  },

  onReady() {

  },

  onPullDownRefresh() {
    this.getBanner();
  }
})