// 获取应用实例
const app = getApp()

Page({
  data: {
    lunbo: [],
    admin: "", // 账号 
    pwd: "", //密码
    login: false,
    clockData: "", //打卡数据
    token:''
  },
  onShow() {
    let token = wx.getStorageSync('token')
    if (token == '') {

      this.setData({
        login: true
      })
    }else{
      this.IndexMyData()
    }
    this.setData({
      token
    })
    this.getlist()
  },
  // 关闭
  myevent() {
    this.setData({
      login: false
    })
  },

  // 轮播
  getlist() {
    var that = this;
    app.post("index/Banner", {}).then(res => {
      if (res.code == 1) {
        that.setData({
          lunbo: res.data

        })
      }
    }).catch(err => {

    })
  },
  //获取用户打卡数据
  IndexMyData() {
    var that = this;
    app.post("index/IndexMyData", {}).then(res => {
      if (res.code == 1) {
        that.setData({
          clockData: res.data

        })
      }
    }).catch(err => {

    })
  },





  // 
  // goToday() {
  //   wx.navigateTo({
  //     url: '/pages/first/first',
  //   })
  // },
  bindRask() {
    if(!this.data.token){
      this.setData({
        login:true
      })
      return
    }
    wx.navigateTo({
      url: '/pages/mission/mission',
    })
  }
})