let app = getApp()
Page({
  data: {
    IMG_NAME: app.IMG_NAME,
    // 轮播
    bannerUrls: [{
        url: 'https://www.71big.com/heqing/zhaojingwang/common/images/banner1.jpg',
        linkUrl: ''
      },
      {
        url: 'https://www.71big.com/heqing/zhaojingwang/common/images/banner1.jpg',
        linkUrl: ''
      },
      {
        url: 'https://www.71big.com/heqing/zhaojingwang/common/images/banner1.jpg',
        linkUrl: ''
      }
    ],
    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: '服务',
    })
    let that = this
    if (e.type) {
      that.setData({
        type: '2'
      })
      wx.setNavigationBarTitle({
        title: '我的服务',
      })
    }
  },
  onShow(e) {
    var that = this
    app.AjaxRequest('get', {
      'content-type': 'application/json',
      'Authorization': 'Bearer ' + app.Getopenid()
    }, '/menu/list', {}, function (res) {
      that.setData({
        list: res.data
      })
    })
  },
  bannernav(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.uri,
    })
  },
  //轮播高度自适应——获取图片高度
  imgHeight: function (e) {
    var winWid = wx.getSystemInfoSync().windowWidth; //获取当前屏幕的宽度
    var imgh = e.detail.height; //图片高度
    var imgw = e.detail.width; //图片宽度
    var swiperH = winWid * imgh / imgw + "px"
    this.setData({
      Height: swiperH //设置高度
    })
  },
  changeType(e) {
    this.setData({
      type: e.currentTarget.dataset.type
    })
    if (e.currentTarget.dataset.type == 2) {
      wx.setNavigationBarTitle({
        title: '我的服务',
      })
    }
  },
  navapply(e) {
    let data = JSON.stringify(e.currentTarget.dataset.objlist)
    wx.navigateTo({
      url: '../enterpriseServices/serviceList/serviceList?data=' + data,
    })
  },
  navDetail(e) {
    wx.navigateTo({
      url: '../enterpriseServices/serviceDetail/serviceDetail?id=' + e.currentTarget.dataset.id,
    })
  },
  //请求数据
  getData(isPage) {
    let that = this
    let params = {
      pageNum: that.data.pageNo,
      pageSize: 10
    }
    that.setData({
      loading: false
    })
  },
  scrollToLower: function (e) {
    if (!this.data.loading && !this.data.noMore) {
      this.setData({
        loading: true,
        pageNo: this.data.pageNo + 1
      })
      this.getData(true);
    }
  },
})