import http from '../../base/httputil'

Page({
  /**
   * 组件的初始数据
   */
  data: {

    todayXunchaCount: 0,
    todayRiskCount: 0,
    todayEnterpriseCount: 0,

    xunchaList: null,


    menulist: [{
        "id": "1",
        "url": "icon-anquanxuncha",
        "title": "巡查",
      },
      {
        "id": "2",
        "url": "icon-xunjian",
        "title": "巡检",
      },
    ],
    mainmodel: {

    }
  },

  onLoad() {
    this.getXunchaCount()
    this.getXunchaList()
  },

  getXunchaCount() {
    http.post("/system/AppXunchaController/getXunchaCount", null, this.getXunchaCountSuccess)
  },
  getXunchaCountSuccess(res) {
    this.setData({
      todayXunchaCount: res.xunchaCount.todayXunchaCount,
      todayRiskCount: res.xunchaCount.todayRiskCount,
      todayEnterpriseCount: res.xunchaCount.todayEnterpriseCount
    })
  },
  getXunchaList() {
    http.post("/system/AppXunchaController/getXunchaList", null, this.getXunchaListSuccess)
  },
  getXunchaListSuccess(res) {
    this.setData({
      xunchaList: res.rows
    })
  },



  // 搜索结果跳页
  bindViewSearchEnd() {
    wx.navigateTo({
      url: '../xunchawu/xunchawu'
    })
  },
  toBindXunjinaMore(e){
    let isrisk = e.currentTarget.dataset.isrisk
    let buslogid = e.currentTarget.dataset.buslogid
    if(isrisk == 0){
      wx.showToast({
        title: '没有发现安全隐患,请放心!!',
        icon: "none" 
      })
    }
    console.log(isrisk,"####",buslogid)
  },

  menuItemClick: function (res) {
    //获取点击事件的信息
    let clickInfo = res.detail.iteminfo
    if(clickInfo.id ==2){
      //巡检
      wx.navigateTo({
        url: '../search/search',
      })

    }
    // 根据不同类型进行判别处理
    //事件的处理 代码
  }

})