let app = getApp()
Page({
  data: {
    IMG_NAME: app.IMG_NAME,
    currentTab: 0,
    loading: false,
    noMore: 0,
    loadingFailed: false,
    pageNo: 1,
    indicatorDots: true,
    autoplay: true,
    interval: 3000,
    duration: 1000,
    type: '1',
    list: [],
    myOrderList: []
  },

  onLoad(e) {
    wx.setNavigationBarTitle({
      title: '业务申请',
    })
    this.getList()
  },

  getList() {
    let that = this
    let workCondition = ''
    that.data.repairList = []
    if (that.data.currentTab == 0) {
      workCondition = '/applyPark/getByCurrentUser'
    } else if (that.data.currentTab == 1) {
      workCondition = '/settle/getByCurrentUser'
    } else if (that.data.currentTab == 2) {
      workCondition = '/applyMoveIn/getByCurrentUser'
    }
    app.AjaxRequest('get', {
      'content-type': 'application/json',
      'Authorization': 'Bearer ' + app.Getopenid()
    }, workCondition, {}, function (res) {
      if (res.code == 0) {
        that.setData({
          repairList: res.data
        })
      }
    })
  },

  bannernav(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.uri,
    })
  },

  navDetail(e) {
    var data = e.currentTarget.dataset
    wx.navigateTo({
      url: data.url + data.id
    })
  },

  navapply(e) {
    let data = JSON.stringify(e.currentTarget.dataset.objlist)
    wx.navigateTo({
      url: '/pages/enterpriseServices/serviceList/serviceList?data=' + data
    })
  },

  // 滑动加载
  // scrollToLower: function (e) {
  //   if (!this.data.loading && !this.data.noMore) {
  //     this.setData({
  //       loading: true,
  //       pageNo: this.data.pageNo + 1
  //     })
  //     this.getData(true);
  //   }
  // },

  // 滑动切换
  swiperTab(e) {
    this.setData({
      currentTab: e.detail.current
    })
    this.getList()
  },

  //点击切换
  clickTab(e) {
    var that = this
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      that.setData({
        currentTab: e.target.dataset.current
      })
    }
  }
})