diff --git a/assets/js/http/signUp.js b/assets/js/http/signUp.js index 9c2be2a..707e0fa 100644 --- a/assets/js/http/signUp.js +++ b/assets/js/http/signUp.js @@ -23,11 +23,15 @@ const signUpApi = { uploadPayRecord: (params) => http.post(`${URL_CONFIG}meeting/payMeetingSituation/editTerminal`, params), // 通过单位名称校验是否标协会员 validateStandard: (params) => http.get(`${URL_CONFIG}meeting/internalMeetingSituation/checkMember`, params), - // 判断当前企业是否是内部企业 + // 判断当前企业是否是内部企业 judgeInternalEnterprise: (params) => http.get(`${URL_CONFIG}company/payCompanyManagement/getInternalEnterprise`, params), // 国际研讨会-判断当前的邀请码是否可用 judgeMeetingCode: (params) => http.get(`${URL_CONFIG}meeting/payMeetingSituation/validInvitationCode`, params), + // 报名的时候修改企业的信息 + updateInvoiceBySignUp: (params) => http.post(`${URL_CONFIG}company/payCompanyManagement/updateInvoice`, params), + + } -export default signUpApi \ No newline at end of file +export default signUpApi diff --git a/behavior/confirmInvoiceModal.js b/behavior/confirmInvoiceModal.js new file mode 100644 index 0000000..09f763b --- /dev/null +++ b/behavior/confirmInvoiceModal.js @@ -0,0 +1,123 @@ +// 发票信息模态框等相关操作的集合 +// 需要发票的类型 +export const InvoiceTypeEnums = { + noNeed: { name: '不需要', index: 0 }, + plain: { name: '增值税普通发票', index: 1 }, + special: { name: '增值税专用发票', index: 2 } +} +const commonArr = [ + {name: '企业名称', key: 'companyName'}, + {name: '信用代码', key: 'dutyCode'} +] +const specialArr = [ + {name: '公司地址', key: 'companyAddress'}, + {name: '公司电话', key: 'companyPhone'}, + {name: '开户行', key: 'openingBank'}, + {name: '银行账号', key: 'bankAccount'}, + {name: '联行号', key: 'linkBankNumber'} +] +import signUpApi from '../assets/js/http/signUp' + +module.exports = Behavior({ + data: { + // page-container 相关的配置 + statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'], + invoiceConfirmModalVisible: false, + duration: 300, + position: 'bottom', + round: false, + overlay: true, + customStyle: 'height: 60%;', + overlayStyle: '', + // 验证的相关信息 + confirmArr: [], + confirmObj: {} + + }, + methods: { + showConfirmModal(obj, callback) { + console.log("----showConfirmModal-----") + this.data.confirmObj = {...obj} + let needInvoice = Number(obj.needInvoice) + let confirmArr = [...commonArr] + if (needInvoice === InvoiceTypeEnums.special.index) { + confirmArr = confirmArr.concat(specialArr) + } + // 将回调函数存储 + this.confirmModalCallback = callback + this.setData({ + invoiceConfirmModalVisible: true, + confirmObj: this.data.confirmObj, + confirmArr + }) + }, + /** + * 判断发票信息是否发生改变 + * @param confirmObj ---form表单中的数据 + * @param selectedCompany ---单位的初始化信息 + * @returns {boolean} --返回是否发生改变 + */ + judgeInvoiceChange(confirmObj, selectedCompany) { + // 如果需要发票,判断当前的发票信息是否进行了修改,用于最后提交的时候判断是否请求接口,减少冗余的请求 + let needInvoice = Number(confirmObj.needInvoice) + if(!needInvoice) { + return false + } + if (needInvoice) { + let changeInvoiceFlag = this.data.confirmArr.some(tt => { + if(selectedCompany[tt.key] !== confirmObj[tt.key]) { + return true + } + }) + return changeInvoiceFlag + } + }, + confirmModalCancel() { + this.setData({ + invoiceConfirmModalVisible: false + }) + }, + confirmModalSureFunc() { + const formData = this.data.confirmObj + // 首先先判断发票信息有没有变化 + let changeInvoiceFlag = this.judgeInvoiceChange(formData, this.data.selectedCompany) + if(!changeInvoiceFlag) { + this.setData({ + invoiceConfirmModalVisible: false + }) + this.confirmModalCallback && this.confirmModalCallback() + return + } + + // 变化的时候请求接口 + // 请求接口同步数据 + const params = { + id: formData.companyId, // 企业id + needInvoice: formData.needInvoice, + companyName: formData.companyName, + dutyCode: formData.dutyCode + } + if (Number(formData.needInvoice) === InvoiceTypeEnums.special.index) { + params.companyAddress = formData.companyAddress + params.companyPhone = formData.companyPhone + params.openingBank = formData.openingBank + params.bankAccount = formData.bankAccount + params.linkBankNumber = formData.linkBankNumber + } + signUpApi.updateInvoiceBySignUp(params).then(res => { + if (res.success) { + this.setData({ + invoiceConfirmModalVisible: false + }) + this.confirmModalCallback && this.confirmModalCallback() + } else { + wx.showToast({ + title: res.message, + icon: "none", + duration: 800, + }); + } + }) + } + } +}) diff --git a/pages/companyList/companyList.js b/pages/companyList/companyList.js index 5c8c495..dde4c37 100644 --- a/pages/companyList/companyList.js +++ b/pages/companyList/companyList.js @@ -117,10 +117,11 @@ Page({ // wx.navigateTo({ // url: `../signUpPageGuoji/signUpPageGuoji?company=${selectedCompany}`, // }) - - - // 将上一个报名页面的企业回显 + + + // 将上一个报名页面的企业回显 prevPage.setData({ + 'selectedCompany': e.currentTarget.dataset.company, 'selectedCompany.companyName':e.currentTarget.dataset.company.companyName, 'selectedCompany.id':e.currentTarget.dataset.company.id, }) @@ -139,6 +140,7 @@ Page({ }) } else{ prevPage.setData({ + 'selectedCompany': e.currentTarget.dataset.company, 'selectedCompany.companyName':e.currentTarget.dataset.company.companyName, 'selectedCompany.id':e.currentTarget.dataset.company.id, }) @@ -168,7 +170,7 @@ Page({ } }) }) - + }, /** * 生命周期函数--监听页面加载 diff --git a/pages/signUpPage/signUpPage.js b/pages/signUpPage/signUpPage.js index ff55b08..7083e79 100644 --- a/pages/signUpPage/signUpPage.js +++ b/pages/signUpPage/signUpPage.js @@ -1,12 +1,23 @@ // pages/signUpPage/signUpPage.js import signUpApi from '../../assets/js/http/signUp' import MeetingApi from '../../assets/js/http/meetingApi' +// 引入对发票信息 校验的方法 +let confirmInvoiceModalBehavior = require('../../behavior/confirmInvoiceModal.js') import { phoneReg, postcode, - compareDate + compareDate, + dutyCode } from '../../utils/validate' + +const InvoiceTypeEnums = { + noNeed: { name: '不需要', index: 0 }, + plain: { name: '增值税普通发票', index: 1 }, + special: { name: '增值税专用发票', index: 2 } +} + Page({ + behaviors: [confirmInvoiceModalBehavior], /** * 页面的初始数据 */ @@ -15,17 +26,17 @@ Page({ identifyList: [{ value: '2', name: '参会人', - disabled:false + disabled: false }, { value: '1', name: '嘉宾', - disabled:false + disabled: false }, { value: '3', name: '内部企业', - disabled:true + disabled: true }, ], // 缴费方式 @@ -57,6 +68,16 @@ Page({ name: '增值税专用发票' }, ], + // 发票项目 + invoiceProjectList: [{ + value: '1', + name: '会议费' + }, + { + value: '2', + name: '培训费' + }, + ], // 是否住酒店 needCheckInHotel: [{ value: '1', @@ -71,6 +92,8 @@ Page({ selectedIdentity: '2', // 是否选择发票的选中的索引 默认需要 index: -1, + // 发票项目选择的索引 + invoiceProjectIndex: -1, paymentMethod: '1', // 抵达时间 arrivalTime: '请选择抵达时间', @@ -116,52 +139,50 @@ Page({ }) }, // 内部企业是否禁用 只有参会单位是内部企业才能选 否则禁用内部企业 - setIdentityDisabled(bool){ - const identifyLiseSelect = [ - { + setIdentityDisabled(bool) { + const identifyLiseSelect = [{ value: '2', name: '参会人', - disabled:false + disabled: false }, { value: '1', name: '嘉宾', - disabled:false + disabled: false }, { value: '3', name: '内部企业', - disabled:false + disabled: false }, ] - const identifyLiseSelectDisabled = [ - { + const identifyLiseSelectDisabled = [{ value: '2', name: '参会人', - disabled:false + disabled: false }, { value: '1', name: '嘉宾', - disabled:false + disabled: false }, { value: '3', name: '内部企业', - disabled:true + disabled: true }, ] - if(bool){ + if (bool) { // bool为真 说明是内部企业可以选择内部企业 this.setData({ - 'identifyList':identifyLiseSelect + 'identifyList': identifyLiseSelect }) - }else{ + } else { // 否则不能选中 console.log('不是内部i企业') this.setData({ - 'identifyList':identifyLiseSelectDisabled + 'identifyList': identifyLiseSelectDisabled }) } }, @@ -211,6 +232,7 @@ Page({ // 确定 formSubmit(e) { const formData = Object.assign({}, e.detail.value) + // 会议id if (this.data.selectedMeeting.id) { formData.meetingId = this.data.selectedMeeting.id @@ -240,7 +262,7 @@ Page({ return } - if(!formData.companyId ){ + if (!formData.companyId) { wx.showToast({ title: '请选择参会单位', icon: 'none', @@ -248,7 +270,7 @@ Page({ }) return } - if(!formData.companyContactId ){ + if (!formData.companyContactId) { wx.showToast({ title: '请选择参会人', icon: 'none', @@ -292,6 +314,77 @@ Page({ }) return } + // 20230720 新增需要判断当需要发票时,所有的发票信息是否填写 + if(Number(formData.needInvoice)){ + if (!formData.dutyCode) { + wx.showToast({ + title: '请输入信用代码', + icon: 'none', + duration: 2000 + }) + return + } + // 验证企业信用代码是否正确 + if(!dutyCode(formData.dutyCode)) { + wx.showToast({ + title: '请输入正确的信用代码', + icon: 'none', + duration: 2000 + }) + return + } + if(Number(formData.needInvoice) === InvoiceTypeEnums.special.index) { + if (!formData.companyAddress) { + wx.showToast({ + title: '请输入公司地址', + icon: 'none', + duration: 2000 + }) + return + } + if (!formData.companyPhone) { + wx.showToast({ + title: '请输入公司电话', + icon: 'none', + duration: 2000 + }) + return + } + if (!formData.openingBank) { + wx.showToast({ + title: '请输入开户行', + icon: 'none', + duration: 2000 + }) + return + } + if (!formData.bankAccount) { + wx.showToast({ + title: '请输入银行账号', + icon: 'none', + duration: 2000 + }) + return + } + if (!formData.linkBankNumber) { + wx.showToast({ + title: '请输入联行号', + icon: 'none', + duration: 2000 + }) + return + } + } + if (!formData.invoiceProject || formData.invoiceProject === -1) { + wx.showToast({ + title: '请选择发票项目', + icon: 'none', + duration: 2000 + }) + return + } + formData.invoiceProject = this.data.invoiceProjectList[formData.invoiceProject].value + } // 邮寄联系人 if (this.data.selectedPostPerson.id && formData.postContactId === undefined) { wx.showToast({ @@ -333,57 +426,67 @@ Page({ } } - wx.showLoading({ - title: '加载中', - mask: true - }) - signUpApi.signUpMeeting(formData).then(res => { - if (res.success) { - wx.hideLoading({ + let callback = () => { + wx.showLoading({ + title: '加载中', + mask: true + }) + signUpApi.signUpMeeting(formData).then(res => { + if (res.success) { + wx.hideLoading({}) + wx.showToast({ + title: '报名成功', + icon: 'loading', + duration: 1500 + }) + // 成功 清除缓存 跳转报名成功页面 + wx.removeStorage({ + key: 'selectedCompany', + }) + wx.removeStorage({ + key: 'meetingId', + }) + wx.removeStorage({ + key: 'currentMeetingInfo', + success() { + // 跳转报名成功页面 - }) - wx.showToast({ - title: '报名成功', - icon: 'loading', - duration: 1500 - }) - // 成功 清除缓存 跳转报名成功页面 - wx.removeStorage({ - key: 'selectedCompany', - }) - wx.removeStorage({ - key: 'meetingId', - }) - wx.removeStorage({ - key: 'currentMeetingInfo', - success() { - // 跳转报名成功页面 - - if (!res.result) { - wx.navigateTo({ - url: `../signUpSuccess/signUpSuccess?audit=${res.result}`, - }) - } else { - wx.navigateTo({ - url: `../signUpSuccess/signUpSuccess`, - }) + if (!res.result) { + wx.navigateTo({ + url: `../signUpSuccess/signUpSuccess?audit=${res.result}`, + }) + } else { + wx.navigateTo({ + url: `../signUpSuccess/signUpSuccess`, + }) + } } - } - }) - } else { + }) + } else { + wx.showToast({ + title: res.message, + icon: 'none', + duration: 2000 + }) + } + }).catch(e => { wx.showToast({ - title: res.message, - icon: 'none', + title: '操作失败', + icon: 'error', duration: 2000 }) - } - }).catch(e => { - wx.showToast({ - title: '操作失败', - icon: 'error', - duration: 2000 }) - }) + } + // 如果不需要发票 + if(!Number(formData.needInvoice)) { + callback && callback() + return + } + + //显示 校验发票信息的弹框 + this.showConfirmModal(formData, callback) + + }, // 选择参会单位 selectCompany() { @@ -427,6 +530,46 @@ Page({ }); } }, + // 信用代码验证 + validateDutyCode(e) { + console.log(e, 1111) + 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 (dutyCode(value)) { + // this.setData({ + // flag: false + // }) + } else { + wx.showToast({ + title: errmsg, + icon: 'none', + duration: 800 + }) + // this.setData({ + // flag: true + // }) + } + }, + // 发票项目变化的时候触发的方法 + invoiceProjectChange(e) { + console.log("------e--------", e) + this.setData({ + invoiceProjectIndex: e.detail.value + }) + }, // 根据会议id查询会议信息 queryMeetingInfo(id) { MeetingApi.meetingDetail({ @@ -487,6 +630,7 @@ Page({ // 默认填写个人信息 // 从缓存中拿个人信息 + // TODO 好像拿不到企业的其他信息 wx.getStorage({ key: 'userInfo', success(res) { @@ -577,6 +721,7 @@ Page({ }, + /** * 生命周期函数--监听页面初次渲染完成 */ @@ -661,8 +806,12 @@ Page({ }) } }).finally(() => { - if(that.data.selectedIdentity) { - that.changeIdentity({detail: {value: that.data.selectedIdentity}}) + if (that.data.selectedIdentity) { + that.changeIdentity({ + detail: { + value: that.data.selectedIdentity + } + }) } }) } diff --git a/pages/signUpPage/signUpPage.wxml b/pages/signUpPage/signUpPage.wxml index 5547aea..5198a00 100644 --- a/pages/signUpPage/signUpPage.wxml +++ b/pages/signUpPage/signUpPage.wxml @@ -2,23 +2,23 @@
- - - 参会单位: - - + + + 参会单位: + + - - 参会人: - - + + 参会人: + + - - 手机号: - - + + 手机号: + + - + 参会身份: @@ -30,87 +30,155 @@ - - - + + + 缴费方式: - + - - - 是否需要发票: - - - {{index === -1 ? '请选择' :needInvoiceList[index].name }} + + + 是否需要发票: + + + {{index === -1 ? '请选择' :needInvoiceList[index].name }} + + + + + + + 企业名称: + - - + + 信用代码: + + + + + + 公司地址: + + + + 公司电话: + + + + 开户行: + + + + 银行账号: + + + + 联行号: + + + + + 发票项目: + + + {{invoiceProjectIndex === -1 ? '请选择发票项目' : invoiceProjectList[invoiceProjectIndex].name }} + + + + + - - 邮寄联系人: - - + + 邮寄联系人: + + - - 邮寄地址: - - + + 邮寄地址: + + - - 邮编: - - + + 邮编: + + - + - 是否住酒店: + 是否住酒店: - + - - 抵达时间: - - - {{arrivalTime}} - - - + + 抵达时间: + + + {{arrivalTime}} + + + - - 离开时间: - - - {{departureTime}} - - - + + 离开时间: + + + {{departureTime}} + + + - - 费用合计: - - {{meetingCost}}元 - - - - + + 备注: +