const { reservation } = require("../../../utils/serve/user") // subpackage/user/apply-school/apply-school.js const app =getApp() Page({ /** * 页面的初始数据 */ data: { userName:"", phoneNo:"", schoolName:"", schoolAddress:"", }, input(e){ console.log(e) this.setData({ [e.currentTarget.id]:e.detail.value }) }, async submit(){ wx.showLoading({ title: '预约中', }) if(this.data.userName == '' || this.data.phoneNo == '') return app.showToast('请输入正确的联系人和电话') const queryString = Object.keys(this.data).map(key => `${key}=${this.data[key] || ""}`).join("&"); const res = await reservation(queryString,this.data) if(res.success){ wx.showModal({ title: '预约成功,请等待工作人员与您联系', content: '', complete: (res) => { wx.navigateBack() } }) }else{ app.showToast(res.errorMsg) } }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })