const jsbuffer=require('../../lib/jsbuffer.min.js')
const { api, imgName, getUserInfo, wxLogin, alertTip, authAgainByUser, userLocation } = require('../../lib/util.js')
Page({
  data: {
    msg: 'welcome',
    imgDotBig: imgName('mesgDot1.png'),
    imgDotSmall: imgName('mesgDot2.png'),
    imgAlarmBattery: imgName('alarm_battery.png'),
    imgAlarmMove: imgName('alarm_move.png'),
    imgArrowUp:imgName('arrowup.png'),
    imgArrowDown:imgName('arrowdown.png'),
    alarmClass:'alarm-warn',
    alarmMsg:[{
      id:'1',
      open:false,
      date:{
        month:'二月',
        day:'27'
      },
      mileage:'0km',
      alarmNum:'35次',
      travelTimes:'10次',
      detail:[{
        time:'09:43',
        type:'battery',
        msg:'电池移除',
        warn:true
      }, {
        time: '12:43',
        type: 'battery',
        msg:'电池接入',
        warn: false
        }, {
          time: '13:53',
          type: 'move',
          msg:'车辆轻微震动',
          warn: false
      }, {
        time: '14:53',
        type: 'move',
        msg: '车辆严重震动',
        warn: true
      }]
    }]
  },
  onLoad: function () {

  },
  getImgSrc(type){
    console.log(type)
  },
  openDetail(e){
    let a =this.data.alarmMsg.map(item=>{
      if(item.id==e.target.dataset.num){
        item.open=!item.open
      }
      return item
    })
    this.setData({
      alarmMsg:a
    })
    a=null;
  },
  onShow: function () {
    // console.log('welcome show')
    // let ab=new jsbuffer().from('2152e2ac','hex')
    // ab.set(0,36)
    // console.log(ab)
    // let ba=new jsbuffer().read(ab.buffer)
    // console.log(ba)
    // console.log(ab.get(2))
    // console.log(ab.get(1, 'HEX'))
  }
})