// pages/qtest/form.js const api = require("../../utils/request.js"); Page({ /** * 页面的初始数据 */ data: { userInfo:{}, form:{ deptname:null, code:null } }, deptInput: function(e){ this.data.form.deptname = e.detail.value }, codeinput: function(e){ this.data.form.code = e.detail.value }, submit: function(){ if(this.data.form.deptname&&this.data.form.code){ wx.showToast({ title: '加入考试成功', icon:'none' }) let data = this.data.form api.request('/examtest/exam/attend/','POST', data).then(res=>{ wx.showLoading({ title: '正在组卷。。。', mask:true }) let exam = res.data.exam api.request(`/examtest/exam/${exam}/init/`,'POST', data).then(res=>{ console.log(res.data) wx.hideLoading({ success: (res) => {}, }) }).catch(e=>{ wx.hideLoading({ success: (res) => {}, }) }) }) }else{ wx.showToast({ title: '信息不完整', icon:'none' }) } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { api.request('/crm/consumer/info/','GET').then(res=>{ getApp().globalData.userinfo = res.data.userinfo this.setData( { userinfo: res.data.userinfo, form:{ deptname:res.data.userinfo.deptname }, } ) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })