From b26da71df5c976902aa114ea251585dd8a46574a Mon Sep 17 00:00:00 2001 From: gongfuxiang Date: Fri, 26 Jun 2026 00:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=91=E7=A5=A8=E6=8F=92=E4=BB=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=8B=E5=8D=95=E5=8D=B3=E5=BC=80=E7=A5=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locale/zh.json | 10 + pages.json | 6 +- pages/buy/buy.css | 12 +- pages/buy/buy.vue | 260 ++++++++++++-- .../invoice/common/invoice-form-mixin.js | 184 ++++++++++ .../invoice-buy-popup/invoice-buy-popup.vue | 199 +++++++++++ .../invoice-form-fields.vue | 153 ++++++++ .../invoice-saveinfo/invoice-saveinfo.vue | 329 ++++-------------- 8 files changed, 877 insertions(+), 276 deletions(-) create mode 100644 pages/plugins/invoice/common/invoice-form-mixin.js create mode 100644 pages/plugins/invoice/components/invoice-buy-popup/invoice-buy-popup.vue create mode 100644 pages/plugins/invoice/components/invoice-form-fields/invoice-form-fields.vue diff --git a/locale/zh.json b/locale/zh.json index ba1b90dd..2cbc2ec6 100644 --- a/locale/zh.json +++ b/locale/zh.json @@ -757,6 +757,16 @@ "4rb08b": "暂无可用优惠劵", "3740ur": "请选择地址", "71kidy": "请选择支付方式", + "k8inv1": "发票信息", + "k8inv2": "不开发票", + "k8inv3": "修改发票信息", + "k8inv4": "查看发票信息", + "k8inv5": "钱包支付不支持开票", + "k8inv6": "当前支付方式为钱包支付,不支持开具发票", + "k8inv7": "是否需要发票", + "k8inv8": "开发票", + "payment_expand_all": "展开全部支付方式", + "payment_collapse": "收起支付方式", "31616e": "当前模式不允许使用地址", "g7dk3f": "卡种选择", "0s1k23": "立即开通", diff --git a/pages.json b/pages.json index 84d59a42..2693279f 100644 --- a/pages.json +++ b/pages.json @@ -273,10 +273,12 @@ "enablePullDownRefresh": true, "navigationBarTitleText": "", "usingComponents": { - "component-form-input-base": "/pages/form-input/components/form-input/form-input-base" + "component-form-input-base": "/pages/form-input/components/form-input/form-input-base", + "component-invoice-buy-popup": "/pages/plugins/invoice/components/invoice-buy-popup/invoice-buy-popup" }, "componentPlaceholder": { - "component-form-input-base": "view" + "component-form-input-base": "view", + "component-invoice-buy-popup": "view" } } } diff --git a/pages/buy/buy.css b/pages/buy/buy.css index 2d6e7b8e..ceab0a21 100644 --- a/pages/buy/buy.css +++ b/pages/buy/buy.css @@ -81,6 +81,9 @@ font-size: 20rpx; background: #D8D8D8 linear-gradient(107deg, #FC6F31 0%, #E22C08 100%); } +.payment-list-toggle { + line-height: 60rpx; +} /** * 扩展数据 @@ -140,9 +143,16 @@ } .buy-data-item .right-value { width: calc(100% - 260rpx); + display: flex; + flex-direction: row; + align-items: center; + justify-content: flex-end; + flex-wrap: nowrap; } .buy-data-item .right-value .right-value-content { - width: calc(100% - 32rpx); + flex: 1; + min-width: 0; + width: auto; } /* diff --git a/pages/buy/buy.vue b/pages/buy/buy.vue index 8ab8111b..1b4848bb 100644 --- a/pages/buy/buy.vue +++ b/pages/buy/buy.vue @@ -209,24 +209,6 @@ {{ plugins_points_data.not_msg_tips }} - - - - - - {{ user_note_value || $t('common.leave_message') }} - - - {{ $t('buy.buy.q7jq76') }} - - - - {{ item }} - - - - - @@ -252,7 +234,7 @@ - + @@ -264,9 +246,47 @@ + + {{ payment_list_expand_status ? $t('buy.buy.payment_collapse') : $t('buy.buy.payment_expand_all') }} + + + + + + + + + {{ user_note_value || $t('common.leave_message') }} + + + {{ $t('buy.buy.q7jq76') }} + + + + {{ item }} + + + + + + + + + + {{ $t('buy.buy.k8inv1') }} + + {{ plugins_invoice_summary_text }} + + + + + + {{ $t('buy.buy.k8inv6') }} + + @@ -365,6 +385,16 @@ + + + @@ -382,8 +412,10 @@ import componentTimeSelect from '@/pages/common/components/time-select/time-select'; import componentPayment from '@/components/payment/payment'; import componentFormInputBase from '@/pages/form-input/components/form-input/form-input-base'; + import componentInvoiceBuyPopup from '@/pages/plugins/invoice/components/invoice-buy-popup/invoice-buy-popup'; var common_static_url = app.globalData.get_static_url('common'); + var plugins_invoice_buy_cache_key = 'plugins-invoice-buy-data'; export default { data() { return { @@ -396,6 +428,7 @@ bottom_fixed_style: '', params: null, payment_list: [], + payment_list_expand_status: false, payment_index: -1, payment_id: 0, goods_list: [], @@ -448,6 +481,14 @@ plugins_coin_is_valid: false, plugins_coin_payment_id: 0, + // 发票 + plugins_invoice_buy_data: null, + plugins_invoice_cache_data: {}, + plugins_invoice_summary_text: '', + plugins_invoice_summary_grey: true, + plugins_invoice_wallet_payment: false, + popup_plugins_invoice_status: false, + // 支付弹窗参数 pay_url: '', qrcode_url: '', @@ -469,7 +510,8 @@ componentNoData, componentTimeSelect, componentPayment, - componentFormInputBase + componentFormInputBase, + componentInvoiceBuyPopup }, onLoad(params) { @@ -727,8 +769,12 @@ plugins_intellectstools_data: data.plugins_intellectstools_data || null, plugins_coin_data: plugins_coin_data, plugins_coin_is_valid: plugins_coin_data != null && (plugins_coin_data.accounts_list || null) != null && plugins_coin_data.accounts_list.length > 0, + plugins_invoice_buy_data: data.plugins_invoice_buy_data || null, }); + // 发票数据处理 + this.plugins_invoice_init_handle(data.plugins_invoice_buy_data || null); + // 非门店模式则赋值指定的类型模式 if(this.is_first == 1) { if (this.buy_site_model_list.length > 0) { @@ -850,9 +896,143 @@ data.staff_booking_data = JSON.stringify(data.staff_booking_data); } + // 发票 + data['buy_invoice_data'] = this.plugins_invoice_data_encode(); + return data; }, + // 发票缓存读取 + plugins_invoice_cache_get() { + var cache = uni.getStorageSync(plugins_invoice_buy_cache_key); + return (cache || null) != null && typeof cache == 'object' ? cache : null; + }, + + // 发票缓存写入 + plugins_invoice_cache_set(data) { + if ((data || null) == null) { + uni.removeStorageSync(plugins_invoice_buy_cache_key); + return; + } + uni.setStorageSync(plugins_invoice_buy_cache_key, data); + }, + + // 发票数据编码 + plugins_invoice_data_encode(source) { + var data = this.plugins_invoice_data_build(source); + if (this.plugins_invoice_wallet_payment) { + data = { is_buy_invoice: 0 }; + } + try { + return base64.encode(JSON.stringify(data)); + } catch (e) { + return ''; + } + }, + + // 发票数据构建 + plugins_invoice_data_build(source) { + if ((source || null) == null) { + source = this.plugins_invoice_cache_get() || {}; + } + var is_buy_invoice = parseInt(source.is_buy_invoice || 0); + var result = { is_buy_invoice: is_buy_invoice }; + if (is_buy_invoice == 1) { + var fields = ['invoice_type', 'apply_type', 'invoice_content', 'invoice_title', 'invoice_code', 'invoice_bank', 'invoice_account', 'invoice_tel', 'invoice_address', 'name', 'tel', 'address', 'email', 'user_note']; + for (var i in fields) { + result[fields[i]] = source[fields[i]] || ''; + } + } + return result; + }, + + // 发票摘要文本 + plugins_invoice_summary_text_build(data) { + data = data || {}; + if (this.plugins_invoice_wallet_payment) { + return this.$t('buy.buy.k8inv5'); + } + if (parseInt(data.is_buy_invoice || 0) != 1) { + return this.$t('buy.buy.k8inv2'); + } + var config = this.plugins_invoice_buy_data || {}; + var type_map = config.invoice_type_map || {}; + var apply_map = config.apply_type_map || {}; + var type_name = type_map[parseInt(data.invoice_type || 0)] || ''; + var apply_name = apply_map[parseInt(data.apply_type || 0)] || ''; + var invoice_title = (data.invoice_title || '').trim(); + if (invoice_title) { + var inner = apply_name ? (apply_name + '-' + invoice_title) : invoice_title; + return type_name ? (type_name + '(' + inner + ')') : ('(' + inner + ')'); + } + return type_name || this.$t('buy.buy.k8inv8'); + }, + + // 发票摘要更新 + plugins_invoice_summary_update(source) { + var data = this.plugins_invoice_data_build(source); + if (this.plugins_invoice_wallet_payment) { + data = { is_buy_invoice: 0 }; + } + this.setData({ + plugins_invoice_cache_data: data, + plugins_invoice_summary_text: this.plugins_invoice_summary_text_build(data), + plugins_invoice_summary_grey: parseInt(data.is_buy_invoice || 0) != 1 || this.plugins_invoice_wallet_payment, + }); + this.plugins_invoice_cache_set(data); + }, + + // 发票初始化 + plugins_invoice_init_handle(invoice_data) { + if ((invoice_data || null) == null) { + this.setData({ + plugins_invoice_buy_data: null, + plugins_invoice_wallet_payment: false, + }); + return; + } + var is_wallet = parseInt(invoice_data.is_wallet_payment || 0) == 1; + this.setData({ + plugins_invoice_wallet_payment: is_wallet, + }); + if (is_wallet) { + this.plugins_invoice_summary_update({ is_buy_invoice: 0 }); + return; + } + var cache = this.plugins_invoice_cache_get(); + if (cache != null) { + this.plugins_invoice_summary_update(cache); + } else { + this.plugins_invoice_summary_update({ is_buy_invoice: 0 }); + } + }, + + // 发票弹窗打开 + plugins_invoice_open_event() { + if (this.plugins_invoice_wallet_payment) { + app.globalData.showToast(this.$t('buy.buy.k8inv5')); + return; + } + this.setData({ + popup_plugins_invoice_status: true, + }); + }, + + // 发票弹窗关闭 + plugins_invoice_close_event() { + this.setData({ + popup_plugins_invoice_status: false, + }); + }, + + // 发票确认 + plugins_invoice_confirm_event(data) { + this.plugins_invoice_summary_update(data); + this.setData({ + popup_plugins_invoice_status: false, + }); + }, + // 扩展数据最大显示状态事件 extension_data_max_show_event(e) { var index = e.currentTarget.dataset.index; @@ -1063,6 +1243,46 @@ this.init(); }, + // 可见支付方式列表 + payment_list_visible() { + var list = this.payment_list || []; + if (list.length <= 3 || this.payment_list_expand_status) { + return list; + } + var visible = list.slice(0, 3); + var selected_id = parseInt(this.payment_id || 0); + if (selected_id > 0) { + var selected_in_visible = false; + for (var i in visible) { + if (parseInt(visible[i]['id']) == selected_id) { + selected_in_visible = true; + break; + } + } + if (!selected_in_visible) { + for (var j = 3; j < list.length; j++) { + if (parseInt(list[j]['id']) == selected_id) { + visible[2] = list[j]; + break; + } + } + } + } + return visible; + }, + + // 是否显示支付方式展开按钮 + payment_list_expand_visible() { + return (this.payment_list || []).length > 3; + }, + + // 支付方式展开/收起 + payment_list_expand_event() { + this.setData({ + payment_list_expand_status: !this.payment_list_expand_status, + }); + }, + // 虚拟币支付方式选择 plugins_coin_payment_event(e) { var value = e.currentTarget.dataset.value; diff --git a/pages/plugins/invoice/common/invoice-form-mixin.js b/pages/plugins/invoice/common/invoice-form-mixin.js new file mode 100644 index 00000000..2af4a5c3 --- /dev/null +++ b/pages/plugins/invoice/common/invoice-form-mixin.js @@ -0,0 +1,184 @@ +const app = getApp(); + +const invoice_form_field_list = [ + 'invoice_title', + 'invoice_code', + 'invoice_bank', + 'invoice_account', + 'invoice_tel', + 'invoice_address', + 'name', + 'tel', + 'address', + 'email', + 'user_note', +]; + +export default { + methods: { + invoice_form_assign(data) { + if (typeof this.setData === 'function') { + this.setData(data); + } else { + Object.keys(data).forEach((key) => { + this[key] = data[key]; + }); + } + }, + + get_list_index(list, id) { + if ((list || null) == null || list.length == 0) { + return 0; + } + if (id === undefined || id === null || id === '') { + return 0; + } + for (var i in list) { + if (list[i]['id'] == id) { + return parseInt(i); + } + } + return parseInt(id) < list.length ? parseInt(id) : 0; + }, + + form_invoice_type_event(e) { + this.invoice_form_assign({ + form_invoice_type_index: e.detail.value, + }); + this.invoice_container_handle(); + }, + + form_apply_type_event(e) { + this.invoice_form_assign({ + form_apply_type_index: e.detail.value, + }); + this.invoice_container_handle(); + }, + + form_invoice_content_event(e) { + this.invoice_form_assign({ + form_invoice_content_index: e.detail.value, + }); + }, + + invoice_container_handle() { + if ((this.can_invoice_type_list || []).length == 0) { + return; + } + var invoice_type = this.can_invoice_type_list[this.form_invoice_type_index]['id']; + var upd_data = {}; + if (invoice_type == 2 || invoice_type == 3) { + upd_data.form_apply_type_index = this.get_list_index(this.apply_type_list, 1); + upd_data.form_apply_type_disabled = true; + } else { + upd_data.form_apply_type_disabled = false; + } + + switch (invoice_type) { + case 0: + upd_data.company_special_container = false; + upd_data.addressee_container = false; + upd_data.email_container = true; + break; + case 1: + upd_data.company_special_container = false; + upd_data.addressee_container = true; + upd_data.email_container = false; + break; + case 2: + upd_data.company_container = true; + upd_data.company_special_container = true; + upd_data.addressee_container = true; + upd_data.email_container = false; + break; + case 3: + upd_data.company_container = true; + upd_data.company_special_container = true; + upd_data.addressee_container = false; + upd_data.email_container = true; + break; + } + + if (invoice_type == 0 || invoice_type == 1) { + var apply_type = this.apply_type_list[this.form_apply_type_index]['id']; + upd_data.company_container = apply_type != 0; + } + this.invoice_form_assign(upd_data); + }, + + invoice_form_build_validation(invoice_type, apply_type) { + var validation = [ + { fields: 'invoice_title', msg: this.$t('invoice-saveinfo.invoice-saveinfo.r13p43') }, + ]; + if (apply_type == 1) { + validation.push({ fields: 'invoice_code', msg: this.$t('invoice-saveinfo.invoice-saveinfo.ws4wbb') }); + } + if (invoice_type == 2) { + validation.push({ fields: 'invoice_bank', msg: this.$t('invoice-saveinfo.invoice-saveinfo.87itn8') }); + validation.push({ fields: 'invoice_account', msg: this.$t('invoice-saveinfo.invoice-saveinfo.01lw93') }); + validation.push({ fields: 'invoice_tel', msg: this.$t('invoice-saveinfo.invoice-saveinfo.414ihr') }); + validation.push({ fields: 'invoice_address', msg: this.$t('invoice-saveinfo.invoice-saveinfo.g3yh32') }); + } + if (invoice_type == 1 || invoice_type == 2) { + validation.push({ fields: 'name', msg: this.$t('invoice-saveinfo.invoice-saveinfo.4xy6xi') }); + validation.push({ fields: 'tel', msg: this.$t('invoice-saveinfo.invoice-saveinfo.quhnk0') }); + validation.push({ fields: 'address', msg: this.$t('invoice-saveinfo.invoice-saveinfo.kq77u3') }); + } + return validation; + }, + + invoice_form_collect_result(data, invoice_type, apply_type) { + var result = { + invoice_type: invoice_type, + apply_type: apply_type, + }; + if (this.invoice_content_list.length > 0 && this.invoice_content_list[this.form_invoice_content_index] != undefined) { + result.invoice_content = this.invoice_content_list[this.form_invoice_content_index]; + } + for (var i in invoice_form_field_list) { + var field = invoice_form_field_list[i]; + result[field] = data[field] || ''; + } + return result; + }, + + invoice_form_init_state(source, default_data, lists) { + source = source || {}; + default_data = default_data || {}; + var form_data = {}; + for (var i in invoice_form_field_list) { + var field = invoice_form_field_list[i]; + form_data[field] = source[field] || default_data[field] || ''; + } + var data = Object.assign({}, default_data, source, form_data); + + var invoice_content_index = 0; + if ((source.invoice_content || default_data.invoice_content || null) != null) { + invoice_content_index = (lists.invoice_content_list || []).indexOf(source.invoice_content || default_data.invoice_content); + if (invoice_content_index == -1) { + invoice_content_index = 0; + } + } + + var apply_type_index = this.get_list_index(lists.apply_type_list || [], source.apply_type !== undefined ? source.apply_type : default_data.apply_type); + this.invoice_form_assign({ + can_invoice_type_list: lists.can_invoice_type_list || [], + apply_type_list: lists.apply_type_list || [], + invoice_content_list: lists.invoice_content_list || [], + form_data: form_data, + data: data, + form_invoice_type_index: this.get_list_index(lists.can_invoice_type_list || [], source.invoice_type !== undefined ? source.invoice_type : default_data.invoice_type), + form_apply_type_index: apply_type_index, + form_invoice_content_index: invoice_content_index, + form_apply_type_disabled: ((lists.apply_type_list || [])[apply_type_index] || {}).id == 1, + }); + this.invoice_container_handle(); + }, + + invoice_form_validate(data) { + var invoice_type = this.can_invoice_type_list[this.form_invoice_type_index]['id']; + var apply_type = this.apply_type_list[this.form_apply_type_index]['id']; + return app.globalData.fields_check(data, this.invoice_form_build_validation(invoice_type, apply_type)); + }, + }, +}; diff --git a/pages/plugins/invoice/components/invoice-buy-popup/invoice-buy-popup.vue b/pages/plugins/invoice/components/invoice-buy-popup/invoice-buy-popup.vue new file mode 100644 index 00000000..5d644c51 --- /dev/null +++ b/pages/plugins/invoice/components/invoice-buy-popup/invoice-buy-popup.vue @@ -0,0 +1,199 @@ + + + diff --git a/pages/plugins/invoice/components/invoice-form-fields/invoice-form-fields.vue b/pages/plugins/invoice/components/invoice-form-fields/invoice-form-fields.vue new file mode 100644 index 00000000..b9d1f589 --- /dev/null +++ b/pages/plugins/invoice/components/invoice-form-fields/invoice-form-fields.vue @@ -0,0 +1,153 @@ + + diff --git a/pages/plugins/invoice/invoice-saveinfo/invoice-saveinfo.vue b/pages/plugins/invoice/invoice-saveinfo/invoice-saveinfo.vue index ba03ba86..b44e8dfc 100644 --- a/pages/plugins/invoice/invoice-saveinfo/invoice-saveinfo.vue +++ b/pages/plugins/invoice/invoice-saveinfo/invoice-saveinfo.vue @@ -12,96 +12,25 @@ {{ save_base_data.business_desc }} - - - {{$t('invoice.invoice.j04kjc')}}* - - - {{ can_invoice_type_list[form_invoice_type_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.t3i3e3') : can_invoice_type_list[form_invoice_type_index]['name'] }} - - - + - - {{$t('invoice.invoice.hoenw8')}}* - - - {{ apply_type_list[form_apply_type_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.k31t2s') : apply_type_list[form_apply_type_index]['name'] }} - - - - - - {{$t('invoice-detail.invoice-detail.p73963')}}* - - - {{ invoice_content_list[form_invoice_content_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.i73t3c') : invoice_content_list[form_invoice_content_index] }} - - - - - - {{$t('invoice.invoice.y724c7')}}* - - - - - - - {{$t('invoice-saveinfo.invoice-saveinfo.x8hhiv')}}* - - - - - - - - {{$t('invoice-detail.invoice-detail.41qbu6')}}* - - - - {{$t('invoice-detail.invoice-detail.3a9459')}}* - - - - {{$t('invoice-detail.invoice-detail.2g7t23')}}* - - - - {{$t('invoice-detail.invoice-detail.6k6sov')}}* - - - - - - - - {{$t('invoice-detail.invoice-detail.7159m0')}}* - - - - {{$t('invoice-detail.invoice-detail.f2222p')}}* - - - - {{$t('invoice-detail.invoice-detail.q8l3zj')}}* - - - - - - - - {{$t('login.login.db1rf4')}} - - - - - - {{$t('common.note')}} - - - @@ -124,8 +53,11 @@ const app = getApp(); import componentCommon from '@/components/common/common'; import componentNoData from '@/components/no-data/no-data'; + import componentInvoiceFormFields from '@/pages/plugins/invoice/components/invoice-form-fields/invoice-form-fields'; + import invoiceFormMixin from '@/pages/plugins/invoice/common/invoice-form-mixin.js'; export default { + mixins: [invoiceFormMixin], data() { return { theme_view: app.globalData.get_theme_value_view(), @@ -155,6 +87,7 @@ components: { componentCommon, componentNoData, + componentInvoiceFormFields, }, onLoad(params) { @@ -208,7 +141,7 @@ if (res.data.code == 0) { var data = res.data.data; var default_data = ((data.data || null) == null || data.data.length == 0) ? null : data.data; - var upd_data = { + this.setData({ data_base: data.base || null, apply_type_list: data.apply_type_list || [], can_invoice_type_list: data.can_invoice_type_list || [], @@ -218,19 +151,16 @@ data_list_loding_status: 0, data_bottom_line_status: true, data_list_loding_msg: data.save_base_data.total_price <= 0 ? this.$t('invoice-saveinfo.invoice-saveinfo.dl11n1') : '', - }; - // 类型数据处理 + }); if (default_data != null) { - var invoice_content_index = upd_data.invoice_content_list.indexOf(default_data.invoice_content); - upd_data['form_invoice_type_index'] = default_data.invoice_type; - upd_data['form_apply_type_index'] = default_data.apply_type; - upd_data['form_invoice_content_index'] = invoice_content_index == -1 ? 0 : invoice_content_index; - upd_data['form_apply_type_disabled'] = default_data.apply_type == 1; + this.invoice_form_init_state(default_data, {}, { + can_invoice_type_list: data.can_invoice_type_list || [], + apply_type_list: data.apply_type_list || [], + invoice_content_list: data.invoice_content_list || [], + }); + } else { + this.invoice_container_handle(); } - this.setData(upd_data); - - // 数据容器处理 - this.invoice_container_handle(); } else { this.setData({ data_list_loding_status: 2, @@ -253,93 +183,6 @@ }); }, - // 发票类型事件 - form_invoice_type_event(e) { - this.setData({ - form_invoice_type_index: e.detail.value, - }); - this.invoice_container_handle(); - }, - - // 发票类型事件 - form_apply_type_event(e) { - this.setData({ - form_apply_type_index: e.detail.value, - }); - this.invoice_container_handle(); - }, - - // 发票内容事件 - form_invoice_content_event(e) { - this.setData({ - form_invoice_content_index: e.detail.value, - }); - }, - - // 容器显隐处理 - invoice_container_handle() { - // 发票类型 - var invoice_type = this.can_invoice_type_list[this.form_invoice_type_index]['id']; - if (invoice_type == 2 || invoice_type == 3) { - // 选择专票的时候申请类型必须是企业 - this.setData({ - form_apply_type_index: 1, - form_apply_type_disabled: true, - }); - } else { - this.setData({ - form_apply_type_disabled: false, - }); - } - - // 申请类型 - switch (invoice_type) { - // 增值税普通电子发票 - case 0: - this.setData({ - company_special_container: false, - addressee_container: false, - email_container: true, - }); - break; - // 增值税普通纸质发票 - case 1: - this.setData({ - company_special_container: false, - addressee_container: true, - email_container: false, - }); - break; - // 增值税专用纸质发票 - case 2: - this.setData({ - company_container: true, - company_special_container: true, - addressee_container: true, - email_container: false, - }); - break; - - // 增值税专用纸质发票 - case 3: - this.setData({ - company_container: true, - company_special_container: true, - addressee_container: false, - email_container: true, - }); - break; - } - - // 增值税专用纸质发票情况下个人类型处理 - if (invoice_type == 0 || invoice_type == 1) { - var apply_type = this.apply_type_list[this.form_apply_type_index]['id']; - this.setData({ - company_container: apply_type != 0, - }); - } - }, - // 表单提交 form_submit(e) { var data = e.detail.value; @@ -350,85 +193,65 @@ data['id'] = this.data.id; } - // 数据验证 var validation = [ { fields: 'invoice_type', msg: this.$t('invoice-saveinfo.invoice-saveinfo.t3i3e3'), is_can_zero: 1 }, { fields: 'apply_type', msg: this.$t('invoice-saveinfo.invoice-saveinfo.k31t2s'), is_can_zero: 1 }, { fields: 'invoice_title', msg: this.$t('invoice-saveinfo.invoice-saveinfo.r13p43') }, ]; if (app.globalData.fields_check(data, validation)) { - var invoice_type = this.can_invoice_type_list[this.form_invoice_type_index]['id']; - var apply_type = this.apply_type_list[this.form_apply_type_index]['id']; - if (apply_type == 1) { - validation.push({ fields: 'invoice_code', msg: this.$t('invoice-saveinfo.invoice-saveinfo.ws4wbb') }); + if (!this.invoice_form_validate(data)) { + return; } - if (invoice_type == 2) { - validation.push({ fields: 'invoice_bank', msg: this.$t('invoice-saveinfo.invoice-saveinfo.87itn8') }); - validation.push({ fields: 'invoice_account', msg: this.$t('invoice-saveinfo.invoice-saveinfo.01lw93') }); - validation.push({ fields: 'invoice_tel', msg: this.$t('invoice-saveinfo.invoice-saveinfo.414ihr') }); - validation.push({ fields: 'invoice_address', msg: this.$t('invoice-saveinfo.invoice-saveinfo.g3yh32') }); + data['invoice_type'] = this.can_invoice_type_list[this.form_invoice_type_index]['id']; + data['apply_type'] = this.apply_type_list[this.form_apply_type_index]['id']; + if (this.invoice_content_list.length > 0 && this.invoice_content_list[this.form_invoice_content_index] != undefined) { + data['invoice_content'] = this.invoice_content_list[this.form_invoice_content_index]; } + uni.showLoading({ + title: this.$t('common.submit_in_text'), + }); + this.setData({ + form_submit_loading: true, + }); - if (invoice_type == 1 || invoice_type == 2) { - validation.push({ fields: 'name', msg: this.$t('invoice-saveinfo.invoice-saveinfo.4xy6xi') }); - validation.push({ fields: 'tel', msg: this.$t('invoice-saveinfo.invoice-saveinfo.quhnk0') }); - validation.push({ fields: 'address', msg: this.$t('invoice-saveinfo.invoice-saveinfo.kq77u3') }); - } - - if (app.globalData.fields_check(data, validation)) { - // 发票类型 - data['invoice_type'] = this.can_invoice_type_list[this.form_invoice_type_index]['id']; - - // 发票内容 - if (this.invoice_content_list.length > 0 && this.invoice_content_list[this.form_invoice_content_index] != undefined) { - data['invoice_content'] = this.invoice_content_list[this.form_invoice_content_index]; - } - uni.showLoading({ - title: this.$t('common.submit_in_text'), - }); - this.setData({ - form_submit_loading: true, - }); - - // 网络请求 - uni.request({ - url: app.globalData.get_request_url('save', 'user', 'invoice'), - method: 'POST', - data: data, - dataType: 'json', - success: (res) => { - uni.hideLoading(); - if (res.data.code == 0) { - app.globalData.showToast(res.data.msg, 'success'); - var is_to = (this.params || null) != null && (this.params.is_redirect || 0) == 1; - setTimeout(function () { - // 是否关闭页面进入我的发票、适合从订单开票中过来提交成功直接进入我的发票列表 - if (is_to) { - app.globalData.url_open('/pages/plugins/invoice/invoice/invoice', true); - } else { - uni.navigateBack(); - } - }, 2000); - } else { - this.setData({ - form_submit_loading: false, - }); - if (app.globalData.is_login_check(res.data)) { - app.globalData.showToast(res.data.msg); + // 网络请求 + uni.request({ + url: app.globalData.get_request_url('save', 'user', 'invoice'), + method: 'POST', + data: data, + dataType: 'json', + success: (res) => { + uni.hideLoading(); + if (res.data.code == 0) { + app.globalData.showToast(res.data.msg, 'success'); + var is_to = (this.params || null) != null && (this.params.is_redirect || 0) == 1; + setTimeout(function () { + // 是否关闭页面进入我的发票、适合从订单开票中过来提交成功直接进入我的发票列表 + if (is_to) { + app.globalData.url_open('/pages/plugins/invoice/invoice/invoice', true); } else { - app.globalData.showToast(this.$t('common.sub_error_retry_tips')); + uni.navigateBack(); } - } - }, - fail: () => { - uni.hideLoading(); + }, 2000); + } else { this.setData({ form_submit_loading: false, }); - app.globalData.showToast(this.$t('common.internet_error_tips')); - }, - }); - } + if (app.globalData.is_login_check(res.data)) { + app.globalData.showToast(res.data.msg); + } else { + app.globalData.showToast(this.$t('common.sub_error_retry_tips')); + } + } + }, + fail: () => { + uni.hideLoading(); + this.setData({ + form_submit_loading: false, + }); + app.globalData.showToast(this.$t('common.internet_error_tips')); + }, + }); } }, },