var e = getApp(),
  a = e.globalData.setting,
  os = a,
  t = e.request,
  d = e.globalData;
	
	
Page({

  /**
   * 页面的初始数据
   */
  data: {
    defimgurl: "/miniapp/images/no-head.jpg",
    iurl: a.imghost,
    cosmetology_list: [], //美容师列表
    is_cosmetology_read: 0, //是否有读过美容师接口,该属性用在没有美容师列表的排版
    curpage: 1, //当前分页数
    pageSize: 10, //页大小
    total: 0, //总数量
    ismore: 0, //是否加载完毕
    itemId: 0, //服务id,
    storageId: 0, //线下门店id
    projectId:"",//项目id
  },
	
  onReachBottom: function() {
    var th = this;
    if (this.data.total <= th.data.pageSize) return;
    if (this.data.ismore) return;
    wx.showLoading({
      title: '加载中...',
    })
    th.query_cology();
  },
	
	
  query_cology: function() {
    var th = this;
    var url = "/api/weshop/marketing/reservation/staff/pagenew";
    var itemId = th.data.itemId; //服务id
    var storageId = th.data.storageId;
    getApp().request.promiseGet(url, {
      data: {
        storeId: a.stoid,
        userId: th.data.options.userid,
        serviceId: itemId,
        storageId: storageId,
        page: th.data.curpage,
        pageSize: th.data.pageSize
      }
    }).then(res => {
      wx.hideLoading();
      if (res.data.code == 0) {
        th.data.curpage++;
        var arr1 = th.data.cosmetology_list;
        var arr2 = res.data.data;
        var arr3 = [...arr1, ...arr2];
      
    
        th.setData({
          cosmetology_list: arr3,
          total: res.data.data.total,      
          is_service_read: 1,
          is_cosmetology_read:1
        }), wx.stopPullDownRefresh(); //停止下拉刷新
      } else {
        th.setData({
          is_cosmetology_read:1,
		  ismore:1
        })
      }
    })
  },
	
	
  //图片失败，默认图片
  bind_bnerr1: function(e) {
    var _errImg = e.target.dataset.errorimg;
    var _Img = e.target.dataset.img;
    if (_Img != undefined) {
      var _errObj = {};
      _errObj[_errImg] = "/miniapp/images/no-head.jpg";
      console.log(_errObj,"zzzzzzz");
      this.setData(_errObj) //注意这里的赋值方式,只是将数据列表中的此项图片路径值替换掉 ;
    }
  },
	
	
	
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
		console.log('options--->', options);
    var th = this;
    this.setData({
			options,
      projectId: options.projectId,
      itemId: options.itemId,
      storageId: options.storageId
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var th = this;
	th.data.curpage++;	    
	th.setData({
	  cosmetology_list: [],
	  total: 0,      
	  is_service_read: 0,
	  is_cosmetology_read:0
	})	
    th.query_cology();
  },


})