// pages/signUpPageGuoji/signUpPageGuoji.js import MeetingApi from "../../assets/js/http/meetingApi" import signUpApi from "../../assets/js/http/signUp" import { phoneReg, postcode } from '../../utils/validate' import {baseUrl, URL_CONFIG} from '../../assets/js/project.config.js' Page({ /** * 页面的初始数据 */ data: { // 会议详情 meetingDetailInfo: {}, // 参会身份 identifyList: [{ value: '2', name: '参会人' }, { value: '1', name: '嘉宾' }, { value: '3', name: '内部企业' }, ], // 邀请码数组 inviteCodeArr: [], // 是否出现输入邀请码 参会身份选择嘉宾才出现 inviteCodeShowBool: false, // 校验邀请码的按钮控制 validateBtnBool: false, // 表单的邀请码值 inviteCode: "", // vip的表单显示 vipBool: false, // 演讲嘉宾的表单显示 speakerBool: false, // 合作伙伴的表单显示 cooperatieBool: false, // 特邀嘉宾的显示 guestBool: false, // 选中的参会单位 selectedCompany: {}, // 选中的联系人 selectedPerson: {}, // 选中的邮寄联系人 selectedPostPerson: {}, selectedMeeting:{}, // 抵达时间 arrivalTime: '请选择抵达时间', // 入住酒店时间 inHotelTime: '请选择入住酒店时间', // 离店时间 outHotelTime: '请选择离店时间', // 离开时间 departureTime: '请选择离开时间', // 是否选择发票的选中的索引 index: -1, // 是否需要用餐 haveMeal:'', // 是否住酒店 needHotel:'', // 是否接站 needPick:'', // 是否送站 needSend:'', // 上传图片的id imageIds: '', // 记录临时的文件名 用于回显 小程序上传后后端的名会乱码 tempFiles: '点击上传', // ppt Id speechPpt: '', // 嘉宾身份 guestType: -1, // 参会身份 identity:'', // 缴费方式 payMethod:'', // 缴费方式 paymentMethodList: [{ value: '1', name: '汇款' }, { value: '2', name: '现场缴费' }, { value: '3', name: '打包' }, ], needInvoiceList: [{ value: '0', name: '不需要' }, { value: '1', name: '增值税普通发票' }, { value: '2', name: '增值税专用发票' }, ], // 是否 need: [{ value: '1', name: '是' }, { value: '0', name: '否' }, ], flag:false, // 是否调用无限制接口 nolimitBool:false, //会议费用 meetingCosts:'' }, // 抵达时间选择 bindDateChangeArriveTime(e) { this.setData({ arrivalTime: e.detail.value }) }, // 离开时间选择 bindDateChangeLeaveTime(e) { this.setData({ departureTime: e.detail.value }) }, // 入住酒店时间 bindDateChangeInHotelTime(e) { this.setData({ inHotelTime: e.detail.value }) }, // 离店时间选择 bindDateChangeOutHotelTime(e) { this.setData({ outHotelTime: e.detail.value }) }, // 是否需要发票的选择 needInvoiceChange(e) { this.setData({ index: e.detail.value }) }, // 是否用餐 needHaveMeal(e){ let value = e.detail.value this.setData({ haveMeal:value }) }, // 是否住酒店 needHotel(e){ let value = e.detail.value this.setData({ needHotel:value }) }, // 是否接站 needPick(e){ let value = e.detail.value this.setData({ needPick:value }) }, // 是否送站 needSend(e){ let value = e.detail.value this.setData({ needSend:value }) }, // 缴费方式选择 paymentMethodRadioChange(e){ let value = e.detail.value this.setData({ payMethod:value }) }, // 选择参会单位 selectCompany(e) { wx.navigateTo({ }) if(this.data.nolimitBool){ wx.navigateTo({ url: `../companyList/companyList?page=${e.currentTarget.dataset.page}&nolimit=nolimit`, }) }else{ wx.navigateTo({ url: `../companyList/companyList?page=${e.currentTarget.dataset.page}`, }) } }, // 选择参会人 selectPerson(e) { const that = this if (!!this.data.selectedCompany.id) { wx.navigateTo({ url: `../personList/personList?companyId=${this.data.selectedCompany.id}&selectType=${e.currentTarget.dataset.selecttype}&page=${e.currentTarget.dataset.page}&nolimit=${that.data.nolimitBool}`, }) } else { wx.showToast({ title: '请先选择参会单位', icon: "none", duration: 800, }); } }, // 改变参会身份 changeIdentify(e) { const that = this let value = e.detail.value this.setData({ identity:value }) // 国际研讨会嘉宾 内部企业 不需要缴费 if( value === '2' ){ this.setData({ meetingCosts:that.data.selectedMeeting.meetingCosts }) }else{ this.setData({ meetingCosts: '0.00' }) } if (value === '1') { this.setData({ inviteCodeShowBool: true, validateBtnBool: true, inviteCode: '' }) } else { this.setData({ inviteCodeShowBool: false, validateBtnBool: false }) } // 切换身份显示的 bug this.setData({ vipBool: false, speakerBool: false, cooperatieBool: false, guestBool: false, }) }, // 设置邀请码的值 bindInputInviteCode(e) { // 在这里将所有控制表单都设为false 防止显示出问题 this.setData({ inviteCode: e.detail.value, vipBool: false, speakerBool: false, cooperatieBool: false, guestBool: false, }) }, // 校验邀请码 validateCode() { if (this.data.inviteCode === '' || this.data.inviteCode === undefined) { wx.showToast({ title: '请输入邀请码', icon: "none", duration: 800, }); return } else { console.log(this.data.inviteCodeArr); let validateArr = this.data.inviteCodeArr.filter(item => { return this.data.inviteCode === item.code }) if (validateArr.length === 0) { wx.showToast({ title: '邀请码输入有误', icon: "error", duration: 800, }); } else { wx.showToast({ title: '邀请码输入正确', icon: "success", duration: 800, }); console.log(validateArr[0].type); this.setData({ guestType: validateArr[0].type }) switch (validateArr[0].type) { case '1': this.setData({ vipBool: true, validateBtnBool: false }) break case '2': this.setData({ speakerBool: true, validateBtnBool: false }) break case '3': this.setData({ guestBool: true, validateBtnBool: false }) break case '4': this.setData({ cooperatieBool: true, validateBtnBool: false }) break } } } }, // 获取图片的id getImagesId(e) { this.setData({ imageIds: e.detail.join(',') }) }, // ppt的上传 uploadPPT() { const that = this wx.chooseMessageFile({ count: 1, //能选择文件的数量 type: 'file', //能选择文件的类型,我这里只允许上传文件.还有视频,图片,或者都可以 success(res) { console.log(res); var size = res.tempFiles[0].size; var name = res.tempFiles[0].name; var temporaryPdfArr = []; temporaryPdfArr.push(res.tempFiles[0]); var filePath = res.tempFiles[0].path; if (size > 10485760) { //限制了文件的大小和具体文件类型 wx.showToast({ title: '文件大小不能超过10MB', icon: "none", duration: 2000, mask: true }) } else { wx.showLoading({ title: '上传中...', mask: true, }); // 如果多个文件 要循环上传 wx.uploadFile({ url: baseUrl + URL_CONFIG + 'sys/common/upload', //上传的路径 filePath: filePath, //刚刚在data保存的文件路径 name: 'file', //后台获取的凭据 success(res) { var fileBackDa = JSON.parse(res.data); console.log(fileBackDa); var backPdfArr = []; backPdfArr.push(fileBackDa) wx.hideLoading(); //隐藏提示框 //上传成功, that.setData({ tempFiles: name, speechPpt: fileBackDa.result.id }); } }) } } }) }, // 手机号验证 validatePhone(e) { console.log(e); let value = e.detail.value let { message, errmsg } = e.currentTarget.dataset if (value === '' || value === undefined) { wx.showToast({ title: message, icon: 'none', duration: 800 }) this.setData({ flag: true }) return } else if (phoneReg(value)) { this.setData({ flag: false }) } else { wx.showToast({ title: errmsg, icon: 'none', duration: 800 }) this.setData({ flag: true }) } }, // 邮编验证 validatePostCode(e) { let value = e.detail.value let { message, errmsg } = e.currentTarget.dataset if (value === '' || value === undefined) { wx.showToast({ title: message, icon: 'none', duration: 800 }) this.setData({ flag: true }) return } else if (postcode(value)) { this.setData({ flag: false }) } else { wx.showToast({ title: errmsg, icon: 'none', duration: 800 }) this.setData({ flag: true }) } }, // 返回一一个邀请码的数组用于校验输入的邀请码显示不同的字段 1VIP 2演讲嘉宾 3特邀嘉宾 4 合作伙伴 validateCodeArr(obj) { let { vipInvitationCode, speakerInvitationCode, guestInvitationCode, cooperativeInvitationCode } = obj return [{ type: '1', code: vipInvitationCode }, { type: '2', code: speakerInvitationCode }, { type: '3', code: guestInvitationCode }, { type: '4', code: cooperativeInvitationCode } ] }, // 获取会议的详情 queryMeetingDetail(id) { const that = this MeetingApi.meetingDetail({ id: id }).then(res => { if (res.success) { this.setData({ meetingDetailInfo: res.result, inviteCodeArr: that.validateCodeArr(res.result), selectedMeeting:res.result, meetingCosts:res.result.meetingCosts }) } }) }, // 确定 formSubmit(e) { const formData = Object.assign({}, e.detail.value) console.log(e); if (this.data.flag) { wx.showToast({ title: '信息输入有误', icon: 'error', duration: 2000 }) return } if( !this.data.selectedPerson.id){ wx.showToast({ title: '请选择参会单位', icon: 'none', duration: 2000 }) return } if( !this.data.selectedPerson.id){ wx.showToast({ title: '请选择参会人', icon: 'none', duration: 2000 }) return } // 参会身份验证 if (formData.identity === '') { wx.showToast({ title: '请选择参会身份', icon: 'none', duration: 2000 }) return } // 缴费方式 选择嘉宾不需要校验 if (formData.payMode === '' && this.data.guestType !== '1' ) { wx.showToast({ title: '请选择缴费方式', icon: 'none', duration: 2000 }) return } // 是否需要发票 if (formData.needInvoice === -1 && this.data.guestType !== '1' ) { wx.showToast({ title: '请选择发票', icon: 'none', duration: 2000 }) return } // 邮寄地址 if (formData.postContactAddress === '' && this.data.guestType !== '1' ) { wx.showToast({ title: '请输入邮寄地址', icon: 'none', duration: 2000 }) return } // 邮编 if (formData.postCode === '' && this.data.guestType !== '1' ) { wx.showToast({ title: '请输入邮编', icon: 'none', duration: 2000 }) return } // 是否用餐 if(this.data.guestType === '1' && (formData.haveMeals == '' || formData.haveMeals === undefined) ){ wx.showToast({ title: '请选择是否用餐', icon: 'none', duration: 2000 }) return } // 是否回民 if(this.data.guestType === '1' && thism.data.haveMeal === '1' && (formData.huiPeople == '' || formData.huiPeople === undefined) ){ wx.showToast({ title: '请选择是否回民', icon: 'none', duration: 2000 }) return } // 是否住酒店 只有嘉宾身份是vip的才去校验 if (formData.checkInHotel === '' && this.data.guestType === '1' ) { wx.showToast({ title: '请选择是否住酒店', icon: 'none', duration: 2000 }) return } // 入住酒店时间 if (formData.inHotelTime === '' && this.data.needHotel === '1' && this.data. this.data.guestType === '1' ) { wx.showToast({ title: '请选择入住酒店时间', icon: 'none', duration: 2000 }) return } // 离店时间 if (formData.outHotelTime === '' && this.data.needHotel === '1' && this.data. this.data.guestType === '1' ) { wx.showToast({ title: '请选择离店时间', icon: 'none', duration: 2000 }) return } // 房型 if (formData.roomLayout === '' && this.data.needHotel === '1' && this.data. this.data.guestType === '1' ) { wx.showToast({ title: '请输入房型', icon: 'none', duration: 2000 }) return } // 是否需要接站 if(this.data.identity === '1' && this.data.guestType !== '4' && formData.pickUp === ''){ wx.showToast({ title: '请选择是否需要接站', icon: 'none', duration: 2000 }) return } // 抵达时间 if(this.data.identity === '1' && this.data.needPick === '1' && this.data.guestType !== '4' && formData.arrivalTime === ''){ wx.showToast({ title: '请选择抵达时间', icon: 'none', duration: 2000 }) return } // 到达站 if(this.data.identity === '1' && this.data.needPick === '1' && this.data.guestType !== '4' && formData.destination === ''){ wx.showToast({ title: '请选择到达站', icon: 'none', duration: 2000 }) return } // 到达班次 if(this.data.identity === '1' && this.data.needPick === '1' && this.data.guestType !== '4' && formData.arrivalShift === ''){ wx.showToast({ title: '请输入到达班次', icon: 'none', duration: 2000 }) return } // 是否需要送站 if(this.data.identity === '1' && this.data.guestType !== '4' && formData.deliveryStation === ''){ wx.showToast({ title: '请选择是否需要送站', icon: 'none', duration: 2000 }) return } // 离开时间 if(this.data.identity === '1' && this.data.needSend === '1' && this.data.guestType !== '4' && formData.departureTime === ''){ wx.showToast({ title: '请选择离开时间', icon: 'none', duration: 2000 }) return } // 离开站 if(this.data.identity === '1' && this.data.needSend === '1' && this.data.guestType !== '4' && formData.departureStation === ''){ wx.showToast({ title: '请输入离开站', icon: 'none', duration: 2000 }) return } // 离开班次 if(this.data.identity === '1' && this.data.needSend === '1' && this.data.guestType !== '4' && formData.departureShift === ''){ wx.showToast({ title: '请输入离开班次', icon: 'none', duration: 2000 }) return } // 会议id formData.meetingId = this.meetingDetailInfo.id // 参会人id formData.companyContactId = this.data.selectedPerson.id // 邮寄联系人id formData.postContactId = this.data.selectedPostPerson.id // 参会企业id formData.companyId = this.data.selectedCompany.id // 嘉宾身份类型 formData.guestType = this.data.guestType // 国际研讨会嘉宾上传的照片id formData.photo = this.data.imageIds // 国际研讨会嘉宾上传的ppt formData.speechPpt = this.data.speechPpt // 会议类型 // formData.meetingType = this.data.selectedMeeting.meetingType console.log(formData); signUpApi.signUpMeeting(formData).then(res => { if (res.success) { // 成功 清除缓存 跳转报名成功页面 wx.removeStorage({ key: 'selectedCompany', }) wx.removeStorage({ key: 'selectedPerson', }) wx.removeStorage({ key: 'selectedPostPerson', }) wx.removeStorage({ key: 'currentMeetingInfo', success() { // 跳转报名成功页面 wx.navigateTo({ url: '../signUpSuccess/signUpSuccess', }) } }) } }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // 这个id 可能是是会议活动进来的 或者消息 或者扫码的 if(options.meetingId){ this.queryMeetingDetail(options.meetingId) } if(options.nolimit){ this.setData({ nolimitBool:true }) } // 从缓存中拿选中的企业 const that = this wx.getStorage({ key: 'selectedCompany', success(res) { that.setData({ selectedCompany: JSON.parse(res.data) }) } }) // 从缓存中拿选中的会议的信息 wx.getStorage({ key: 'currentMeetingInfo', success(res) { console.log(res, 'meetingInfo'); that.setData({ selectedMeeting: res.data }) } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })