123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- // 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<fields.length;i++){
- if (!form[fields[i]]){
- wx.showToast({
- title: '请输入' + this.data.labels[fields[i]]+'!',
- icon: 'none'
- })
- return;
- }
- }
- if (!form.code) {
- 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({
- 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 () {
- }
- })
|