createStaff.js 1.75 KB
// packageWorkspace/pages/residentManage/createStaff.js
const phoneRex = /^[1]([3-9])[0-9]{9}$/;
Page({

  /**
   * 页面的初始数据
   */
  data: {
		navStyle: 'background-color: transparent',
		navBarHeight: 88,
	},
	
	navbarReady(e) {
    let navBarHeight = e.detail.height
    this.setData({
      navBarHeight
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
		let comp = this.selectComponent('#componet-0')
		if (comp) {
			comp.setData({
				'staffObj.staffName': options?.staffName,
				'staffObj.staffPhone': options?.staffPhone,
				'staffObj.staffId': options?.staffId
			})
		}
	},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

	},

	back() {
    wx.$router.back()
	},
	
	getBaseSceneList() {
		getBaseSceneCodeList
	},
	
	checkRequired(obj) {
    let target = [
      "staffName",
      "staffPhone",
      "staffSceneLabel",
      "merchantId",
      "yqMerchantId"
    ];
  
    obj = {
      ...obj
    };
    if (!phoneRex.test(obj.staffPhone)) {
      this.showToast("请输入正确的手机号");
      return true;
    }
    try {
      target.map((key) => {
        if (!obj[key]) {
          throw key;
        }
      });
    } catch (error) {
      return error;
    }
    return false;
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})