// pages/actDetail/actDetail.js const app = getApp() var host = app.globalData.host; Page({ /** * 页面的初始数据 */ data: { info: {}, uid: '', zk1: 0, zk2: 0, sex_array: ['男', '女'], sex: -1, job_array: ['非中科院单位','中科院单位'], job: 0, show: 0, list:[], index:[0,0,0], page:1, proof_img:'', user_id:'', //用户id apply_id:'' //报名ID }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { options.id=1; if (options.apply_id){ this.setData({ page: 3, show:1, apply_id: options.apply_id }) } 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: 'conference', id: options.id }, success: function (res) { wx.hideNavigationBarLoading(); that.setData({ info: res.data.data }) }, fail: function () { wx.hideLoading(); wx.showToast({ title: '服务器开小差啦!', icon: 'none' }) } }) //中科院单位 wx.request({ url: host + '/api/organization/list', method: 'GET', success: function (res) { wx.hideNavigationBarLoading(); var list=[]; list[0] = res.data.data; list[1] = list[0][0].children; list[2] = list[1][0].children; that.setData({ list: list }) }, }) }, upload:function(){ wx.chooseImage({ count:0, success: res=>{ wx.showLoading({ title: '正在上传', }) wx.uploadFile({ url: host + '/api/uploadfile', filePath: res.tempFilePaths[0], name: 'file', success:response=>{ wx.hideLoading(); let data = JSON.parse(response.data); this.setData({ proof_img:data.data }) } }) }, }) }, bindMultiPickerColumnChange:function(e){ console.log('修改的列为', e.detail.column, ',值为', e.detail.value); var list = this.data.list, i = e.detail.value, j = e.detail.column; var index=this.data.index; index[j] = i if (e.detail.column == 0){ list[1] = list[i][0].children; list[2] = list[1][0].children; index[1]=0; index[2]=0; } if (e.detail.column == 1) { list[1] = list[i][0].children; list[2] = list[1][0].children; index[2] = 0; } this.setData({ list: list, index: index }) }, bindSexChange:function(e){ this.setData({ sex: e.detail.value }) }, bindPickerChange:function(e){ this.setData({ job: e.detail.value }) }, skip:function(){ this.setData({ page: this.data.page+2 }) }, sure: function () { this.setData({ page: this.data.page + 1 }) }, close:function(){ this.setData({ show: 0 }) }, open: function () { this.setData({ show: 1 }) }, //提交报名信息 submit: function (e) { var form = e.detail.value; var list = this.data.list, index=this.data.index; form.organizer_unit = list[0][index[0]].value+list[1][index[1]].value+list[2][index[2]].value form.uid=this.data.user_id; form.conference_id=this.data.info.id; form.conference_name = this.data.info.name; if(!form.name){ wx.showToast({ title: '请输入姓名!', icon:'none' }) return; } if (!form.job) { wx.showToast({ title: '请输入职务!', icon: 'none' }) return; } if (!form.phone) { wx.showToast({ title: '请输入手机号!', icon: 'none' }) return; } wx.showLoading({ title: '正在提交', }) wx.request({ url: host + '/api/user/signup', method:'POST', data: form, success:(res=>{ if(res.data.code == 0){ wx.hideLoading() this.setData({ page: 2, apply_id:res.data.data }) }else{ wx.showToast({ title: '提交失败', icon:'none' }) } }) }) }, //提交凭证 submit1:function(e){ var form = e.detail.value; form.id=this.data.apply_id; form.proof_img = this.data.proof_img; wx.showLoading({ title: '正在提交', }) wx.request({ url: host + '/api/user/signup', method: 'PUT', data: e.detail.value, success: (res => { wx.hideLoading(); if (res.data.code == 0) { wx.showToast({ title: '提交成功', }) this.skip(); } }), fail:error=>{ wx.hideLoading() } }) }, home:function(){ wx.switchTab({ url: '../mine/mine', }) }, zk1: function () { this.setData({ zk1: 1 }) }, sq1: function () { this.setData({ zk1: 0 }) }, zk2: function () { this.setData({ zk2: 1 }) }, sq2: function () { this.setData({ zk2: 0 }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })