const api = require("../../api/api"), app = getApp() Page({ data: {}, onLoad() {}, addUser(e){ let inputValue = e.detail.value if(inputValue.name != '' && inputValue.phone != '' && inputValue.password != ''){ my.showLoading(); api.request({ url : "users/createUser", header: { "Authorization": app.globalData.token }, method: "POST", data : { phone : inputValue.phone, name : inputValue.name, password : inputValue.password } }).then(res=>{ my.alert({ content : res.data, buttonText: '知道了', success: () => { my.navigateBack(); } }); my.hideLoading(); }).catch(err=>{ my.showToast({ content: err.data.message }) my.hideLoading(); }) }else if(inputValue.name == ''){ my.showToast({ content:"请输入店员姓名" }); }else if(inputValue.phone == ''){ my.showToast({ content:"请输入店员手机号码" }); }else if(inputValue.password == ''){ my.showToast({ content:"请输入店员登录密码" }); } } });