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

  /**
   * 页面的初始数据
   */
  data: {
    iurl: a.imghost, //服务器网址
    store: 0, //是否显示服务门店列表
    beautician: 0, //是否显示美容师列表
    beautician_name: null, //选中的美容师名称
    placeholder: "填写备注", //备注为空的placeholder
    store_list: null, //门店列表
    store_name: null, //选择的服务门店
    fir_pick_index: 0, //选择的门店下标
  },
  onclickstore: function() {
    var th = this;
    var store = th.data.store;
    if (store) {
      th.setData({
        store: 0,
        placeholder: "填写备注"
      })
    } else {
      th.setData({
        store: 1,
        placeholder: ""
      })
    }
  },
  query_bea: function(e) {
    var th = this;
    //获取选择美容师字段是不是为null,是的话就提示用户先选择门店
    if (true) {
      var beautician = th.data.beautician;
      var beaname = e.currentTarget.dataset.beaname;
      if (beautician) {
        // 判断是否选择美容师没有的话就把美容师列表收起来
        if (beaname != undefined) {
          th.setData({
            beautician: 0,
            beautician_name: beaname,
            placeholder: "填写备注"
          })
        } else {
          th.setData({
            beautician: 0,
            placeholder: "填写备注"
          })
        }
      } else {
        th.setData({
          beautician: 1,
          placeholder: ""
        })
      }

    } else {
      getApp().my_warnning("请先选择服务门店", 0, th);
    }
  },
  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].pickup_name;
    th.setData({
      store: 0,
      store_name: pickup_name
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {
    var th = this;
    wx.request({
      url: 'http://localhost:8022/api/weshop/yy_fuwu_sto',
      success: function(e) {
        if (e.data.code == 0) {
          th.setData({
            store_list: e.data.data.pageData
          })
        }
      }
    })
  }
})