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

  /**
   * 页面的初始数据
   */
  data: {
    iurl: a.imghost, //服务器网址
    store: 0, //是否显示服务门店列表
    beautician: 0, //是否显示美容师列表
    beautician_name: null, //选中的美容师名称
    placeholder: "填写备注", //备注为空的placeholder
    store_list: [], //门店列表
    beautician_list: [], //美容师列表
    store_name: "", //选择的服务门店
    fir_pick_index: 0, //选择的门店下标
    curpage: 1, //当前分页数
    pageSize: 5, //页大小
    total: 0,
    ismore: 0, //是否加载完毕
  },
  onclickstore: function() {
    var th = this;
    var store = th.data.store;
    if (store) {
      th.setData({
        store: 0,
        placeholder: "填写备注"
      })
    } else {
      th.setData({
        store: 1,
        placeholder: ""
      })
    }
  },
  goto: function(e) {
    var th = this;
    if (th.data.beautician_name != null) {
      var url = e.currentTarget.dataset.url;
      getApp().goto(url);
    } else {
      getApp().my_warnning("请先选择美容师", 0, th);
    }
  },
  //点击选择门店
  choose_for_store: function(e) {
    var th = this;
    var index_c = e.currentTarget.dataset.ind;
    var fir_pick_index = th.data.fir_pick_index;
    //判断是否点击选中的门店,防止重复点击重复设置选中下标
    if (index_c == fir_pick_index) {
      return false;
    } else {
      th.setData({
        fir_pick_index: index_c
      })
    }
  },
  //确认选择门店
  choice_store: function() {
    var th = this;
    var index = th.data.fir_pick_index;
    var pickup_name = th.data.store_list[index].StorageName;
    th.setData({
      store: 0,
      store_name: pickup_name
    })
  },
  onReachBottom: function() {
    var th = this;
    if (this.data.total <= th.data.pageSize) return;
    if (this.data.ismore) return;

    wx.showLoading({
      title: '加载中...',
    })
    th.query_store();
  },
  //分页查询门店信息
  query_store: function() {
    var th = this;
    var itemid = "8f503b2e-f35f-4210-ba42-df4345526b93";
    var url = "/api/weshop/marketing/reservation/storage/page";
    getApp().request.promiseGet(url, {
      data: {
        storeId: a.stoid,
        userId: d.user_id,
        itemId: itemid,
        page: th.data.curpage,
        pageSize: th.data.pageSize
      }
    }).then(res => {
      if (res.data.code == 0) {
        wx.hideLoading();
        th.data.curpage++;
        var arr1 = th.data.store_list;
        var arr2 = res.data.data.pageData;
        var arr3 = [...arr1, ...arr2];
        var ismore = 0;
        if (arr3.length == res.data.data.total) ismore = 1
        th.setData({
          store_list: arr3,
          total: res.data.data.total,
          ismore: ismore,
          is_service_read: 1,
        }), wx.stopPullDownRefresh(); //停止下拉刷新
      }
    })
  },
  //查询
  query_beautician: function() {
    var th = this;
    if (th.data.store_name == "") {
      getApp().my_warnning("请先选择服务门店", 0, th);
    } else {
      if (th.data.beautician == 0) {
        th.setData({
          beautician: 1
        })
      } else {
        th.setData({
          beautician: 0
        })
      }
      var itemid = "8f503b2e-f35f-4210-ba42-df4345526b93";
      var storageId = "FD8EC44A-6474-4BA1-A17C-A87306690E59";
      var url = "/api/weshop/marketing/reservation/staff/page";
      getApp().request.promiseGet(url, {
        data: {
          storeId: a.stoid,
          userId: d.user_id,
          itemId: itemid,
          storageId: storageId
        }
      }).then(res => {
        if (res.data.code == 0) {
          th.setData({
            beautician_list: res.data.data.pageData
          }) //停止下拉刷新
        }
      })
    }
  },
  choice_beautician: function(e) {
    var th = this;
    var bea_name = e.currentTarget.dataset.beaname;
    th.setData({
      beautician_name:bea_name
    })
 
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var th = this;
    th.query_store();
  }
})