const app = getApp() Page({ /** * 页面的初始数据 */ data: { frameStyle: { useTop: true, name: '审核入学', leftArrow: true, useBar: false }, id: '', form: {}, student_id: '', }, // 返回 back: function () { wx.navigateBack({ delta: 1 }) }, // 审核 toEdit: function (e) { const that = this; let params = {}; const { try_status } = e.currentTarget.dataset; wx.showModal({ title: '提示', content: '是否审核该条数据', async success(res) { if (res.confirm) { params.try_status = try_status if (that.data.id) { const arr = await app.$post(`/lessonStudent/${that.data.id}`, params); if (arr.errcode == '0') { wx.showToast({ title: `维护信息完成`, icon: 'success', duration: 2000 }); that.back(); } else wx.showToast({ title: `${error.msg}`, icon: 'error', duration: 2000 }) } } else if (res.cancel) { } } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { const that = this; that.setData({ id: options.id || '' }) // 监听用户是否登录 that.watchLogin(); }, // 监听用户是否登录 watchLogin: async function () { const that = this; wx.getStorage({ key: 'user', success: async res => { that.setData({ school_id: res.data.info.id }) const aee = await app.$get(`/dict`, { code: "student_grade" }); if (aee.errcode == '0' && aee.total > 0) that.setData({ levelList: aee.data[0].list }); const ree = await app.$get(`/dict`, { code: "gender" }); if (ree.errcode == '0' && ree.total > 0) that.setData({ genderList: ree.data[0].list }); if (that.data.id) { const aee = await app.$get(`/lessonStudent/${that.data.id}`); if (aee.errcode == '0') { that.setData({ student_id: aee.data.student_id }) } const arr = await app.$get(`/student/${that.data.student_id}`); if (arr.errcode == '0') { let gender = that.data.genderList.find(i => i.value == arr.data.gender) if (gender) arr.data.zhGender = gender.label; let level = that.data.levelList.find(i => i.value == arr.data.level) if (level) arr.data.zhLevel = level.label; that.setData({ form: arr.data }); } } }, fail: res => { wx.redirectTo({ url: '/pages/index/index', }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })