发票插件支持下单即开票

This commit is contained in:
gongfuxiang
2026-06-26 00:08:21 +08:00
parent f019d15071
commit b26da71df5
8 changed files with 877 additions and 276 deletions

View File

@ -757,6 +757,16 @@
"4rb08b": "暂无可用优惠劵",
"3740ur": "请选择地址",
"71kidy": "请选择支付方式",
"k8inv1": "发票信息",
"k8inv2": "不开发票",
"k8inv3": "修改发票信息",
"k8inv4": "查看发票信息",
"k8inv5": "钱包支付不支持开票",
"k8inv6": "当前支付方式为钱包支付,不支持开具发票",
"k8inv7": "是否需要发票",
"k8inv8": "开发票",
"payment_expand_all": "展开全部支付方式",
"payment_collapse": "收起支付方式",
"31616e": "当前模式不允许使用地址",
"g7dk3f": "卡种选择",
"0s1k23": "立即开通",

View File

@ -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"
}
}
}

View File

@ -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;
}
/*

View File

@ -209,24 +209,6 @@
<view v-if="(plugins_points_data.not_msg_tips || null) != null" class="desc tr">{{ plugins_points_data.not_msg_tips }}</view>
</block>
</view>
<!-- 留言 -->
<view class="content-textarea-container padding-main border-radius-main bg-white spacing-mb">
<view class="content">
<textarea v-if="user_note_status" class="textarea" @blur="bind_user_note_blur_event" @input="bind_user_note_event" :focus="true" :disable-default-padding="false" :value="user_note_value" maxlength="230" :placeholder="$t('common.leave_message')"></textarea>
<view v-else @tap="bind_user_note_tap_event" :class="'textarea-view ' + ((user_note_value || null) == null ? 'cr-grey' : '')">{{ user_note_value || $t('common.leave_message') }}</view>
</view>
<view v-if="(plugins_intellectstools_data || null) != null && (plugins_intellectstools_data.note_fast_data || null) != null" class="plugins-intellectstools-data-note-fast margin-top-sm">
<text class="cr-grey margin-right-sm va-m text-size-xs">{{ $t('buy.buy.q7jq76') }}</text>
<view class="note-fast-data-list scroll-view-horizontal dis-inline-block va-m">
<scroll-view :scroll-x="true" :show-scrollbar="false" :scroll-with-animation="true">
<block v-for="(item, index) in plugins_intellectstools_data.note_fast_data" :key="index">
<view :class="'dis-inline-block text-size-xs round padding-top-xs padding-bottom-xs padding-left padding-right br-grey-f5 cr-base cp ' + (index > 0 ? 'margin-left-sm' : '')" :data-value="item" @tap="note_fast_event">{{ item }}</view>
</block>
</scroll-view>
</view>
</view>
</view>
<!-- 支付选择 -->
<view v-if="total_price > 0 && ((common_order_is_booking != 1 && payment_list.length > 0) || plugins_coin_is_valid)" class="payment-list border-radius-main bg-white oh padding-main spacing-mb">
@ -252,7 +234,7 @@
</block>
<!-- 支付方式 -->
<view v-if="common_order_is_booking != 1 && payment_list.length > 0" :class="(plugins_coin_is_valid ? 'br-t-f9' : '')">
<view v-for="(item, index) in payment_list" :key="index">
<view v-for="(item, index) in payment_list_visible()" :key="item.id">
<view class="item flex-row jc-sb align-c" :data-value="item.id" :data-index="index" @tap="payment_event">
<view class="item-content pr flex-1 flex-width">
<image v-if="(item.logo || null) != null" class="icon margin-right-sm va-m radius" :src="item.logo" mode="widthFix"></image>
@ -264,9 +246,47 @@
</view>
</view>
</view>
<view v-if="payment_list_expand_visible()" class="payment-list-toggle tc padding-top-sm cp" @tap="payment_list_expand_event">
<text class="cr-grey text-size-xs va-m">{{ payment_list_expand_status ? $t('buy.buy.payment_collapse') : $t('buy.buy.payment_expand_all') }}</text>
<view class="dis-inline-block margin-left-xs va-m">
<iconfont :name="payment_list_expand_status ? 'icon-arrow-top' : 'icon-arrow-bottom'" size="28rpx" propClass="cr-grey"></iconfont>
</view>
</view>
</view>
</view>
<!-- 留言 -->
<view class="content-textarea-container padding-main border-radius-main bg-white spacing-mb">
<view class="content">
<textarea v-if="user_note_status" class="textarea" @blur="bind_user_note_blur_event" @input="bind_user_note_event" :focus="true" :disable-default-padding="false" :value="user_note_value" maxlength="230" :placeholder="$t('common.leave_message')"></textarea>
<view v-else @tap="bind_user_note_tap_event" :class="'textarea-view ' + ((user_note_value || null) == null ? 'cr-grey' : '')">{{ user_note_value || $t('common.leave_message') }}</view>
</view>
<view v-if="(plugins_intellectstools_data || null) != null && (plugins_intellectstools_data.note_fast_data || null) != null" class="plugins-intellectstools-data-note-fast margin-top-sm">
<text class="cr-grey margin-right-sm va-m text-size-xs">{{ $t('buy.buy.q7jq76') }}</text>
<view class="note-fast-data-list scroll-view-horizontal dis-inline-block va-m">
<scroll-view :scroll-x="true" :show-scrollbar="false" :scroll-with-animation="true">
<block v-for="(item, index) in plugins_intellectstools_data.note_fast_data" :key="index">
<view :class="'dis-inline-block text-size-xs round padding-top-xs padding-bottom-xs padding-left padding-right br-grey-f5 cr-base cp ' + (index > 0 ? 'margin-left-sm' : '')" :data-value="item" @tap="note_fast_event">{{ item }}</view>
</block>
</scroll-view>
</view>
</view>
</view>
<!-- 发票信息 -->
<view v-if="plugins_invoice_buy_data != null && total_price > 0" class="padding-horizontal-main border-radius-main bg-white spacing-mb">
<view class="buy-data-item oh" @tap="plugins_invoice_open_event">
<text class="cr-base">{{ $t('buy.buy.k8inv1') }}</text>
<view class="right-value fr cp tr">
<text :class="'right-value-content single-text va-m ' + (plugins_invoice_summary_grey ? 'cr-grey' : 'cr-base')">{{ plugins_invoice_summary_text }}</text>
<view class="dis-inline-block va-m lh-xs">
<iconfont name="icon-arrow-right" color="#999"></iconfont>
</view>
</view>
</view>
<view v-if="plugins_invoice_wallet_payment" class="cr-grey text-size-xs padding-bottom-sm">{{ $t('buy.buy.k8inv6') }}</view>
</view>
<!-- 底部说明 - 智能工具箱插件 -->
<view v-if="(plugins_intellectstools_data || null) != null && (plugins_intellectstools_data.bottom_desc || null) != null && plugins_intellectstools_data.bottom_desc.length > 0" class="border-radius-main padding-main bg-white oh cr-orange spacing-mb">
<view v-for="(item, index) in plugins_intellectstools_data.bottom_desc" :key="index">
@ -365,6 +385,16 @@
</view>
</component-popup>
<!-- 发票选择 -->
<component-invoice-buy-popup
:propShow="popup_plugins_invoice_status"
:propConfig="plugins_invoice_buy_data"
:propCacheData="plugins_invoice_cache_data"
:propCurrencySymbol="currency_symbol"
@onclose="plugins_invoice_close_event"
@onconfirm="plugins_invoice_confirm_event"
></component-invoice-buy-popup>
<!-- 支付组件 -->
<component-payment ref="payment" :propIsRedirectTo="true" :propPayUrl="pay_url" :propQrcodeUrl="qrcode_url" :propToAppointPage="to_appoint_page" propPayDataKey="ids" :propPaymentList="payment_list" :propToPageBack="to_page_back" :propToFailPage="to_fail_page"></component-payment>
</block>
@ -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;

View File

@ -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));
},
},
};

View File

@ -0,0 +1,199 @@
<template>
<component-popup :propShow="propShow" propPosition="bottom" @onclose="close_event">
<view class="plugins-invoice-buy-popup bg-base">
<view class="popup-header flex-row jc-sb align-c padding-horizontal-main padding-top-main padding-bottom-sm">
<view class="text-size fw-b">{{ $t('buy.buy.k8inv1') }}</view>
<view class="cp" @tap.stop="close_event">
<iconfont name="icon-close-line" size="28rpx" color="#999"></iconfont>
</view>
</view>
<view class="padding-horizontal-main padding-bottom-main">
<view v-if="(config.invoice_desc || null) != null && config.invoice_desc.length > 0" class="padding-main border-radius-main bg-white spacing-mb cr-grey text-size-xs">
<view v-for="(item, index) in config.invoice_desc" :key="index">{{ index + 1 }}. {{ item }}</view>
</view>
<view class="padding-main border-radius-main bg-white spacing-mb">
<text class="cr-base margin-right-sm">{{ $t('invoice.invoice.fvuc4p') }}</text>
<text class="cr-main text-size fw-b">{{ currency_symbol }}{{ config.total_price }}</text>
</view>
<form @submit="form_submit" class="form-container">
<view class="border-radius-main bg-white oh spacing-mb">
<view class="form-gorup invoice-choice-group">
<view class="form-gorup-title">{{ $t('buy.buy.k8inv7') }}</view>
<radio-group class="invoice-radio-group" name="is_buy_invoice" @change="buy_invoice_choice_event">
<label class="invoice-radio-item margin-right-lg">
<radio class="invoice-radio" value="0" :checked="is_buy_invoice == 0" color="#E22C08" style="transform: scale(0.7)" />{{ $t('buy.buy.k8inv2') }}
</label>
<label class="invoice-radio-item">
<radio class="invoice-radio" value="1" :checked="is_buy_invoice == 1" color="#E22C08" style="transform: scale(0.7)" />{{ $t('buy.buy.k8inv8') }}
</label>
</radio-group>
</view>
<block v-if="is_buy_invoice == 1">
<component-invoice-form-fields
:can_invoice_type_list="can_invoice_type_list"
:apply_type_list="apply_type_list"
:invoice_content_list="invoice_content_list"
:form_data="form_data"
:form_invoice_type_index="form_invoice_type_index"
:form_apply_type_index="form_apply_type_index"
:form_invoice_content_index="form_invoice_content_index"
:form_apply_type_disabled="form_apply_type_disabled"
:company_container="company_container"
:company_special_container="company_special_container"
:addressee_container="addressee_container"
:email_container="email_container"
@invoice-type-change="form_invoice_type_event"
@apply-type-change="form_apply_type_event"
@invoice-content-change="form_invoice_content_event"
></component-invoice-form-fields>
</block>
</view>
<view class="padding-bottom-main">
<button class="bg-main br-main cr-white round text-size" type="default" form-type="submit" hover-class="none">{{ $t('common.confirm') }}</button>
</view>
</form>
</view>
</view>
</component-popup>
</template>
<script>
const app = getApp();
import componentPopup from '@/components/popup/popup';
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],
props: {
propShow: {
type: Boolean,
default: false,
},
propConfig: {
type: Object,
default: null,
},
propCacheData: {
type: Object,
default: null,
},
propCurrencySymbol: {
type: String,
default: '',
},
},
data() {
return {
config: {},
currency_symbol: app.globalData.currency_symbol(),
is_buy_invoice: 0,
can_invoice_type_list: [],
apply_type_list: [],
invoice_content_list: [],
form_data: {},
form_invoice_type_index: 0,
form_apply_type_index: 0,
form_invoice_content_index: 0,
form_apply_type_disabled: false,
company_container: false,
company_special_container: false,
addressee_container: false,
email_container: true,
};
},
components: {
componentPopup,
componentInvoiceFormFields,
},
watch: {
propShow(val) {
if (val) {
this.init_form();
}
},
propConfig(val) {
if ((val || null) != null) {
this.config = val;
}
},
},
methods: {
init_form() {
var config = this.propConfig || {};
var cache = this.propCacheData || {};
var default_data = config.data || {};
var source = Object.keys(cache).length > 0 ? cache : default_data;
this.config = config;
this.is_buy_invoice = parseInt(source.is_buy_invoice || 0);
this.invoice_form_init_state(source, default_data, {
can_invoice_type_list: config.can_invoice_type_list || [],
apply_type_list: config.apply_type_list || [],
invoice_content_list: config.invoice_content_list || [],
});
},
buy_invoice_choice_event(e) {
this.is_buy_invoice = parseInt(e.detail.value || 0);
if (this.is_buy_invoice == 1) {
this.invoice_container_handle();
}
},
form_submit(e) {
var data = e.detail.value || {};
var result = {
is_buy_invoice: this.is_buy_invoice,
};
if (this.is_buy_invoice != 1) {
this.$emit('onconfirm', result);
return;
}
if (!this.invoice_form_validate(data)) {
return;
}
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'];
result = Object.assign(result, this.invoice_form_collect_result(data, invoice_type, apply_type));
result.is_buy_invoice = 1;
this.$emit('onconfirm', result);
},
close_event() {
this.$emit('onclose');
},
},
};
</script>
<style scoped>
.plugins-invoice-buy-popup {
max-height: 85vh;
overflow-y: auto;
}
.plugins-invoice-buy-popup .popup-header {
position: sticky;
top: 0;
z-index: 1;
background: inherit;
}
.plugins-invoice-buy-popup .invoice-choice-group .form-gorup-title {
margin-bottom: 0;
}
.plugins-invoice-buy-popup .invoice-radio-group {
margin-top: 20rpx;
}
.plugins-invoice-buy-popup .invoice-radio-item {
display: inline-flex;
align-items: center;
font-size: 28rpx;
line-height: 1.4;
}
</style>

View File

@ -0,0 +1,153 @@
<template>
<view class="border-radius-main bg-white oh">
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice.invoice.j04kjc') }}<text class="form-group-tips-must">*</text></view>
<picker name="invoice_type" @change="invoice_type_event" :value="form_invoice_type_index" :range="can_invoice_type_list" range-key="name">
<view :class="'picker ' + (can_invoice_type_list[form_invoice_type_index] == undefined ? 'cr-grey' : 'cr-base') + ' arrow-right'">
{{ can_invoice_type_list[form_invoice_type_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.t3i3e3') : can_invoice_type_list[form_invoice_type_index]['name'] }}
</view>
</picker>
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice.invoice.hoenw8') }}<text class="form-group-tips-must">*</text></view>
<picker name="apply_type" @change="apply_type_event" :disabled="form_apply_type_disabled" :value="form_apply_type_index" :range="apply_type_list" range-key="name">
<view :class="'picker ' + (apply_type_list[form_apply_type_index] == undefined ? 'cr-grey' : 'cr-base') + ' arrow-right'">
{{ apply_type_list[form_apply_type_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.k31t2s') : apply_type_list[form_apply_type_index]['name'] }}
</view>
</picker>
</view>
<view v-if="invoice_content_list.length > 0" class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.p73963') }}<text class="form-group-tips-must">*</text></view>
<picker name="invoice_content" @change="invoice_content_event" :value="form_invoice_content_index" :range="invoice_content_list">
<view :class="'picker ' + (invoice_content_list[form_invoice_content_index] == undefined ? 'cr-grey' : 'cr-base') + ' arrow-right'">
{{ invoice_content_list[form_invoice_content_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.i73t3c') : invoice_content_list[form_invoice_content_index] }}
</view>
</picker>
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice.invoice.y724c7') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_title" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.x461e0')" maxlength="200" :value="form_data.invoice_title || ''" />
</view>
<view v-if="company_container">
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-saveinfo.invoice-saveinfo.x8hhiv') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_code" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.924cag')" maxlength="160" :value="form_data.invoice_code || ''" />
</view>
</view>
<view v-if="company_special_container">
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.41qbu6') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_bank" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.ymvw6b')" maxlength="200" :value="form_data.invoice_bank || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.3a9459') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_account" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.664qc7')" maxlength="160" :value="form_data.invoice_account || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.2g7t23') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_tel" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.bbseo1')" maxlength="15" :value="form_data.invoice_tel || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.6k6sov') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_address" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.85735j')" maxlength="230" :value="form_data.invoice_address || ''" />
</view>
</view>
<view v-if="addressee_container">
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.7159m0') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="name" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.gsc7dy')" maxlength="30" :value="form_data.name || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.f2222p') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="tel" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.bp8822')" maxlength="15" :value="form_data.tel || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('invoice-detail.invoice-detail.q8l3zj') }}<text class="form-group-tips-must">*</text></view>
<input type="text" name="address" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.u7h724')" maxlength="230" :value="form_data.address || ''" />
</view>
</view>
<view v-if="email_container">
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('login.login.db1rf4') }}</view>
<input type="text" name="email" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.d3qbe1')" maxlength="60" :value="form_data.email || ''" />
</view>
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{ $t('common.note') }}</view>
<input type="text" name="user_note" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.vaw647')" maxlength="60" :value="form_data.user_note || ''" />
</view>
</view>
</template>
<script>
export default {
props: {
can_invoice_type_list: {
type: Array,
default: () => [],
},
apply_type_list: {
type: Array,
default: () => [],
},
invoice_content_list: {
type: Array,
default: () => [],
},
form_data: {
type: Object,
default: () => ({}),
},
form_invoice_type_index: {
type: Number,
default: 0,
},
form_apply_type_index: {
type: Number,
default: 0,
},
form_invoice_content_index: {
type: Number,
default: 0,
},
form_apply_type_disabled: {
type: Boolean,
default: false,
},
company_container: {
type: Boolean,
default: false,
},
company_special_container: {
type: Boolean,
default: false,
},
addressee_container: {
type: Boolean,
default: false,
},
email_container: {
type: Boolean,
default: true,
},
},
methods: {
invoice_type_event(e) {
this.$emit('invoice-type-change', e);
},
apply_type_event(e) {
this.$emit('apply-type-change', e);
},
invoice_content_event(e) {
this.$emit('invoice-content-change', e);
},
},
};
</script>

View File

@ -12,96 +12,25 @@
<view class="cr-base margin-top-sm">{{ save_base_data.business_desc }}</view>
</view>
<view class="border-radius-main bg-white oh spacing-mb">
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice.invoice.j04kjc')}}<text class="form-group-tips-must">*</text></view>
<picker name="invoice_type" @change="form_invoice_type_event" :value="form_invoice_type_index" :range="can_invoice_type_list" range-key="name">
<view :class="'picker ' + (can_invoice_type_list[form_invoice_type_index] == undefined ? 'cr-grey' : 'cr-base') + ' arrow-right'">
{{ can_invoice_type_list[form_invoice_type_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.t3i3e3') : can_invoice_type_list[form_invoice_type_index]['name'] }}
</view>
</picker>
</view>
<component-invoice-form-fields
class="spacing-mb"
:can_invoice_type_list="can_invoice_type_list"
:apply_type_list="apply_type_list"
:invoice_content_list="invoice_content_list"
:form_data="data"
:form_invoice_type_index="form_invoice_type_index"
:form_apply_type_index="form_apply_type_index"
:form_invoice_content_index="form_invoice_content_index"
:form_apply_type_disabled="form_apply_type_disabled"
:company_container="company_container"
:company_special_container="company_special_container"
:addressee_container="addressee_container"
:email_container="email_container"
@invoice-type-change="form_invoice_type_event"
@apply-type-change="form_apply_type_event"
@invoice-content-change="form_invoice_content_event"
></component-invoice-form-fields>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice.invoice.hoenw8')}}<text class="form-group-tips-must">*</text></view>
<picker name="apply_type" @change="form_apply_type_event" :disabled="form_apply_type_disabled" :value="form_apply_type_index" :range="apply_type_list" range-key="name">
<view :class="'picker ' + (apply_type_list[form_apply_type_index] == undefined ? 'cr-grey' : 'cr-base') + ' arrow-right'">
{{ apply_type_list[form_apply_type_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.k31t2s') : apply_type_list[form_apply_type_index]['name'] }}
</view>
</picker>
</view>
<view v-if="invoice_content_list.length > 0" class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.p73963')}}<text class="form-group-tips-must">*</text></view>
<picker name="invoice_content" @change="form_invoice_content_event" :value="form_invoice_content_index" :range="invoice_content_list">
<view :class="'picker ' + (invoice_content_list[form_invoice_content_index] == undefined ? 'cr-grey' : 'cr-base') + ' arrow-right'">
{{ invoice_content_list[form_invoice_content_index] == undefined ? $t('invoice-saveinfo.invoice-saveinfo.i73t3c') : invoice_content_list[form_invoice_content_index] }}
</view>
</picker>
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice.invoice.y724c7')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_title" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.x461e0')" maxlength="200" :value="data.invoice_title || ''" />
</view>
<!-- 企业信息 -->
<view v-if="company_container">
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-saveinfo.invoice-saveinfo.x8hhiv')}}<text class="form-group-tips-must">*</text> </view>
<input type="text" name="invoice_code" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.924cag')" maxlength="160" :value="data.invoice_code || ''" />
</view>
</view>
<!-- 企业专票信息 -->
<view v-if="company_special_container">
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.41qbu6')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_bank" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.ymvw6b')" maxlength="200" :value="data.invoice_bank || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.3a9459')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_account" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.664qc7')" maxlength="160" :value="data.invoice_account || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.2g7t23')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_tel" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.bbseo1')" maxlength="15" :value="data.invoice_tel || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.6k6sov')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="invoice_address" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.85735j')" maxlength="230" :value="data.invoice_address || ''" />
</view>
</view>
<!-- 收件人信息 -->
<view v-if="addressee_container">
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.7159m0')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="name" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.gsc7dy')" maxlength="30" :value="data.name || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.f2222p')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="tel" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.bp8822')" maxlength="15" :value="data.tel || ''" />
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('invoice-detail.invoice-detail.q8l3zj')}}<text class="form-group-tips-must">*</text></view>
<input type="text" name="address" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.u7h724')" maxlength="230" :value="data.address || ''" />
</view>
</view>
<!-- 电子邮箱信息 -->
<view v-if="email_container">
<view class="form-gorup">
<view class="form-gorup-title">{{$t('login.login.db1rf4')}}</view>
<input type="text" name="email" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.d3qbe1')" maxlength="60" :value="data.email || ''" />
</view>
</view>
<view class="form-gorup">
<view class="form-gorup-title">{{$t('common.note')}}</view>
<input type="text" name="user_note" placeholder-class="cr-grey" class="cr-base" :placeholder="$t('invoice-saveinfo.invoice-saveinfo.vaw647')" maxlength="60" :value="data.user_note || ''" />
</view>
</view>
<view class="bottom-fixed" :style="bottom_fixed_style">
<view class="bottom-line-exclude">
<button class="item bg-main br-main cr-white round text-size" type="default" form-type="submit" hover-class="none" :loading="form_submit_loading" :disabled="form_submit_loading">{{$t('common.submit')}}</button>
@ -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'));
},
});
}
},
},