//职位添加 const app = getApp() Page({ /** * 页面的初始数据 */ data: { curShopId: '', //店铺ID positionName: '', //名称 positionOrder: 0, //排序 positionSummary: '' //职位描述 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ curShopId: options.shopId }) }, inputWatch(e) { let key = e.currentTarget.dataset.model this.setData({ [key]: e.detail.value }) }, checkParams() { if (this.data.positionName == '') { wx.showToast({ title: '请输入职位名称', icon: "none" }) return false } if (this.data.positionOrder == 0) { wx.showToast({ title: '请输入职位排序', }) return false } return true }, addPosition() { if (this.checkParams()) { let _self = this wx.showLoading({ title: '添加中...', }) app.http.post(app.urls.doSavePosition, { header: { token: app.globalData.token }, data: { shopId: _self.data.curShopId, positionName: _self.data.positionName, positionSummary: _self.data.positionSummary, positionOrder: _self.data.positionOrder } }) .then(res => { wx.hideLoading({}) wx.showToast({ title: '添加成功', success: function () { var pages = getCurrentPages(); //当前页面 var beforePage = pages[pages.length - 2]; //前一页 beforePage.setData({ isAddSuccess: true }) wx.navigateBack({ delta: 1, }) } }) }) .catch(err => { wx.hideLoading({}) }) } }, textareaBInput(e) { this.setData({ positionSummary: e.detail.value }) }, })