// pages/conference/conference.js const app = getApp() var host = app.globalData.host; Page({ /** * 页面的初始数据 */ data: { info:{}, text:'发送验证码', labels: { company: '单位', name: '姓名', tax_company: '发票单位', idcard: '身份证号', email: '邮箱', sex: '性别', age: '年龄', title: '职称', remark1: '备注1', remark2: '备注2', remark3: '备注3', phone:'手机号' }, sex_array: ['男', '女'], sex: -1, phone:'', show:0 }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this; wx.showNavigationBarLoading() var that = this; wx.getStorage({ key: 'uid', success: res => { if (res.data) { this.setData({ user_id: res.data }) wx.request({ url: host + '/api/detail', method: 'GET', data: { type: 'activity', id: options.id, uid: res.data }, success: function (res) { wx.hideNavigationBarLoading(); if(res.data.code != 0){ wx.showToast({ title: '服务器开小差啦!', icon: 'none' }) return } const info = res.data.data if (info.sign_note) { info.sign_note = info.sign_note.replace(/\\n/, '\n') } that.setData({ info: info }) }, fail: function () { wx.hideLoading(); wx.showToast({ title: '服务器开小差啦!', icon: 'none' }) } }) } }, fail:err=>{ wx.switchTab({ url: '../mine/mine', }) } }) }, close: function () { this.setData({ show: 0 }) }, open: function () { this.setData({ show: 1 }) }, phoneChange: function (e) { this.setData({ phone: e.detail.value }) }, sendcode: function () { if (this.data.phone.length < 11) { wx.showToast({ title: '请输入正确的手机号', icon: 'none' }) return; } wx.request({ url: host + '/api/phcode', method: 'POST', data: { phone: this.data.phone }, success: res => { if (res.data.code == 0) { wx.showToast({ title: '验证码已发送', }) this.countdown() } else { wx.showToast({ title: '发送失败', icon: 'none' }) } }, }) }, countdown: function () { var time = 60, text; var timer = setInterval(() => { if (time > 0) { time--; text = time + 's' } else { text = '发送验证码' clearInterval(timer) } this.setData({ text: text }) }, 1000) }, bindSexChange: function (e) { this.setData({ sex: e.detail.value }) }, //提交报名信息 submit: function (e) { var form = e.detail.value; var list = this.data.list, index = this.data.index; if (this.data.info.signup_fields.indexOf('sex') >= 0) { form.sex = this.data.sex > -1 ? this.data.sex:'' } form.uid = this.data.user_id; form.conference_id = this.data.info.id; form.conference_name = this.data.info.name; form.type ='activity'; console.log(form) var fields = this.data.info.signup_fields; for(let i=0;i { if (res.data.code == 0) { wx.hideLoading() this.setData({ show: 0 }) wx.redirectTo({ url: '../order/order', }) } else { wx.showToast({ title: '提交失败', icon: 'none' }) } }) }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })